Skip to content

Commit

Permalink
Added context with timeout for get shoot operation
Browse files Browse the repository at this point in the history
  • Loading branch information
akgalwas committed Nov 22, 2024
1 parent c7f22d8 commit e5840d3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion hack/runtime-migrator/cmd/migration.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,11 @@ func (m Migration) fetchShoot(ctx context.Context, shootList *v1beta1.ShootList,
return nil, errors.New("shoot was deleted or the runtime ID is incorrect")
}

getCtx, cancel := context.WithTimeout(ctx, timeoutK8sOperation)
defer cancel()

// We are fetching the shoot from the gardener to make sure the runtime didn't get deleted during the migration process
refreshedShoot, err := m.shootClient.Get(ctx, shoot.Name, v1.GetOptions{})
refreshedShoot, err := m.shootClient.Get(getCtx, shoot.Name, v1.GetOptions{})
if err != nil {
if k8serrors.IsNotFound(err) {
return nil, errors.New("shoot was deleted")
Expand Down

0 comments on commit e5840d3

Please sign in to comment.