Skip to content

Commit

Permalink
Merge pull request #221 from stefanprodan/migrate-storage
Browse files Browse the repository at this point in the history
Migrate the instance storage from the Opaque type
  • Loading branch information
stefanprodan authored Oct 19, 2023
2 parents db8e2cc + df6d2d4 commit debfedc
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 debfedc

Please sign in to comment.