// Concurrent `helm upgrade`s will either fail here with `errPending` or when creating the release with "already exists". This should act as a pessimistic lock.
upgradeClientSideFieldManager:=isReleaseApplyMethodClientSideApply(originalRelease.ApplyMethod)&&serverSideApply// Update client-side field manager if transitioning from client-side to server-side apply
f.BoolVar(&client.ForceConflicts,"force-conflicts",false,"if set server-side apply will force changes against conflicts")
f.BoolVar(&client.ServerSideApply,"server-side",true,"object updates run in the server instead of the client")
f.BoolVar(&client.DisableHooks,"no-hooks",false,"prevent hooks from running during install")
f.BoolVar(&client.Replace,"replace",false,"reuse the given name, only if that name is a deleted release which remains in the history. This is unsafe in production")
f.DurationVar(&client.Timeout,"timeout",300*time.Second,"time to wait for any individual Kubernetes operation (like Jobs for hooks)")
f.BoolVar(&client.ForceConflicts,"force-conflicts",false,"if set server-side apply will force changes against conflicts")
f.StringVar(&client.ServerSideApply,"server-side","auto","must be \"true\", \"false\" or \"auto\". Object updates run in the server instead of the client (\"auto\" defaults the value from the previous chart release's method)")
f.BoolVar(&client.DisableHooks,"no-hooks",false,"prevent hooks from running during rollback")
f.DurationVar(&client.Timeout,"timeout",300*time.Second,"time to wait for any individual Kubernetes operation (like Jobs for hooks)")
f.BoolVar(&client.WaitForJobs,"wait-for-jobs",false,"if set and --wait enabled, will wait until all Jobs have been completed before marking the release as successful. It will wait for as long as --timeout")
f.BoolVar(&client.CleanupOnFail,"cleanup-on-fail",false,"allow deletion of new resources created in this rollback when rollback fails")
f.IntVar(&client.MaxHistory,"history-max",settings.MaxHistory,"limit the maximum number of revisions saved per release. Use 0 for no limit")
f.BoolVar(&client.ForceConflicts,"force-conflicts",false,"if set server-side apply will force changes against conflicts")
f.StringVar(&client.ServerSideApply,"server-side","auto","must be \"true\", \"false\" or \"auto\". Object updates run in the server instead of the client (\"auto\" defaults the value from the previous chart release's method)")
f.BoolVar(&client.DisableOpenAPIValidation,"disable-openapi-validation",false,"if set, the upgrade process will not validate rendered templates against the Kubernetes OpenAPI Schema")
f.BoolVar(&client.SkipCRDs,"skip-crds",false,"if set, no CRDs will be installed when an upgrade is performed with install flag enabled. By default, CRDs are installed if not already present, when an upgrade is performed with install flag enabled")
// ClientUpdateOptionUpgradeClientSideFieldManager specifies that resources client-side field manager should be upgraded to server-side apply
// (before applying the object server-side)
// This is required when upgrading a chart from client-side to server-side apply, otherwise the client-side field management remains. Conflicting with server-side applied updates.
//
// Note:
// if this option is specified, but the object is not managed by client-side field manager, it will be a no-op. However, the cost of fetching the objects will be incurred.
returnfmt.Errorf("failed to upgrade managed fields for object %s/%s %s: %w",info.Namespace,info.Name,info.Mapping.GroupVersionKind.String(),err)
}
iflen(patchData)==0{
returnnil
}
obj,err:=helper.Patch(
info.Namespace,
info.Name,
types.JSONPatchType,
patchData,
nil)
iferr==nil{
patched=true
returninfo.Refresh(obj,true)
}
if!apierrors.IsConflict(err){
returnfmt.Errorf("failed to patch object to upgrade CSA field manager %s/%s %s: %w",info.Namespace,info.Name,info.Mapping.GroupVersionKind.String(),err)