@@ -61,6 +61,14 @@ func SetCommonDefaults(in CoherenceResource) {
6161 logger := webhookLogger .WithValues ("namespace" , in .GetNamespace (), "name" , in .GetName ())
6262 status := in .GetStatus ()
6363 spec := in .GetSpec ()
64+ dt := in .GetDeletionTimestamp ()
65+
66+ if dt != nil {
67+ // the deletion timestamp is set so do nothing
68+ logger .Info ("Skipping updating defaults for deleted resource" , "deletionTimestamp" , * dt )
69+ return
70+ }
71+
6472 if status .Phase == "" {
6573 logger .Info ("Setting defaults for new resource" )
6674
@@ -105,8 +113,8 @@ func SetCommonDefaults(in CoherenceResource) {
105113 // Set the features supported by this version
106114 in .AddAnnotation (AnnotationFeatureSuspend , "true" )
107115 } else {
108- logger .Info ("Updating defaults for existing resource" )
109116 // this is an update
117+ logger .Info ("Updating defaults for existing resource" )
110118 }
111119
112120 // apply the Operator version annotation
@@ -134,8 +142,16 @@ var commonWebHook = CommonWebHook{}
134142// The optional warnings will be added to the response as warning messages.
135143// Return an error if the object is invalid.
136144func (in * Coherence ) ValidateCreate () (admission.Warnings , error ) {
145+ logger := webhookLogger .WithValues ("namespace" , in .GetNamespace (), "name" , in .GetName ())
137146 var warnings admission.Warnings
138147
148+ dt := in .GetDeletionTimestamp ()
149+ if dt != nil {
150+ // the deletion timestamp is set so do nothing
151+ logger .Info ("Skipping validation for deleted resource" , "deletionTimestamp" , * dt )
152+ return warnings , nil
153+ }
154+
139155 webhookLogger .Info ("validate create" , "name" , in .Name )
140156 if err := commonWebHook .validateReplicas (in ); err != nil {
141157 return warnings , err
@@ -154,8 +170,16 @@ func (in *Coherence) ValidateCreate() (admission.Warnings, error) {
154170// Return an error if the object is invalid.
155171func (in * Coherence ) ValidateUpdate (previous runtime.Object ) (admission.Warnings , error ) {
156172 webhookLogger .Info ("validate update" , "name" , in .Name )
173+ logger := webhookLogger .WithValues ("namespace" , in .GetNamespace (), "name" , in .GetName ())
157174 var warnings admission.Warnings
158175
176+ dt := in .GetDeletionTimestamp ()
177+ if dt != nil {
178+ // the deletion timestamp is set so do nothing
179+ logger .Info ("Skipping validation for deleted resource" , "deletionTimestamp" , * dt )
180+ return warnings , nil
181+ }
182+
159183 if err := commonWebHook .validateReplicas (in ); err != nil {
160184 return warnings , err
161185 }
0 commit comments