@@ -55,6 +55,15 @@ const (
5555 errUpdateCriticalAnnotations = "cannot update critical annotations"
5656)
5757
58+ var (
59+ criticalAnnotations = []string {
60+ meta .AnnotationKeyExternalCreateFailed ,
61+ meta .AnnotationKeyExternalCreatePending ,
62+ meta .AnnotationKeyExternalCreateSucceeded ,
63+ meta .AnnotationKeyExternalName ,
64+ }
65+ )
66+
5867// NameAsExternalName writes the name of the managed resource to
5968// the external name annotation field in order to be used as name of
6069// the external resource in provider.
@@ -280,7 +289,18 @@ func NewRetryingCriticalAnnotationUpdater(c client.Client) *RetryingCriticalAnno
280289// Only annotations will be updated as part of this operation, other fields of the
281290// supplied Object will not be modified.
282291func (u * RetryingCriticalAnnotationUpdater ) UpdateCriticalAnnotations (ctx context.Context , o client.Object ) error {
283- a := o .GetAnnotations ()
292+ a := make (map [string ]string )
293+ for _ , k := range criticalAnnotations {
294+ if v , ok := o .GetAnnotations ()[k ]; ok {
295+ a [k ] = v
296+ }
297+ }
298+
299+ if len (a ) == 0 {
300+ // No critical annotations to update.
301+ return nil
302+ }
303+
284304 err := retry .OnError (retry .DefaultRetry , func (err error ) bool {
285305 return ! errors .Is (err , context .Canceled )
286306 }, func () error {
0 commit comments