-
Notifications
You must be signed in to change notification settings - Fork 148
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
update: DSC status update and delete component CR if it is not set Managed #1390
update: DSC status update and delete component CR if it is not set Managed #1390
Conversation
instance, _ = status.UpdateWithRetry(ctx, r.Client, instance, func(saved *dscv1.DataScienceCluster) { | ||
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileFailed, fmt.Sprintf("Component reconciliation failed: %v", err), corev1.ConditionFalse) | ||
status.SetComponentCondition(&saved.Status.Conditions, componentName, status.ReconcileFailed, fmt.Sprintf("Component creation failed: %v", err), corev1.ConditionFalse) |
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.
nit: this method does not only creates a component, but would also update it so I think reconciliation
is more appropriate
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.
correct. let me revert it
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.
updated
@@ -78,6 +78,9 @@ type DataScienceClusterConfig struct { | |||
|
|||
const ( | |||
finalizerName = "datasciencecluster.opendatahub.io/finalizer" | |||
RHOAIAppNS = "redhat-ods-applications" | |||
ODHAppNS = "opendatahub" | |||
MonitoringNS = "redhat-ods-monitoring" |
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.
Those changes do not seem to be related with the PR :)
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.
yeah, the lint is annoying, to get rid of the //nolint:goconst
but i can revert it
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.
reverted
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## feature-operator-refactor #1390 +/- ##
============================================================
Coverage ? 27.16%
============================================================
Files ? 60
Lines ? 4804
Branches ? 0
============================================================
Hits ? 1305
Misses ? 3347
Partials ? 152 ☔ View full report in Codecov by Sentry. |
@@ -360,7 +352,7 @@ func (r *DataScienceClusterReconciler) apply(ctx context.Context, dsc *dscv1.Dat | |||
} | |||
|
|||
managementStateAnn, exists := obj.GetAnnotations()[annotations.ManagementStateAnnotation] | |||
if exists && managementStateAnn == string(operatorv1.Removed) { | |||
if exists && (managementStateAnn == string(operatorv1.Removed) || managementStateAnn == "Unknown") { |
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.
When is this case happening ? I wonder if we should only handle Managed
and Removed
, and return an error or skip otherwise ?
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.
we can set it in DSC as
components:
codeflare: {}
which is the same
components:
codeflare:
managementState: Removed
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.
currently we tell user, do not set managementState in the component is the same as set it to Removed.
to make it easier i always create DSC with
spec:
components:
modelmeshserving:
managementState: Managed
only ;D , then i found other new components get created
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.
so I guess the mapping could be done in the components' NewCRObject
?
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.
yeah, either do in all components NewCRObject(), or a central place.
thinking it out, if one day, we add Force or Unmanaged as supported case, we will need it in NewCRObject(), then DSC need logic to handle that as well.
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.
Now since components have GetManagementState
, maybe we can move it to a central place.
/test opendatahub-operator-e2e |
- delete component CR when it is either set to Removed or not set in DSC - remove old status updates, only update when component CR create successful or failed Signed-off-by: Wen Zhou <[email protected]>
- change return as string, used by NewCRObject() - move logic check on Managed, Removed, not set component and others into GetManagementState() Signed-off-by: Wen Zhou <[email protected]>
Signed-off-by: Wen Zhou <[email protected]>
case operatorv1.Managed, operatorv1.Removed: | ||
return string(dsc.Spec.Components.Dashboard.ManagementState) | ||
default: // Force and Unmanaged case for unknown values, we do not support these yet | ||
return "Unknown" |
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.
Wonder if this should return operatorv1.Removed
, in other words, how do we generally handle the case where the ManagementState
is not set ?
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 think it falls into the s == nil
case ?
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.
Now, i think i understand your comments better:
i can think of two approaches:
- remove this default for now: since enum is only for Removed and Managed. till we add support for Force and Unmanaged, we do not need to worry about "default"
func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) operatorv1.ManagementState {
if s == nil {
return operatorv1.Removed
}
return dsc.Spec.Components.Dashboard.ManagementState
}
- change the whole funciton to
func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) operatorv1.ManagementState {
if dsc.Spec.Components.Dashboard.ManagementState == operatorv1.Managed {
return operatorv1.Managed
}
return operatorv1.Removed
}
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.
yep something like option 2
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.
updated
return dsc.Spec.Components.Dashboard.ManagementState | ||
func (s *componentHandler) GetManagementState(dsc *dscv1.DataScienceCluster) string { | ||
if s == nil { | ||
return "Removed" |
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 would do return string(operatorv1.Removed)
so it is always consistent with the constant
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 first made the one with return string(operatorv1.Removed)
then i thought to convert a const to string, is that extra step to just return a string.
but yeah, i get your point, i can get that reverted
@@ -21,7 +20,7 @@ type ComponentHandler interface { | |||
// GetName and GetManagementState sound like pretty much the same across | |||
// all components, but I could not find a way to avoid it | |||
GetName() string | |||
GetManagementState(dsc *dscv1.DataScienceCluster) operatorv1.ManagementState | |||
GetManagementState(dsc *dscv1.DataScienceCluster) string |
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 we always return a known state, then we don't need tor return a plain string
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.
yeah, lets revert back to operatorv1.ManagementState
…ementState() - return Managed if component is managed, other case, return Removed Signed-off-by: Wen Zhou <[email protected]>
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lburgazzoli The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
7384fe6
into
opendatahub-io:feature-operator-refactor
Description
split out changes not related to modelmesh from #1338
How Has This Been Tested?
Screenshot or short clip
Merge criteria