1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ // Package util
1516package util
1617
1718import (
@@ -122,7 +123,7 @@ func UnmarshParametersWorkflow(paramsString string) (SpecParameters, error) {
122123 return rev , nil
123124}
124125
125- // Marshal parameters to JSON encoded string.
126+ // MarshalParametersWorkflow marshal parameters to JSON encoded string.
126127// This also checks result is not longer than a limit.
127128func MarshalParametersWorkflow (params SpecParameters ) (string , error ) {
128129 if params == nil {
@@ -148,13 +149,12 @@ func MarshalParametersWorkflow(params SpecParameters) (string, error) {
148149 return string (paramBytes ), nil
149150}
150151
151- // Get ExecutionType: ArgoWorkflow
152+ // ExecutionType ArgoWorkflow
152153func (w * Workflow ) ExecutionType () ExecutionType {
153154 return ArgoWorkflow
154155}
155156
156- // ExecutionSpec interface: Get ExecutionStatus which can be used to
157- // access status related information
157+ // ExecutionStatus access status related information
158158func (w * Workflow ) ExecutionStatus () ExecutionStatus {
159159 return w
160160}
@@ -201,12 +201,12 @@ func (w *Workflow) GenerateRetryExecution() (ExecutionSpec, []string, error) {
201201 return nil , nil , NewBadRequestError (errors .New ("workflow cannot be retried" ), "Workflow must be Failed/Error to retry" )
202202 }
203203
204- newWF := w .Workflow . DeepCopy ()
204+ newWF := w .DeepCopy ()
205205 // Delete/reset fields which indicate workflow completed
206206 delete (newWF .Labels , common .LabelKeyCompleted )
207207 // Delete/reset fields which indicate workflow is finished being persisted to the database
208208 delete (newWF .Labels , LabelKeyWorkflowPersistedFinalState )
209- newWF .ObjectMeta . Labels [common .LabelKeyPhase ] = string (workflowapi .NodeRunning )
209+ newWF .Labels [common .LabelKeyPhase ] = string (workflowapi .NodeRunning )
210210 newWF .Status .Phase = workflowapi .WorkflowRunning
211211 newWF .Status .Conditions .UpsertCondition (workflowapi.Condition {Status : metav1 .ConditionFalse , Type : workflowapi .ConditionTypeCompleted })
212212 newWF .Status .Message = ""
@@ -218,7 +218,7 @@ func (w *Workflow) GenerateRetryExecution() (ExecutionSpec, []string, error) {
218218
219219 // Iterate the previous nodes. If it was successful Pod carry it forward
220220 newWF .Status .Nodes = make (map [string ]workflowapi.NodeStatus )
221- onExitNodeName := w .ObjectMeta . Name + ".onExit"
221+ onExitNodeName := w .Name + ".onExit"
222222 var podsToDelete []string
223223 for _ , node := range w .Status .Nodes {
224224 oldNodeID := RetrievePodName (* w .Workflow , node )
@@ -280,7 +280,7 @@ func (w *Workflow) ExecutionName() string {
280280 return w .Name
281281}
282282
283- // OverrideName sets the name of a Workflow.
283+ // SetExecutionName sets the name of a Workflow.
284284func (w * Workflow ) SetExecutionName (name string ) {
285285 w .GenerateName = ""
286286 w .Name = name
@@ -378,11 +378,13 @@ func (w *Workflow) ScheduledWorkflowUUIDAsStringOrEmpty() string {
378378 return ""
379379}
380380
381- // Derives the Pod name from a given workflowapi.Workflow and workflowapi.NodeStatus
381+ // RetrievePodName derives the Pod name from a given workflowapi.Workflow and workflowapi.NodeStatus
382382// This is a workaround for an upstream breaking change with node.ID and node.Name mismatches,
383383// see https://github.com/argoproj/argo-workflows/issues/10107#issuecomment-1536113642
384+ // This behavior can be reverted by setting POD_NAMES=v1 on the workflow controller
385+ // https://argo-workflows.readthedocs.io/en/release-3.5/upgrading/#e5b131a33-feat-add-template-node-to-pod-name-fixes-1319-6712
384386func RetrievePodName (wf workflowapi.Workflow , node workflowapi.NodeStatus ) string {
385- if wf .APIVersion == "v1" {
387+ if wf .APIVersion == "v1" || wf . Annotations [ "workflows.argoproj.io/pod-name-format" ] == "v1" {
386388 return node .ID
387389 }
388390 if wf .Name == node .Name {
@@ -706,7 +708,7 @@ func (w *Workflow) SetPodMetadataLabels(key string, value string) {
706708}
707709
708710func (w * Workflow ) ReplaceUID (id string ) error {
709- newWorkflowString := strings .Replace (w .ToStringForStore (), "{{workflow.uid}}" , id , - 1 )
711+ newWorkflowString := strings .ReplaceAll (w .ToStringForStore (), "{{workflow.uid}}" , id )
710712 var workflow * workflowapi.Workflow
711713 if err := json .Unmarshal ([]byte (newWorkflowString ), & workflow ); err != nil {
712714 return NewInternalServerError (err ,
0 commit comments