-
Notifications
You must be signed in to change notification settings - Fork 261
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: apply ssa namespace twice #537
base: master
Are you sure you want to change the base?
fix: apply ssa namespace twice #537
Conversation
pkg/sync/sync_context.go
Outdated
nsSpec := &v1.Namespace{TypeMeta: metav1.TypeMeta{APIVersion: "v1", Kind: kube.NamespaceKind}, ObjectMeta: metav1.ObjectMeta{Name: t.liveObj.GetName(), Annotations: t.liveObj.GetAnnotations(), Labels: t.liveObj.GetLabels(), Namespace: t.liveObj.GetNamespace()}} | ||
liveCopy, err := kube.ToUnstructured(nsSpec) | ||
|
||
message, err = sc.resourceOps.ApplyResource(context.TODO(), liveCopy, dryRunStrategy, force, validate, serverSideApply, "argocd-controller-tmp") |
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.
argocd-controller-tmp
is a placeholder name, but the idea is that in order to preserve existing metadata we need to apply the namespace with a separate manager before using managedNamespaceMetadata
on said namespace.
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #537 +/- ##
=======================================
Coverage 54.63% 54.64%
=======================================
Files 41 41
Lines 4638 4652 +14
=======================================
+ Hits 2534 2542 +8
- Misses 1908 1912 +4
- Partials 196 198 +2
☔ View full report in Codecov by Sentry. |
This requires argoproj/gitops-engine#537. This is more or less similar to argoproj#13965, with the difference that this is _only_ upgrading dependencies and does not require any changes in the usage of `managedNamespaceMetadata`. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This requires argoproj/gitops-engine#537. This is more or less similar to argoproj#13965, with the difference that this is _only_ upgrading dependencies and does not require any changes in the usage of `managedNamespaceMetadata`. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This requires argoproj/gitops-engine#537. This builds upon argoproj#13965, with the difference that this does not require any changes in the usage of `managedNamespaceMetadata`. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This requires argoproj/gitops-engine#537. This builds upon argoproj#13965, with the difference that this does not require any changes in the usage of `managedNamespaceMetadata`. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This requires argoproj/gitops-engine#537. This builds upon argoproj#13965, with the difference that this does not require any changes in the usage of `managedNamespaceMetadata`. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This requires argoproj/gitops-engine#537. This builds upon argoproj#13965, with the difference that this does not require any changes in the usage of `managedNamespaceMetadata`. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This requires argoproj/gitops-engine#537. This builds upon argoproj#13965, with the difference that this does not require any changes in the usage of `managedNamespaceMetadata`. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Use argoproj/gitops-engine#537 version of gitops-engine, which preserves the intended behaviour; which is that an existing namespace can be "adopted" when using `managedNamespaceMetadata` without removing existing labels and annotations. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
This is based on argoproj#13965, which this time hopefully has been updated and merged correctly to a currentish version of argo-cd. The main difference here is that the gitops version is based upon argoproj/gitops-engine#537, which should maintain pre-existing labels and annotations. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
c3be8a4
to
76e7caf
Compare
In argoproj/argo-cd#13965, upgrading to client-go 0.26 uncovered an issue with existing namespaces not preserving labels and annotations when converting an existing namespace to use `managedNamespaceMetadata`. From 0.26 up, in order to preserve the existing behaviour what we need to do is to first apply the existing namespace with SSA and its preexisting labels and annotations. This also needs to be applied with another manager than the default one. After that initial apply, we proceed as normal with a ServerSideApply. This is a one-time thing for any existing namespace; we check if we need to perform this action by detecting if there is a preexisting SSA annotation on the namespace. Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com> Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
76e7caf
to
45d4394
Compare
Signed-off-by: Blake Pettersson <blake.pettersson@gmail.com>
Kudos, SonarCloud Quality Gate passed! 0 Bugs No Coverage information |
In argoproj/argo-cd#13965, upgrading to client-go 0.26 uncovered an issue with existing namespaces not preserving labels and annotations when converting an existing namespace to use
managedNamespaceMetadata
.From 0.26 up, in order to preserve the existing behaviour what we need to do is to first apply the existing namespace with SSA and its preexisting labels and annotations. This also needs to be applied with another manager than the default one.
After that initial apply, we proceed as normal with a ServerSideApply. This is a one-time thing for any existing namespace; we check if we need to perform this action by detecting if there is a preexisting SSA annotation on the namespace.