Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use env when pod version annotation is missing. Fixes #10237 #10457

Merged
merged 3 commits into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions workflow/util/pod_name.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,10 @@ func ensurePodNamePrefixLength(prefix string) string {
// given workflow
func GetWorkflowPodNameVersion(wf *v1alpha1.Workflow) PodNameVersion {
annotations := wf.GetAnnotations()
version := annotations[common.AnnotationKeyPodNameVersion]

version, ok := annotations[common.AnnotationKeyPodNameVersion]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the default in the switch case below still valid? Otherwise this could potentially be rewritten so that GetPodNameVersion() is the default case?

Copy link
Member Author

@isubasinghe isubasinghe Feb 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was tempted to implement this fix that way but that default switch case will be hit if the annotation is invalid. That is a different behaviour to the GetPodNameVersion call.

But yeah I was on the fence on this about what the "right behaviour" is. This is why I went with the current approach, at least it will always be consistent when the user makes a wrong annotation (default to v2).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, sounds good!

if !ok {
return GetPodNameVersion()
}
switch version {
case PodNameV1.String():
return PodNameV1
Expand Down