-
Notifications
You must be signed in to change notification settings - Fork 177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cephblockpool: allow updation of mirroring field from different components #2480
base: main
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: rewantsoni The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
3c480f8
to
fd14881
Compare
/retest |
fd14881
to
7a82888
Compare
existing.Spec.DeviceClass = cephBlockPool.Spec.DeviceClass | ||
existing.Spec.FailureDomain = cephBlockPool.Spec.FailureDomain | ||
existing.Spec.Replicated = cephBlockPool.Spec.Replicated | ||
existing.Spec.EnableRBDStats = cephBlockPool.Spec.EnableRBDStats | ||
// update the mirroring field only when it is not nil | ||
if instance.Spec.Mirroring != nil { | ||
existing.Spec.Mirroring = cephBlockPool.Spec.Mirroring | ||
} | ||
// update the name only if it is NFS blockpool | ||
if cephBlockPool.Name == generateNameForCephNFSBlockPool(instance) && instance.Spec.NFS != nil && instance.Spec.NFS.Enable { | ||
existing.Spec.Name = cephBlockPool.Spec.Name | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if existing.Spec
is being replaced by all these conditional entries, what happens if some new field gets added to cephBlockPool
and we failed to update that in here?
but again, this is only true if the initial assumption is, this piece doesn't require an update if rook api gets updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only see code changes wrt api changes, however may I know who sets this (mirroringSpec) in the first place?
if that's from UI and has a default, can the field be nullable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MirroringSpec is set by the MCO operator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default CephBlockPool is managed by StorageCluster. So, it is expected that all changes to default pool is made through it. We do not allow other components to change our managed resources by design. We should not have 2 ocs-operator APIs managing the same resource.
@rewantsoni wrt #2480 (review) should this PR be reviewed or not? if not, pls mention what alternatives were considered to move forward, thanks. |
Signed-off-by: Rewant Soni <resoni@redhat.com>
Signed-off-by: Rewant Soni <resoni@redhat.com>
For RDR, we will allow users to use both default block pools and any additional blockpool created by them. The default blockpool is created and managed by the storageCluster whereas the user will create any additional blockpool from the UI. The Mirroring field in the blockpool CR needs to be updated from both StorageClusterPeer and OCS API Server (Provider API Server) ref design doc for more details. If we don't allow the updation of the mirroring field from a different entity,
As a trade-off, we are allowing an update of the cephblockpool mirroring field from different components. @leelavg The PR can be reviewed, I have synced with Umanga and updated the PR. |
existingMirroringSpec := existing.Spec.Mirroring | ||
existing.Spec = cephBlockPool.Spec | ||
|
||
// If mirroring is not set on storageCluster instance, don't update it | ||
if instance.Spec.Mirroring == nil { | ||
existing.Spec.Mirroring = existingMirroringSpec | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a bit confusing, is this what you are trying to achieve?
existingMirroringSpec := existing.Spec.Mirroring | |
existing.Spec = cephBlockPool.Spec | |
// If mirroring is not set on storageCluster instance, don't update it | |
if instance.Spec.Mirroring == nil { | |
existing.Spec.Mirroring = existingMirroringSpec | |
} | |
// If mirroring is not set on storageCluster instance, don't update it | |
if instance.Spec.Mirroring == nil { | |
cephBlockPool.Spec.Mirroring = nil | |
} | |
existing.Spec = cephBlockPool.Spec |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to allow the updation of the mirroring field on the cephBlockPool instance from other components if the mirroring field is not set on storageCluster CR.
Initially, I was updating each field under spec one by one, if a new field is added it might be missed here and lead to bugs. For that, I am creating a temporary copy of the mirroring field from cephblockpool CR and mirroring is not set on storageCluster CR I am setting the value to the temporary variable. So, it will not update the mirroring field on cephblockpool when we don't enable mirroring from storageCluster CR.
The suggestion you made, will update the mirroring field on cephblockpool to be nil if mirroring is not set on storageCluster CR
Signed-off-by: Rewant Soni <resoni@redhat.com>
Signed-off-by: Rewant Soni <resoni@redhat.com>
When ocs-operator reconciles the cephblockpool object, it resets the mirroring field irrespective of whether mirroring is being used in the storageCluster API. This PR aims to modify the storageCluster API and allow us to enable mirroring on cephblockpool from StorageClusterPeer/API Server (required for RDR for Provider Mode).
After this PR,
When the mirroring object is nil, other components can set/unset the mirroringSpec on the cephBlockPool.
When the mirroring object is not nil, mirroring on the pools will be set based on the value of MirroringSpec in the storageCluster.