Skip to content

Commit a22d504

Browse files
authored
skip refresh if owned by app set (#354)
Signed-off-by: Manabu McCloskey <[email protected]>
1 parent 71fefc7 commit a22d504

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

pkg/controllers/localbuild/argo_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,55 @@ func TestArgoCDAppAnnotation(t *testing.T) {
133133
},
134134
},
135135
},
136+
{
137+
err: nil,
138+
listApps: []argov1alpha1.Application{
139+
{
140+
TypeMeta: metav1.TypeMeta{
141+
Kind: argov1alpha1.ApplicationSchemaGroupVersionKind.Kind,
142+
APIVersion: argov1alpha1.ApplicationSchemaGroupVersionKind.GroupVersion().String(),
143+
},
144+
ObjectMeta: metav1.ObjectMeta{
145+
Name: "owned-by-appset",
146+
Namespace: "argocd",
147+
Annotations: map[string]string{
148+
"test": "value",
149+
},
150+
OwnerReferences: []metav1.OwnerReference{
151+
{
152+
Kind: "ApplicationSet",
153+
},
154+
},
155+
},
156+
},
157+
},
158+
annotations: nil,
159+
},
160+
{
161+
err: nil,
162+
listApps: []argov1alpha1.Application{
163+
{
164+
TypeMeta: metav1.TypeMeta{
165+
Kind: argov1alpha1.ApplicationSchemaGroupVersionKind.Kind,
166+
APIVersion: argov1alpha1.ApplicationSchemaGroupVersionKind.GroupVersion().String(),
167+
},
168+
ObjectMeta: metav1.ObjectMeta{
169+
Name: "owned-by-non-appset",
170+
Namespace: "argocd",
171+
OwnerReferences: []metav1.OwnerReference{
172+
{
173+
Kind: "Something",
174+
},
175+
},
176+
},
177+
},
178+
},
179+
annotations: []map[string]string{
180+
{
181+
argoCDApplicationAnnotationKeyRefresh: argoCDApplicationAnnotationValueRefreshNormal,
182+
},
183+
},
184+
},
136185
}
137186

138187
for i := range cases {

pkg/controllers/localbuild/controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,15 @@ func (r *LocalbuildReconciler) requestArgoCDAppRefresh(ctx context.Context) erro
547547
return fmt.Errorf("listing argocd apps for refresh: %w", err)
548548
}
549549

550+
apps:
550551
for i := range apps.Items {
551552
app := apps.Items[i]
553+
for _, o := range app.OwnerReferences {
554+
// if this app is owned by an ApplicationSet, we should let the ApplicationSet refresh.
555+
if o.Kind == argocdapp.ApplicationSetKind {
556+
continue apps
557+
}
558+
}
552559
aErr := r.applyArgoCDAnnotation(ctx, &app, argocdapp.ApplicationKind, argoCDApplicationAnnotationKeyRefresh, argoCDApplicationAnnotationValueRefreshNormal)
553560
if aErr != nil {
554561
return aErr

0 commit comments

Comments
 (0)