-
Notifications
You must be signed in to change notification settings - Fork 931
Add NamespaceManagement reconciliation #1687
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
base: master
Are you sure you want to change the base?
Conversation
c16e6e4
to
f353e2a
Compare
c7bcc4e
to
ccecd06
Compare
0788240
to
0d67be6
Compare
8da9978
to
1495dbc
Compare
53e5090
to
c4a47fa
Compare
f6d3ea6
to
974290d
Compare
allowedNamespaces := make(map[string]bool) | ||
if argocd.Spec.NamespaceManagement != nil { | ||
for _, nm := range argocd.Spec.NamespaceManagement { | ||
allowedNamespaces[nm.Name] = nm.AllowManagedBy |
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.
nm.Name
can be a pattern; this logic isn't correct when nm.Name
is a pattern instead of a namespace name.
// Only act on namespaces in ArgoCD.spec.namespaceManagement that are truly managed by this ArgoCD | ||
for _, ns := range argocd.Spec.NamespaceManagement { | ||
nsName := ns.Name | ||
if !managedNamespaces[nsName] { |
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.
nsName
can be a pattern, rather than just a name, so this logic likely isn't correct.
controllers/argocd/secret.go
Outdated
allowedNamespaceMap := make(map[string]bool) | ||
for _, entry := range cr.Spec.NamespaceManagement { | ||
if entry.AllowManagedBy { | ||
allowedNamespaceMap[entry.Name] = true |
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.
entry.Name
can be a pattern, not just a name. So this logic is likely not correct.
controllers/argocd/util.go
Outdated
|
||
for _, ns := range oldList { | ||
oldNamespaces[ns.Name] = true | ||
oldNamespaceSettings[ns.Name] = ns.AllowManagedBy // Store old setting |
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.
Given that ns.name
can be a pattern, I think this logic isn't correct. (The function that calls this assumes that the []string result are actual namespace names)
assert.Equal(t, "ErrorOccurred", reconciledCondition.Reason) | ||
} | ||
|
||
func TestHandleFeatureDisable_NoNamespaceManagement(t *testing.T) { |
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.
Could use a few more tests that verify the logic in disableNamespaceManagement
controllers/argocd/util.go
Outdated
} | ||
|
||
// getNamespacesToDelete determines which namespaces were removed or had allowManagedBy changed. | ||
func getNamespacesToDelete(oldList, newList []argoproj.ManagedNamespaces) []string { |
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.
Could use some unit tests for getNamespacesToDelete
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
Signed-off-by: Rizwana777 <[email protected]>
What type of PR is this?
Add NamespaceManagement reconciliation
Add NamespaceManagement CR
Add .Spec.NamespaceManagement field in ArgoCDSpec CR
Unit tests
e2e for glob match on .Spec.NamespaceManagement field
Moved
k8sClient, err := initK8sClient()
if err != nil {
setupLog.Error(err, "Failed to initialize Kubernetes client")
os.Exit(1)
}
to main.go and also passing k8sClient in ReconcileArgoCD object to use it in code to avoid these
Failed to initialize Kubernetes client {"error": "invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable", "errorCauses": [{"error": "no configuration has been provided, try setting KUBERNETES_MASTER environment variable"}]}
errorsand also e2e tests was failing because of this, I found out that initializing k8sClient in main.go would be the better option
let me know if this method is incorrect and needs modification
JIRA - https://issues.redhat.com/browse/GITOPS-6179