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

Migration uninstall configmap from DSC to setup controller #1438

Merged
merged 12 commits into from
Dec 19, 2024

Conversation

biswassri
Copy link
Contributor

@biswassri biswassri commented Dec 10, 2024

Description

JIRA: RHOAIENG-16674

Created a new setup-controller and moved the below functionalities to uninstallation.go if HasDeleteConfigMap exists

  • Deletion of the DataScienceCluster instance
  • Operator uninstall
  • Existing workflow

How Has This Been Tested?

Testing process :

  • install cluster
  • create dsc and dsci
  • create delete-configmap with
labels:
    api.openshift.com/addon-managed-odh-delete: 'true'
  • check dsc and dsci deletion and logs for deletion of other resources

Screenshot or short clip

Screenshot 2024-12-16 at 1 00 29 PM

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

@ykaliuta
Copy link
Contributor

Could you put description in the commit message?

}

// Fetch the DataScienceCluster instance
if len(instances.Items) == 0 {
Copy link
Contributor

Choose a reason for hiding this comment

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

100% :)

platform := currentOperatorRelease.Name
instances := &dscv1.DataScienceClusterList{}

// Check if the delete ConfigMap exists
Copy link
Contributor

Choose a reason for hiding this comment

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

Obvious from the function name actually

return reconcile.Result{}, nil
}

// Fetch the DataScienceCluster instance
Copy link
Contributor

Choose a reason for hiding this comment

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

I do not see that

Copy link
Contributor Author

@biswassri biswassri Dec 10, 2024

Choose a reason for hiding this comment

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

The comment should go above this right ? instances := &dscv1.DataScienceClusterList{}


// Check if the delete ConfigMap exists
if !upgrade.HasDeleteConfigMap(ctx, r.Client) {
log.Info("No delete ConfigMap found, skipping reconciliation")
Copy link
Contributor

Choose a reason for hiding this comment

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

Probably, loglevels can be revisited

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, maybe in separate PR or probably after we decide the workflow for this intended task is good.

}
}
// Delete the DataScienceCluster instance
if err := r.Client.Delete(ctx, instance, []client.DeleteOption{}...); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

what is the trick with the options?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap.

@biswassri
Copy link
Contributor Author

biswassri commented Dec 10, 2024

@ykaliuta Thanks for the review. Updated the description Let me know if you have any other questions

Additionally,
/cc @lburgazzoli @VaishnaviHire I took a first go at the possible solution of the above mentioned task. Let me know wdyt or we can discuss further in the channel/gmeet (if you think a longer conversation is needed)
I haven't worked on getting past the tests, I'll work on that once we are good with the workflow

@biswassri biswassri marked this pull request as ready for review December 13, 2024 06:47
@biswassri biswassri changed the title [WIP] Migration uninstall configmap from DSC to setup controller Migration uninstall configmap from DSC to setup controller Dec 13, 2024
Makefile Outdated Show resolved Hide resolved
Copy link

codecov bot commented Dec 16, 2024

Codecov Report

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

Please upload report for BASE (main@9704854). Learn more about missing BASE report.

Files with missing lines Patch % Lines
controllers/setupcontroller/setup_controller.go 0.00% 47 Missing ⚠️
pkg/upgrade/uninstallation.go 0.00% 11 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1438   +/-   ##
=======================================
  Coverage        ?   19.10%           
=======================================
  Files           ?      158           
  Lines           ?    10362           
  Branches        ?        0           
=======================================
  Hits            ?     1980           
  Misses          ?     8158           
  Partials        ?      224           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

return ctrl.Result{}, nil
case err != nil:
return ctrl.Result{}, err
if err := r.Client.Get(ctx, req.NamespacedName, instance); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

a check fr "NotFound" error is probably needed, in such case, the reconciliation loop can return early

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeap makes sense. I'll update this.

@biswassri
Copy link
Contributor Author

/retest

1 similar comment
@biswassri
Copy link
Contributor Author

/retest


func (r *SetupControllerReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
log := logf.FromContext(ctx).WithName("SetupController")
log.Info("Reconciling setup controller", "Request.Name", req.Name) // log.V(1).Info(...)
Copy link
Contributor

Choose a reason for hiding this comment

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

"Request.Name", req.Name is probably redundant as it should be included already in the log passed to the within the context. Can you confirm ?

Copy link
Contributor Author

@biswassri biswassri Dec 16, 2024

Choose a reason for hiding this comment

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

Yeah you're correct it does get passed from within the context.
This is the log for this bit

{"level":"info","ts":"2024-12-16T14:00:12Z","logger":"SetupContoller","msg":"Reconciling setup controller","controller":"configmap","controllerGroup":"","controllerKind":"ConfigMap","ConfigMap":{"name":"delete-configmap","namespace":"opendatahub-operator-system"},"namespace":"opendatahub-operator-system","name":"delete-configmap","reconcileID":"1c11083d-f086-4198-bfde-ba26a7f7fc38","Request.Name":"delete-configmap"}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is similar to that in DSC controller too. But maybe it makes sense for the DSC and not for the setup controller? Or should it be removed from there too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably it should be revisited in the DSC controller too, for the moment I would just fix it here

Copy link
Contributor Author

@biswassri biswassri Dec 17, 2024

Choose a reason for hiding this comment

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

Done 👍 Updated the setup controller only

@biswassri
Copy link
Contributor Author

/retest

1 similar comment
@biswassri
Copy link
Contributor Author

/retest

@lburgazzoli
Copy link
Contributor

LGTM, @grdryn anything missing ?

Copy link
Member

@grdryn grdryn left a comment

Choose a reason for hiding this comment

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

/lgtm 👍

Copy link

openshift-ci bot commented Dec 18, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: grdryn

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-ci openshift-ci bot removed the lgtm label Dec 18, 2024
@lburgazzoli
Copy link
Contributor

/lgtm

@biswassri
Copy link
Contributor Author

/retest

2 similar comments
@biswassri
Copy link
Contributor Author

/retest

@biswassri
Copy link
Contributor Author

/retest

@openshift-merge-bot openshift-merge-bot bot merged commit 56109a7 into opendatahub-io:main Dec 19, 2024
10 checks passed
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.

6 participants