Skip to content
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

Conversation

zdtsw
Copy link
Member

@zdtsw zdtsw commented Nov 26, 2024

  • delete component CR when it is either set to Removed or not set in DSC
  • remove old status updates"Component is disabled/enabled), only update when component CR create successful or failed (should have follow up to add check if CR status is ready or notready)
  • fix a bug in datasciencpipeline :D datasciencepipelines component refactor #1340

Description

split out changes not related to modelmesh from #1338

How Has This Been Tested?

Screenshot or short clip

Merge criteria

  • You have read the contributors guide.
  • Commit messages are meaningful - have a clear and concise summary and detailed explanation of what was changed and why.
  • Pull Request contains a description of the solution, a link to the JIRA issue, and to any dependent or related Pull Request.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

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)
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Member Author

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"
Copy link
Contributor

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 :)

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reverted

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes missing coverage. Please review.

Please upload report for BASE (feature-operator-refactor@7da9176). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...atasciencecluster/datasciencecluster_controller.go 0.00% 12 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

@@ -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") {
Copy link
Contributor

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 ?

Copy link
Member Author

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

Copy link
Member Author

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

Copy link
Contributor

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 ?

Copy link
Member Author

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.

Copy link
Contributor

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.

@zdtsw
Copy link
Member Author

zdtsw commented Nov 26, 2024

/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]>
@zdtsw zdtsw requested a review from jackdelahunt November 27, 2024 08:37
@zdtsw zdtsw changed the title update: DSC status update and remove component CR's case update: DSC status update and delete component CR if it is not set Managed Nov 27, 2024
@zdtsw zdtsw requested a review from lburgazzoli November 27, 2024 10:20
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"
Copy link
Contributor

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 ?

Copy link
Member Author

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 ?

Copy link
Member Author

@zdtsw zdtsw Nov 27, 2024

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:

  1. 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
}
  1. 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
}

Copy link
Contributor

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

Copy link
Member Author

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"
Copy link
Contributor

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

Copy link
Member Author

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
Copy link
Contributor

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

Copy link
Member Author

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]>
Copy link

openshift-ci bot commented Nov 27, 2024

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 7384fe6 into opendatahub-io:feature-operator-refactor Nov 27, 2024
10 checks passed
@lburgazzoli lburgazzoli mentioned this pull request Nov 27, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants