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 issue in extraCommandArgs field #1541

Merged
merged 5 commits into from
Jan 13, 2025
Merged

Conversation

Rizwana777
Copy link
Contributor

@Rizwana777 Rizwana777 commented Sep 9, 2024

@Rizwana777 Rizwana777 force-pushed the issue-5200 branch 6 times, most recently from c2b7eb0 to e8ed105 Compare September 9, 2024 14:20
Copy link
Collaborator

@jopit jopit left a comment

Choose a reason for hiding this comment

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

I don't see any logic to address the 3rd problem reported in the Jira issue

3. Adding argument and value as a single element causes the pod to crash

Other than that, it looks good to me.

@Rizwana777
Copy link
Contributor Author

Rizwana777 commented Sep 23, 2024

I don't see any logic to address the 3rd problem reported in the Jira issue

3. Adding argument and value as a single element causes the pod to crash

Other than that, it looks good to me.

Thanks John, for 3rd point -

Pod crashes as mentioned in description because ,

'{.spec.server.extraCommandArgs}' ["foo bar"] , here extraCommandArgs is of type []string and we need to pass the flag value i.e, foo as --foo and bar as value like this ["--foo" "bar"] , if we pass values as mentioned pod will not crash, 
and pod crashes as mentioned in description is :
error : Error: unknown flag: --foo
Usage:
argocd-server [flags]
argocd-server [command], as --foo is a flag and we can use available flags

@Rizwana777
Copy link
Contributor Author

FAIL: kuttl/harness/1-036_validate_role_rolebinding_for_source_namespace this e2e test is failing in other PRs as well

@saumeya
Copy link
Collaborator

saumeya commented Sep 24, 2024

Re-ran the tests

@Rizwana777
Copy link
Contributor Author

FAIL: kuttl/harness/1-036_validate_role_rolebinding_for_source_namespace this e2e test is failing in other PRs as well

All the tests are passing now

Copy link
Collaborator

@svghadi svghadi left a comment

Choose a reason for hiding this comment

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

@Rizwana777 - Can we allow users to override params? There may be cases where tuning of default params could be useful.

@Rizwana777 Rizwana777 force-pushed the issue-5200 branch 3 times, most recently from 9624248 to 0079ddb Compare November 11, 2024 05:09
@Rizwana777
Copy link
Contributor Author

@svghadi I have updated the code which allow the users to override existing params, PTAL

// appendUniqueArgs appends extraArgs to cmd while ignoring any duplicate flags.
func appendUniqueArgs(cmd []string, extraArgs []string) []string {
// Parse cmd into a map to track flags and their indices
existingArgs := make(map[string]int) // Map to track index of each flag in cmd
Copy link
Collaborator

Choose a reason for hiding this comment

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

Based on our Slack discussion, could you try using a map[string]string to simplify the logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@svghadi I tried updating the logic to use map[string]string but found issues as mentioned-

  • map[string]string creates a map of flags to values, meaning it's expecting each flag to be associated with a value (or an empty string if no value is provided) this approach has the risk of treating arguments like --staticassets as executable commands if there is an issue in the flag parsing. If the function expects this argument to be passed as part of a command and it's incorrectly handled (i.e., not paired with a valid value), this could lead to the error like - create failed: unable to start container process: exec: "--staticassets": executable file not found in $PATH"

  • On the other hand, map[string]int keeps track of the exact positions of flags in the original cmd array, so any updates or additions to cmd are carefully done by index. This prevents the accidental misinterpretation of arguments and ensures the correct structure for the final command.

I may be mistaken, but PTAL and let me know your thoughts. I'm open to any suggestions

Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

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

In addition, it appears that ExtraRepoCommandArgs, which controls extra repo server args, is missing from this PR.

controllers/argocd/deployment.go Outdated Show resolved Hide resolved
@jgwest
Copy link
Member

jgwest commented Jan 13, 2025

Rebased to latest from master to fix the sh oc test failure (I think you might have just done the same thing @Rizwana777)

Copy link
Member

@jgwest jgwest left a comment

Choose a reason for hiding this comment

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

LGTM, thanks @Rizwana777!

@jgwest jgwest merged commit 8caffc7 into argoproj-labs:master Jan 13, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants