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

🐛 Allow rancher cluster to be deleted from UI #87

Merged

Conversation

Danil-Grigorev
Copy link
Contributor

@Danil-Grigorev Danil-Grigorev commented Aug 23, 2023

kind/bug

What this PR does / why we need it:

This addresses the problems described in #86.

Checklist:

  • squashed commits into logical changes
  • includes documentation
  • adds unit tests
  • adds or updates e2e tests

@Danil-Grigorev Danil-Grigorev added the kind/bug Something isn't working label Aug 23, 2023
@Danil-Grigorev Danil-Grigorev requested a review from a team as a code owner August 23, 2023 16:07
if annotations == nil {
annotations = map[string]string{}
}
// If the Rancher Cluster was already imported, then annotate the CAPI cluster so that we don't auto-import again.
Copy link
Contributor

Choose a reason for hiding this comment

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

where is the check in the code from this comment, I seem to be missing it

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.

can we log the message in that case, it was not obvious from first look

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Operator does not reconcile non-imported rancher clusters. Imported rancher cluster follows the <capi-cluster>-capi naming convention. Therefore it is not possible here that any of the reconcile code, including reconcile delete would be executed on non-imported rancher cluster, unless it follows given naming convention. So log message on the https://github.com/rancher-sandbox/rancher-turtles/pull/87/files#diff-df81a5620bfede50d1c70fd0ebb982e652d28721e15b825c52dddcf97ceda0deR311 and https://github.com/rancher-sandbox/rancher-turtles/pull/87/files#diff-df81a5620bfede50d1c70fd0ebb982e652d28721e15b825c52dddcf97ceda0deR314 are both describing what is happening with the cluster. Don’t see a need to make it more vivid than that.

Copy link
Member

Choose a reason for hiding this comment

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

It will also be logged in the predicate itself. My concern is that as far as I know predicates might not always work as expected and we should structure our code like they don't exist, it's nice if they filter out resources for us but don't expect them to always do that. I wouldn't remove the code.

furkatgofurov7
furkatgofurov7 previously approved these changes Aug 24, 2023
if annotations == nil {
annotations = map[string]string{}
}
// If the Rancher Cluster was already imported, then annotate the CAPI cluster so that we don't auto-import again.
Copy link
Contributor

Choose a reason for hiding this comment

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

can we log the message in that case, it was not obvious from first look

@furkatgofurov7
Copy link
Contributor

How does this affect #85?

@Danil-Grigorev
Copy link
Contributor Author

How does this affect #85?

It fully follows the proposal at the state as it is in right now.

internal/helpers/name_converter.go Outdated Show resolved Hide resolved
log := log.FromContext(ctx)
log.Info("Reconciling CAPI Cluster Delete")
log.Info("Reconciling rancher cluster deletion")
Copy link
Member

Choose a reason for hiding this comment

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

but we are reconciling CAPI cluster deletion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right now we have to act upon the fact that rancher cluster is getting deleted

internal/controllers/import_controller.go Outdated Show resolved Hide resolved
if annotations == nil {
annotations = map[string]string{}
}
// If the Rancher Cluster was already imported, then annotate the CAPI cluster so that we don't auto-import again.
Copy link
Member

Choose a reason for hiding this comment

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

It will also be logged in the predicate itself. My concern is that as far as I know predicates might not always work as expected and we should structure our code like they don't exist, it's nice if they filter out resources for us but don't expect them to always do that. I wouldn't remove the code.

@Danil-Grigorev
Copy link
Contributor Author

@alexander-demicev Could you provide some details to support this claim? #87 (comment) Predicates are a feature which was present in controller-runtime for multiple years, and is a simple filtering system for incoming objects from client cache. If it was ever true (only due to assumption that API server may return not a fully valid object, this was fixed). It is used in numerous production installations. I don’t think this is a concern.

mjura
mjura previously approved these changes Aug 24, 2023
Copy link

@mjura mjura left a comment

Choose a reason for hiding this comment

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

lgtm

@alexander-demicev
Copy link
Member

@Danil-Grigorev It happened about 2 years ago when we worked on externally managed infrastructure for CAPI, I can't find this discussion. If not working predicate appears, let's fix it when it happens :)

…luster

Add converter method for rancher/CAPI cluster names

Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
…clsuter

Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
Signed-off-by: Danil Grigorev <danil.grigorev@suse.com>
@Danil-Grigorev
Copy link
Contributor Author

Can we merge this? Capi cluster event causes rancher cluster to be re-imported as of right now. @furkatgofurov7 @alexander-demicev I don't understand the delay in reviews

@furkatgofurov7
Copy link
Contributor

Can we merge this? Capi cluster event causes rancher cluster to be re-imported as of right now. @furkatgofurov7 @alexander-demicev I don't understand the delay in reviews

I did pass through it once already and not blocking it from my side as per comments?

@@ -173,7 +176,7 @@ func (r *CAPIImportReconciler) Reconcile(ctx context.Context, req ctrl.Request)
func (r *CAPIImportReconciler) reconcile(ctx context.Context, capiCluster *clusterv1.Cluster) (ctrl.Result, error) {
// fetch the rancher clusters
rancherClusterHandler := rancher.NewClusterHandler(ctx, r.Client)
rancherClusterName := rancherClusterNameFromCAPICluster(capiCluster.Name)
rancherClusterName := helpers.Name(capiCluster.Name).ToRancherName()
Copy link
Contributor

Choose a reason for hiding this comment

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

Not entirely convinced by the change here, its feels less obvious.

@Danil-Grigorev Danil-Grigorev merged commit 70f5f0d into rancher:main Sep 1, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants