Skip to content

Commit 7660847

Browse files
committed
fix: GitOps Operator hot loop issue
Signed-off-by: Atif Ali <[email protected]>
1 parent 0f46891 commit 7660847

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

controllers/consoleplugin.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,12 @@ func getPluginPodSpec() corev1.PodSpec {
5555
podSpec := corev1.PodSpec{
5656
Containers: []corev1.Container{
5757
{
58-
Env: util.ProxyEnvVars(),
59-
Name: gitopsPluginName,
60-
Image: consolePluginImage,
61-
ImagePullPolicy: corev1.PullAlways,
58+
Env: util.ProxyEnvVars(),
59+
Name: gitopsPluginName,
60+
Image: consolePluginImage,
61+
ImagePullPolicy: corev1.PullAlways,
62+
TerminationMessagePath: corev1.TerminationMessagePathDefault,
63+
TerminationMessagePolicy: corev1.TerminationMessageReadFile,
6264
Ports: []corev1.ContainerPort{
6365
{
6466
Name: "http",

controllers/gitopsservice_controller.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,24 @@ func (r *ReconcileGitopsService) SetupWithManager(mgr ctrl.Manager) error {
114114
})),
115115
).Watches(&argoapp.ArgoCD{},
116116
&handler.EnqueueRequestForObject{},
117-
builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool {
118-
return obj.GetName() == "openshift-gitops" && obj.GetNamespace() == "openshift-gitops"
119-
}))).
117+
builder.WithPredicates(predicate.Funcs{
118+
CreateFunc: func(e event.CreateEvent) bool {
119+
// Only watch openshift-gitops ArgoCD
120+
return e.Object.GetName() == "openshift-gitops" && e.Object.GetNamespace() == "openshift-gitops"
121+
},
122+
UpdateFunc: func(e event.UpdateEvent) bool {
123+
// Only watch openshift-gitops ArgoCD
124+
if e.ObjectNew.GetName() != "openshift-gitops" || e.ObjectNew.GetNamespace() != "openshift-gitops" {
125+
return false
126+
}
127+
// Ignore updates to CR status in which case metadata.Generation does not change
128+
return e.ObjectOld.GetGeneration() != e.ObjectNew.GetGeneration()
129+
},
130+
DeleteFunc: func(e event.DeleteEvent) bool {
131+
// Only watch openshift-gitops ArgoCD
132+
return e.Object.GetName() == "openshift-gitops" && e.Object.GetNamespace() == "openshift-gitops"
133+
},
134+
})).
120135
Complete(r)
121136
}
122137

0 commit comments

Comments
 (0)