-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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: Allow notifications controller to notify on all namespaces (cont.) #15247
fix: Allow notifications controller to notify on all namespaces (cont.) #15247
Conversation
This adds functionality to the notifications controller to be notified of and send notifications for applications in any namespace. The namespaces to watch are controlled by the same --application-namespaces and ARGOCD_APPLICATION_NAMESPACES variables as in the application controller. Signed-off-by: Nikolas Skoufis <nskoufis@seek.com.au>
Signed-off-by: Nikolas Skoufis <nskoufis@seek.com.au>
…rgo-cd into notifications-in-all-namespaces
Signed-off-by: Nikolas Skoufis <nskoufis@seek.com.au>
Signed-off-by: Nik Skoufis <n.skoufis@gmail.com>
Signed-off-by: Nikolas Skoufis <nskoufis@seek.com.au>
Signed-off-by: Stewart Thomson <sthomson@wynshop.com>
Signed-off-by: Stewart Thomson <sthomson@wynshop.com>
…ault) Signed-off-by: Stewart Thomson <sthomson@wynshop.com>
…l-namespaces # Conflicts: # manifests/install.yaml # manifests/namespace-install.yaml
13cfca6
to
46b0404
Compare
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #15247 +/- ##
==========================================
- Coverage 49.92% 49.91% -0.02%
==========================================
Files 263 266 +3
Lines 45223 46089 +866
==========================================
+ Hits 22578 23005 +427
- Misses 20427 20824 +397
- Partials 2218 2260 +42
☔ View full report in Codecov by Sentry. |
Signed-off-by: Stewart Thomson <sthomson@wynshop.com>
21a3c10
to
4996eea
Compare
Thank you @sthomson-wyn for the great contribution! I tested on my local with one finding. Here is my test case: Two apps:
Notification controller is started with Expected Result: receive notification for Recommended Fix: ` |
Signed-off-by: Stewart Thomson <sthomson@wynshop.com>
Thanks @mayzhang2000 , I've added the suggested change via baa28c8 |
Thank you @sthomson-wyn! |
@@ -38,8 +39,8 @@ var ( | |||
appProjects = schema.GroupVersionResource{Group: application.Group, Version: "v1alpha1", Resource: application.AppProjectPlural} | |||
) | |||
|
|||
func newAppProjClient(client dynamic.Interface, namespace string) dynamic.ResourceInterface { | |||
resClient := client.Resource(appProjects).Namespace(namespace) |
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.
Is this necessary? AppProjects are still restricted to only living in the controller namespace.
- "argoproj.io" | ||
resources: | ||
- "applications" | ||
- "appprojects" |
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.
Since AppProjects only exist in the controller's namespace, I don't think this is necessary at the cluster level.
app.kubernetes.io/name: argocd-notifications-controller-cluster-apps | ||
app.kubernetes.io/part-of: argocd | ||
app.kubernetes.io/component: notifications-controller | ||
name: argocd-notifications-controller-cluster-apps |
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.
Should the apps-in-any-namespace docs be updated to mention the two new resources?
if namespace != app.GetNamespace() && !glob.MatchStringInList(applicationNamespaces, app.GetNamespace(), false) { | ||
return true, "app is not in one of the application-namespaces, nor the notification controller namespace" | ||
} |
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.
Can we get test coverage on this? If a full test of the notificationController
would be prohibitively complex, we could pull out this function and just unit-test that.
return resClient.List(context.Background(), options) | ||
appList, err := resClient.List(context.TODO(), options) | ||
if err != nil { | ||
return nil, err |
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.
return nil, err | |
return nil, fmt.Errorf("failed to list applications: %w", err) |
@@ -115,6 +115,7 @@ func TestInit(t *testing.T) { | |||
dynamicClient, | |||
nil, | |||
"default", | |||
[]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.
Would you mind adding some unit tests to cover the apps-in-any-namespace behavior? I think at the minimum we should make sure the notifications controller refuses to manage apps outside the specified namespaces.
Thank you @sthomson-wyn and @crenshaw-dev ! I created below PR as a continuation of this PR. |
…ml's resources Signed-off-by: May Zhang <may_zhang@intuit.com>
Superseded by #15702 |
This is a continuation of #13352 which addresses the following:
#13352 (comment)
#13352 (comment)
#13352 (comment)
This adds functionality to the notifications controller to be notified of and send notifications for applications in any namespace. The namespaces to watch are controlled by the same --application-namespaces and ARGOCD_APPLICATION_NAMESPACES variables as in the application controller.
Closes #12912
Closes #11252
Checklist: