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

Ownership deletion secret #21

Merged
merged 3 commits into from
Nov 13, 2023
Merged

Ownership deletion secret #21

merged 3 commits into from
Nov 13, 2023

Conversation

bigkevmcd
Copy link
Collaborator

@bigkevmcd bigkevmcd commented Nov 8, 2023

This places the Secret under the ownership of the generated GitopsCluster.

It also adds the annotation to the created GitopsCluster to indicate that it can be removed without the secret being removed, as it will cascade because of the ownership in this case.

@bigkevmcd bigkevmcd requested a review from a team November 8, 2023 16:33
@bigkevmcd bigkevmcd force-pushed the ownership-deletion-secret branch 2 times, most recently from 99ec98e to 55c5023 Compare November 9, 2023 12:07
@bigkevmcd bigkevmcd marked this pull request as ready for review November 9, 2023 12:31
Copy link
Collaborator

@foot foot left a comment

Choose a reason for hiding this comment

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

🔥

Works great, w/ new cluster-controller.

  • Annotation added
  • Deleting cluster deletes secret immediately

Follow up / questions:

  • Should this trigger a new ACD reconcile immediately? Status still stays ready etc even though cluster / secret is gone.
  • ~30% of the time I get a transient error[0] about a missing secret, but the sometimes retries, / manually syncing again seems to fix it

[0]

[manager] 2023-11-10T09:34:51Z	INFO	reconciling cluster reflector	{"controller": "automatedclusterdiscovery", "controllerGroup": "clusters.weave.works", "controllerKind": "AutomatedClusterDiscovery", "AutomatedClusterDiscovery": {"name":"aks-cluster-discovery","namespace":"default"}, "namespace": "default", "name": "aks-cluster-discovery", "reconcileID": "4e36d643-5b9e-4d54-a7d9-5d5a52908e23", "type": "aks", "name": ""}
[manager] 2023-11-10T09:34:51Z	INFO	reconciling AKS cluster reflector	{"controller": "automatedclusterdiscovery", "controllerGroup": "clusters.weave.works", "controllerKind": "AutomatedClusterDiscovery", "AutomatedClusterDiscovery": {"name":"aks-cluster-discovery","namespace":"default"}, "namespace": "default", "name": "aks-cluster-discovery", "reconcileID": "4e36d643-5b9e-4d54-a7d9-5d5a52908e23", "name": ""}
[manager] 2023-11-10T09:34:56Z	INFO	reconciling clusters	{"controller": "automatedclusterdiscovery", "controllerGroup": "clusters.weave.works", "controllerKind": "AutomatedClusterDiscovery", "AutomatedClusterDiscovery": {"name":"aks-cluster-discovery","namespace":"default"}, "namespace": "default", "name": "aks-cluster-discovery", "reconcileID": "4e36d643-5b9e-4d54-a7d9-5d5a52908e23", "count": 1}
[manager] 2023-11-10T09:34:56Z	INFO	creating gitops cluster	{"controller": "automatedclusterdiscovery", "controllerGroup": "clusters.weave.works", "controllerKind": "AutomatedClusterDiscovery", "AutomatedClusterDiscovery": {"name":"aks-cluster-discovery","namespace":"default"}, "namespace": "default", "name": "aks-cluster-discovery", "reconcileID": "4e36d643-5b9e-4d54-a7d9-5d5a52908e23", "name": "pestomarketplacetest"}
[manager] 2023-11-10T09:34:56Z	INFO	creating secret	{"controller": "automatedclusterdiscovery", "controllerGroup": "clusters.weave.works", "controllerKind": "AutomatedClusterDiscovery", "AutomatedClusterDiscovery": {"name":"aks-cluster-discovery","namespace":"default"}, "namespace": "default", "name": "aks-cluster-discovery", "reconcileID": "4e36d643-5b9e-4d54-a7d9-5d5a52908e23", "name": "pestomarketplacetest-kubeconfig"}
[manager] 2023-11-10T09:34:56Z	ERROR	failed to reconcile clusters	{"controller": "automatedclusterdiscovery", "controllerGroup": "clusters.weave.works", "controllerKind": "AutomatedClusterDiscovery", "AutomatedClusterDiscovery": {"name":"aks-cluster-discovery","namespace":"default"}, "namespace": "default", "name": "aks-cluster-discovery", "reconcileID": "4e36d643-5b9e-4d54-a7d9-5d5a52908e23", "error": "failed to get the secret to update: Secret \"pestomarketplacetest-kubeconfig\" not found"}
[manager] github.com/weaveworks/cluster-reflector-controller/internal/controller.(*AutomatedClusterDiscoveryReconciler).reconcileResources
[manager] 	/workspace/internal/controller/automatedclusterdiscovery_controller.go:171
[manager] github.com/weaveworks/cluster-reflector-controller/internal/controller.(*AutomatedClusterDiscoveryReconciler).Reconcile
[manager] 	/workspace/internal/controller/automatedclusterdiscovery_controller.go:91
[manager] sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile
[manager] 	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:118
[manager] sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
[manager] 	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:314
[manager] sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
[manager] 	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:265
[manager] sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
[manager] 	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:226
[manager] 2023-11-10T09:34:56Z	ERROR	Reconciler error	{"controller": "automatedclusterdiscovery", "controllerGroup": "clusters.weave.works", "controllerKind": "AutomatedClusterDiscovery", "AutomatedClusterDiscovery": {"name":"aks-cluster-discovery","namespace":"default"}, "namespace": "default", "name": "aks-cluster-discovery", "reconcileID": "4e36d643-5b9e-4d54-a7d9-5d5a52908e23", "error": "failed to get the secret to update: Secret \"pestomarketplacetest-kubeconfig\" not found"}
[manager] sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler
[manager] 	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:324
[manager] sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem
[manager] 	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:265
[manager] sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2
[manager] 	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:226

@bigkevmcd bigkevmcd closed this Nov 10, 2023
@bigkevmcd bigkevmcd reopened this Nov 10, 2023
This changes the ownership of Secrets to be owned by the referencing
GitopsCluster.
This does two things, the Secret is owned by the Cluster which causes
cascading removal.

It also annotates the Cluster to indicate that the cluster-controller
should not wait for the Secret to be removed.
@bigkevmcd bigkevmcd merged commit b1483e5 into main Nov 13, 2023
3 checks passed
@bigkevmcd bigkevmcd deleted the ownership-deletion-secret branch November 13, 2023 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants