@@ -65,10 +65,12 @@ func (r *GitRepositoryWatcher) Reconcile(req ctrl.Request) (ctrl.Result, error)
6565
6666 // trigger apply for each kustomization using this Git repository
6767 for _ , kustomization := range list .Items {
68- if err := r .updateKustomization (kustomization ); err != nil {
69- log .Error (err , "unable to annotate kustomization" , "kustomization" , kustomization .GetName ())
68+ namespacedName := types.NamespacedName {Namespace : kustomization .Namespace , Name : kustomization .Name }
69+ if err := r .requestKustomizationSync (kustomization ); err != nil {
70+ log .Error (err , "unable to annotate Kustomization" , "kustomization" , namespacedName )
71+ continue
7072 }
71- log .Info ("Run kustomization " , "kustomization" , kustomization . GetName () )
73+ log .Info ("requested immediate sync " , "kustomization" , namespacedName )
7274 }
7375
7476 return ctrl.Result {}, nil
@@ -95,7 +97,7 @@ func (r *GitRepositoryWatcher) SetupWithManager(mgr ctrl.Manager) error {
9597 Complete (r )
9698}
9799
98- func (r * GitRepositoryWatcher ) updateKustomization (kustomization kustomizev1.Kustomization ) error {
100+ func (r * GitRepositoryWatcher ) requestKustomizationSync (kustomization kustomizev1.Kustomization ) error {
99101 firstTry := true
100102 return retry .RetryOnConflict (retry .DefaultBackoff , func () (err error ) {
101103 if ! firstTry {
@@ -109,6 +111,7 @@ func (r *GitRepositoryWatcher) updateKustomization(kustomization kustomizev1.Kus
109111
110112 firstTry = false
111113 kustomization .Annotations [kustomizev1 .SyncAtAnnotation ] = metav1 .Now ().String ()
114+ // Prevent strings can't be nil err as API package does not mark APIGroup with omitempty.
112115 if kustomization .Spec .SourceRef .APIGroup == nil {
113116 emptyAPIGroup := ""
114117 kustomization .Spec .SourceRef .APIGroup = & emptyAPIGroup
0 commit comments