Skip to content

Commit

Permalink
Migrate the instance storage from the Opaque type
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Prodan <[email protected]>
  • Loading branch information
stefanprodan committed Oct 19, 2023
1 parent db8e2cc commit df6d2d4
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion internal/runtime/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,21 @@ func (s *StorageManager) Apply(ctx context.Context, instance *apiv1.Instance, cr
client.ForceOwnership,
client.FieldOwner(ownerRef.Field),
}
return s.resManager.Client().Patch(ctx, secret, client.Apply, opts...)

// Migrate storage from the Opaque type by recreating the Secret.
// TODO: remove the immutability error handling after 6 months.
if err := s.resManager.Client().Patch(ctx, secret, client.Apply, opts...); err != nil {
if ssa.IsImmutableError(err) {
if delErr := s.Delete(ctx, instance.Name, instance.Namespace); delErr != nil {
return delErr
}
return s.resManager.Client().Patch(ctx, secret, client.Apply, opts...)
} else {
return err
}
}

return nil
}

// Get retrieves the instance from the storage.
Expand Down

0 comments on commit df6d2d4

Please sign in to comment.