Skip to content

Commit

Permalink
fix(ui): Use proper podname for containersets. Fixes argoproj#13038 (a…
Browse files Browse the repository at this point in the history
…rgoproj#13039)

Signed-off-by: instauro <instauro@proton.me>
Signed-off-by: Anton Gilgur <agilgur5@gmail.com>
Co-authored-by: instauro <instauro@proton.me>
Co-authored-by: Anton Gilgur <agilgur5@gmail.com>
  • Loading branch information
3 people authored Jun 23, 2024
1 parent 8e9dbb1 commit 10e3a6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions ui/src/app/shared/pod-name.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ describe('pod names', () => {
expect(getPodName(wf, node)).toEqual(v2podName);
delete wf.metadata.annotations;
expect(getPodName(wf, node)).toEqual(v2podName);
expect(getPodName(wf, {...node, name: node.name + '.mycontainername', type: 'Container'})).toEqual(v2podName); // containerSet node check

wf.metadata.name = longWfName;
node.templateName = longTemplateName;
Expand Down
9 changes: 6 additions & 3 deletions ui/src/app/shared/pod-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,18 @@ const maxPrefixLength = maxK8sResourceNameLength - k8sNamingHashLength;
// getPodName returns a deterministic pod name
// In case templateName is not defined or that version is explicitly set to POD_NAME_V1, it will return the nodeID (v1)
// In other cases it will return a combination of workflow name, template name, and a hash (v2)
// note: this is intended to be equivalent to the server-side Go code in workflow/util/pod_name.go
// note: this is intended to be equivalent to the server-side Go code in workflow/util/pod_name.go#GeneratePodName
export function getPodName(workflow: Workflow, node: NodeStatus): string {
const version = workflow.metadata?.annotations?.[ANNOTATION_KEY_POD_NAME_VERSION];
if (version === POD_NAME_V1) {
return node.id;
}

const workflowName = workflow.metadata.name;
if (workflowName === node.name) {
// convert containerSet node name to its corresponding pod node name by removing the ".<containerName>" postfix
// this part is from workflow/controller/container_set_template.go#executeContainerSet; the inverse never happens in the back-end, so is unique to the front-end
const podNodeName = node.type == 'Container' ? node.name.replace(/\.[^/.]+$/, '') : node.name;
if (workflowName === podNodeName) {
return workflowName;
}

Expand All @@ -30,7 +33,7 @@ export function getPodName(workflow: Workflow, node: NodeStatus): string {
}
prefix = ensurePodNamePrefixLength(prefix);

const hash = createFNVHash(node.name);
const hash = createFNVHash(podNodeName);
return `${prefix}-${hash}`;
}

Expand Down

0 comments on commit 10e3a6d

Please sign in to comment.