-
Notifications
You must be signed in to change notification settings - Fork 39
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
Fix- When removing all services from a cluster deployment the services remain deployed #1141
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not find the suggested approach sustainable, nor does it fit into the controllers pattern: the Profile
is being created unconditionally several LOC above and then it gets almost immediately removed. I'd suggest adding extra logic to assert should we create a Profile
instance or not and/or update the instance accordingly to the given services in the .spec
.
This needs to be corrected for the MultiClusterService as well. Both of them call the kcm/internal/sveltos/profile.go Line 150 in bbda49d
I am trying to understand why we are seeing this bug. The way I understand it is that if Why is that not happening? |
It appears that sveltos doesn't handle this situation right (or maybe it does depending on how you look at things). I guess basically they assume that if you want to remove the last helm chart you delete the profile. |
It actually creates or updates if you look into the ReconcileProfile function. |
I understand that, my point was to add logic to skip creation if it should not be created at all and update the conditions accordingly. The current approach is creating, immediately removing, and repeating the same. So I discourage such API calls, especially if one thinks about not a single managed object, but at least dozens or hundreds. And please address that @wahabmk mentioned above:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requesting changes, details are here
Circling back to my comment, I remember testing some time back that the Profile/ClusterProfile object gets created with 0 HelmCharts when services = 0, which is why I made the following comment: kcm/internal/sveltos/profile.go Lines 146 to 149 in bbda49d
The "Making services list empty" section of #362 (where it was first written) verifies that this is the case. I wonder why this is not happening anymore, or are we missing something? Sveltos as of ➜ ~ kubectl get profiles.config.projectsveltos.io kyverno -o yaml -n kcm-system
apiVersion: config.projectsveltos.io/v1beta1
kind: Profile
metadata:
annotations:
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"config.projectsveltos.io/v1beta1","kind":"Profile","metadata":{"annotations":{},"name":"kyverno","namespace":"kcm-system"},"spec":{"clusterSelector":{"matchLabels":{"env":"prod"}}}}
creationTimestamp: "2025-03-04T12:35:32Z"
finalizers:
- profilefinalizer.projectsveltos.io
generation: 2
name: kyverno
namespace: kcm-system
resourceVersion: "8571"
uid: 60ad175d-81f6-4d7a-ae9e-9bbfc553e1eb
spec:
clusterSelector:
matchLabels:
env: prod
continueOnConflict: false
continueOnError: false
reloader: false
stopMatchingBehavior: WithdrawPolicies
syncMode: Continuous
tier: 100 |
@wahabmk, there is probably just an error calculating the statuses, and that is that simple because I was purely relying on the So, here is the following remark in the issue:
|
Yes, that makes sense. So it's probably not a problem of services not being removed, but that the |
Exactly! I am glad we'd localized the problem, so ultimately it is the error of calculating the status. There are several approaches for the conditions, the default one is to reset the conditions at the start of the reconcile loop and then recalculate it. @kylewuolle could you please make the corresponding amends regarding the comments above? And I assume that should be done for both |
8765291
to
0d50e99
Compare
OK so it turns out I was wrong! If you remove the helm charts from the profile it does uninstall properly at least in the latest version of sveltos. I've changed the PR to be just about ensuring the status is updated properly in the case of removal of all the helm charts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please fix the linter
799fa87
to
44f30d3
Compare
…e sveltos Profile which will trigger the addon controller to remove the installed services.
…ame logic for multiservice and also added check for service length so the status is updated properly when services are removed completely
44f30d3
to
0ac589e
Compare
This simple fix resolves an issue where the services aren't removed by sveltos when the services list is empty / missing in the cluster deployment after previously being deployed. The fix is to remove the sveltos profile which triggers the adon controller to un-deploy all the helm charts associated with the profile.
Testing performed:
Closes #1132