Skip to content

Commit 38bb8d3

Browse files
instauroagilgur5
andcommitted
fix(ui): Use proper podname for containersets. Fixes argoproj#13038 (argoproj#13039)
Signed-off-by: instauro <[email protected]> Signed-off-by: Anton Gilgur <[email protected]> Co-authored-by: instauro <[email protected]> Co-authored-by: Anton Gilgur <[email protected]> (cherry picked from commit 10e3a6d)
1 parent b1c51df commit 38bb8d3

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

ui/src/app/shared/pod-name.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ describe('pod names', () => {
5252
expect(getPodName(wf, node)).toEqual(v2podName);
5353
delete wf.metadata.annotations;
5454
expect(getPodName(wf, node)).toEqual(v2podName);
55+
expect(getPodName(wf, {...node, name: node.name + '.mycontainername', type: 'Container'})).toEqual(v2podName); // containerSet node check
5556

5657
wf.metadata.name = longWfName;
5758
node.templateName = longTemplateName;

ui/src/app/shared/pod-name.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,18 @@ const maxPrefixLength = maxK8sResourceNameLength - k8sNamingHashLength;
1111
// getPodName returns a deterministic pod name
1212
// In case templateName is not defined or that version is explicitly set to POD_NAME_V1, it will return the nodeID (v1)
1313
// In other cases it will return a combination of workflow name, template name, and a hash (v2)
14-
// note: this is intended to be equivalent to the server-side Go code in workflow/util/pod_name.go
14+
// note: this is intended to be equivalent to the server-side Go code in workflow/util/pod_name.go#GeneratePodName
1515
export function getPodName(workflow: Workflow, node: NodeStatus): string {
1616
const version = workflow.metadata?.annotations?.[ANNOTATION_KEY_POD_NAME_VERSION];
1717
if (version === POD_NAME_V1) {
1818
return node.id;
1919
}
2020

2121
const workflowName = workflow.metadata.name;
22-
if (workflowName === node.name) {
22+
// convert containerSet node name to its corresponding pod node name by removing the ".<containerName>" postfix
23+
// 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
24+
const podNodeName = node.type == 'Container' ? node.name.replace(/\.[^/.]+$/, '') : node.name;
25+
if (workflowName === podNodeName) {
2326
return workflowName;
2427
}
2528

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

33-
const hash = createFNVHash(node.name);
36+
const hash = createFNVHash(podNodeName);
3437
return `${prefix}-${hash}`;
3538
}
3639

0 commit comments

Comments
 (0)