Skip to content

Commit

Permalink
skip refresh if owned by app set (#354)
Browse files Browse the repository at this point in the history
Signed-off-by: Manabu McCloskey <[email protected]>
  • Loading branch information
nabuskey authored Aug 5, 2024
1 parent 71fefc7 commit a22d504
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
49 changes: 49 additions & 0 deletions pkg/controllers/localbuild/argo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,55 @@ func TestArgoCDAppAnnotation(t *testing.T) {
},
},
},
{
err: nil,
listApps: []argov1alpha1.Application{
{
TypeMeta: metav1.TypeMeta{
Kind: argov1alpha1.ApplicationSchemaGroupVersionKind.Kind,
APIVersion: argov1alpha1.ApplicationSchemaGroupVersionKind.GroupVersion().String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "owned-by-appset",
Namespace: "argocd",
Annotations: map[string]string{
"test": "value",
},
OwnerReferences: []metav1.OwnerReference{
{
Kind: "ApplicationSet",
},
},
},
},
},
annotations: nil,
},
{
err: nil,
listApps: []argov1alpha1.Application{
{
TypeMeta: metav1.TypeMeta{
Kind: argov1alpha1.ApplicationSchemaGroupVersionKind.Kind,
APIVersion: argov1alpha1.ApplicationSchemaGroupVersionKind.GroupVersion().String(),
},
ObjectMeta: metav1.ObjectMeta{
Name: "owned-by-non-appset",
Namespace: "argocd",
OwnerReferences: []metav1.OwnerReference{
{
Kind: "Something",
},
},
},
},
},
annotations: []map[string]string{
{
argoCDApplicationAnnotationKeyRefresh: argoCDApplicationAnnotationValueRefreshNormal,
},
},
},
}

for i := range cases {
Expand Down
7 changes: 7 additions & 0 deletions pkg/controllers/localbuild/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,15 @@ func (r *LocalbuildReconciler) requestArgoCDAppRefresh(ctx context.Context) erro
return fmt.Errorf("listing argocd apps for refresh: %w", err)
}

apps:
for i := range apps.Items {
app := apps.Items[i]
for _, o := range app.OwnerReferences {
// if this app is owned by an ApplicationSet, we should let the ApplicationSet refresh.
if o.Kind == argocdapp.ApplicationSetKind {
continue apps
}
}
aErr := r.applyArgoCDAnnotation(ctx, &app, argocdapp.ApplicationKind, argoCDApplicationAnnotationKeyRefresh, argoCDApplicationAnnotationValueRefreshNormal)
if aErr != nil {
return aErr
Expand Down

0 comments on commit a22d504

Please sign in to comment.