fix: apply ssa namespace twice
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.
Kudos, SonarCloud Quality Gate passed! 
0 Bugs
0 Vulnerabilities
0 Security Hotspots
1 Code Smell
No Coverage information
0.0% Duplication
Codecov Report
Attention: 6 lines in your changes are missing coverage. Please review.
Comparison is base (
f15cf61) 54.63% compared to head (0115c94) 54.64%.
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
| Files | Coverage Δ | |
|---|---|---|
| pkg/sync/sync_context.go | 73.81% <62.50%> (-0.27%) |
:arrow_down: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Kudos, SonarCloud Quality Gate passed! 
0 Bugs
0 Vulnerabilities
0 Security Hotspots
1 Code Smell
No Coverage information
0.0% Duplication