@@ -23,6 +23,7 @@ import (
2323 "fmt"
2424 "sort"
2525 "strings"
26+ "time"
2627
2728 "github.com/adyanth/cloudflare-operator/internal/clients/cf"
2829
@@ -156,7 +157,11 @@ func (r *TunnelBindingReconciler) Reconcile(ctx context.Context, req ctrl.Reques
156157 // TunnelBinding object not found, could have been deleted after reconcile request.
157158 // Owned objects are automatically garbage collected. For additional cleanup logic use finalizers.
158159 // Return and don't requeue
159- r .log .Info ("TunnelBinding deleted, nothing to do" )
160+ r .log .Info ("TunnelBinding deleted, updating config" )
161+ if err = r .configureCloudflareDaemon (); err != nil {
162+ r .log .Error (err , "unable to update config" )
163+ return ctrl.Result {}, err
164+ }
160165 return ctrl.Result {}, nil
161166 }
162167 r .log .Error (err , "unable to fetch TunnelBinding" )
@@ -170,7 +175,8 @@ func (r *TunnelBindingReconciler) Reconcile(ctx context.Context, req ctrl.Reques
170175
171176 // Check if TunnelBinding is marked for deletion
172177 if r .binding .GetDeletionTimestamp () != nil {
173- return ctrl.Result {}, r .deletionLogic ()
178+ // Requeue to update configmap above
179+ return ctrl.Result {RequeueAfter : time .Second }, r .deletionLogic ()
174180 }
175181
176182 if err := r .setStatus (); err != nil {
@@ -535,10 +541,10 @@ func (r *TunnelBindingReconciler) setConfigMapConfiguration(config *cf.Configura
535541 // Restart pods
536542 r .Recorder .Event (r .binding , corev1 .EventTypeNormal , "ApplyingConfig" , "Applying ConfigMap to Deployment" )
537543 r .Recorder .Event (cfDeployment , corev1 .EventTypeNormal , "ApplyingConfig" , "Applying ConfigMap to Deployment" )
538- if cfDeployment .Annotations == nil {
539- cfDeployment .Annotations = map [string ]string {}
544+ if cfDeployment .Spec . Template . Annotations == nil {
545+ cfDeployment .Spec . Template . Annotations = map [string ]string {}
540546 }
541- cfDeployment .Annotations [tunnelConfigChecksum ] = hex .EncodeToString (hash [:])
547+ cfDeployment .Spec . Template . Annotations [tunnelConfigChecksum ] = hex .EncodeToString (hash [:])
542548 if err := r .Update (r .ctx , cfDeployment ); err != nil {
543549 r .log .Error (err , "Failed to update Deployment for restart" )
544550 r .Recorder .Event (r .binding , corev1 .EventTypeWarning , "FailedApplyingConfig" , "Failed to apply ConfigMap to Deployment" )
0 commit comments