fix(): Persist VpnKeyRotation owner reference to Kubernetes API server#398
Open
Priyanshubhartistm wants to merge 2 commits into
Open
fix(): Persist VpnKeyRotation owner reference to Kubernetes API server#398Priyanshubhartistm wants to merge 2 commits into
Priyanshubhartistm wants to merge 2 commits into
Conversation
60784ea to
a099bc7
Compare
SetControllerReference() was only setting the owner reference in memory but never calling UpdateResource() to persist it to the Kubernetes API server (etcd). This caused VpnKeyRotation CRs to become orphans after their parent SliceConfig was deleted, since Kubernetes GC relies on ownerReferences stored in etcd to perform cascading deletion. Fix: Add UpdateResource() call immediately after SetControllerReference() so the owner reference is durably written to the cluster. Fixes: kubeslice#396 Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
- Replace util.Client with client.Client in prepareACSTestContext,
prepareNamespaceTestContext, and prepareProjectTestContext function
signatures. util.Client type does not exist; the correct type is
client.Client from sigs.k8s.io/controller-runtime/pkg/client.
- Add missing client package import to project_service_test.go.
- Remove deprecated ClusterName field from metav1.ObjectMeta struct
literal in worker_slice_gateway_service_test.go. ClusterName was
removed from ObjectMeta in k8s API 1.25+.
- Fix namespace_service_test.go mock expectation to include
Annotations: map[string]string{} to match what the service sets.
Signed-off-by: Priyanshubhartistm <bhartipriyanshustm@gmail.com>
0384a02 to
8763045
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #396
When
VpnKeyRotationhas no owner references,controllerutil.SetControllerReference()was called to link it to the parentSliceConfig- butUpdateResource()was never called after. So the owner reference only lived in memory and was never saved to etcd. WhenSliceConfiggets deleted, Kubernetes GC has no idea these two are related, soVpnKeyRotationstays around as an orphan.Fix is one call:
util.UpdateResource()right afterSetControllerReference().How Has This Been Tested?
go build ./...- passes, no errorsgo test -gcflags=-l ./service- all existing tests passChecklist:
Does this PR introduce a breaking change for other components like worker-operator?
No. Single line added inside an existing nil-guard. No API or schema changes.