-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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(controller): Preserve the original slice when removing string #4835
Conversation
Signed-off-by: songjuchao <juchao.song@inceptio.ai>
The previous
The controller logs:
You will find |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see how the original slice could be affected by this function. I played around a bit and found a case where it is actually malformed: https://play.golang.org/p/TGuB3gcWxDc
However, as this pattern is commonly used (and as it is used in this case) is to immediatley reassign the parameter slice with the returning value. This doesn't cause an issue: https://play.golang.org/p/zxJDU8MSt5N
This is the only way this function is used in our codebase:
Is there something I'm missing here? Otherwise it seems like this change would have no effect
https://github.com/argoproj/argo/blob/945106e3dc395055bac2034d633ebce86d1be749/workflow/sync/sync_manager.go#L179-L184 |
https://github.com/argoproj/argo/blob/adfa988f9df64b629e08687737a80f2f6e0a6289/workflow/sync/sync_manager.go#L179 |
@@ -3,7 +3,9 @@ package slice | |||
func RemoveString(slice []string, element string) []string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this method should either modify the argument (and not return anything) or not modify the argument - it should not do both
I see, thanks @juchaosong |
Signed-off-by: songjuchao <juchao.song@inceptio.ai>
Fix for this is out now in https://github.com/argoproj/argo/releases/tag/v2.12.4 |
Checklist: