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: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes #13342 #13360

Merged
merged 10 commits into from
May 8, 2023

Conversation

jiachengxu
Copy link
Member

@jiachengxu jiachengxu commented Apr 27, 2023

Fixes: #13342
This PR fixes the issue that CMP v2 doesn't work with applications that have symlinks to adjacent file in the same git repo.
The root cause is that when calling detectConfigManagementPlugin, we should pass repo path and app path, otherwise, the check can fail since the symlinks can be pointing to files out of the app path but in the repo path.
Note on DCO:

If the DCO action in the integration test fails, one or more of your commits are not signed off. Please click on the Details link next to the DCO action for instructions on how to resolve this.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • Optional. My organization is added to USERS.md.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.

Please see Contribution FAQs if you have questions about your pull-request.

…Fixes argoproj#13342

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
@jiachengxu jiachengxu changed the title fix: CMPv2 does not allow symlinks to adjacent files in same git repo… fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes #13342 Apr 27, 2023
@jiachengxu jiachengxu marked this pull request as draft April 27, 2023 09:28
@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch coverage: 63.63% and no project coverage change.

Comparison is base (c5f49e1) 49.14% compared to head (0ce28f3) 49.15%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #13360   +/-   ##
=======================================
  Coverage   49.14%   49.15%           
=======================================
  Files         248      248           
  Lines       42891    42891           
=======================================
+ Hits        21079    21082    +3     
+ Misses      19693    19691    -2     
+ Partials     2119     2118    -1     
Impacted Files Coverage Δ
util/app/discovery/discovery.go 34.78% <53.84%> (ø)
reposerver/repository/repository.go 60.29% <75.00%> (ø)
util/cmp/stream.go 50.94% <100.00%> (ø)

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alexmt alexmt self-requested a review April 27, 2023 17:08
Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
@jiachengxu jiachengxu force-pushed the fix-13342 branch 2 times, most recently from c3cd3e7 to b3610bc Compare April 28, 2023 08:27
Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
@alexmt
Copy link
Collaborator

alexmt commented Apr 28, 2023

Can you check why TestCMPDiscoverWithFileName is failing please ? Looks like it is related to changes and not flakiness.

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
@jiachengxu jiachengxu marked this pull request as ready for review May 4, 2023 12:18
@@ -7,4 +7,4 @@ spec:
generate:
command: [sh, -c, 'echo "{\"kind\": \"ConfigMap\", \"apiVersion\": \"v1\", \"metadata\": { \"name\": \"$ARGOCD_APP_NAME\", \"namespace\": \"$ARGOCD_APP_NAMESPACE\", \"annotations\": {\"Foo\": \"$FOO\", \"KubeVersion\": \"$KUBE_VERSION\", \"KubeApiVersion\": \"$KUBE_API_VERSIONS\",\"Bar\": \"baz\"}}}"']
discover:
fileName: "subdir/s*.yaml"
fileName: "cmp-fileName/subdir/s*.yaml"
Copy link
Member Author

Choose a reason for hiding this comment

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

Can you check why TestCMPDiscoverWithFileName is failing please ? Looks like it is related to changes and not flakiness.

@alexmt It turned out that this test failed because of the test case is wrong.
As stated on the config management plugin doc, the filename should be applied to the repository root not the application source:

fileName is a glob pattern (https://pkg.go.dev/path/filepath#Glob) that is applied to the repository's root directory (not the Application source directory). If there is a match, this plugin may be used for the repository.

and in the test case, the testdata is the repo, so we need to have cmp-fileName as part of the fileName.
It was not caught because we only passed appPath but not repoPath so the appPath was considered as repoPath and cmp-fileName was not needed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This change is causing issues, so I'm going to try to revert this change without reverting your whole bugfix. #13940

@@ -0,0 +1 @@
../guestbook/guestbook-ui-deployment.yaml
Copy link
Member Author

@jiachengxu jiachengxu May 4, 2023

Choose a reason for hiding this comment

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

I have to put all test files related to symlinks to a dedicated folder testdata2 otherwise it will fail other tests with repository contains out-of-bounds symlinks errors. I think that is because in the codebase we deny all absolute symlinks (https://github.com/argoproj/argo-cd/blob/master/util/app/path/path.go#L67), however, in our tests, repo is located in /tmp/ folder and that means all files are absolute paths.

Copy link
Collaborator

@alexmt alexmt left a comment

Choose a reason for hiding this comment

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

Thank you! LGTM

@alexmt alexmt merged commit 42bdb5a into argoproj:master May 8, 2023
26 checks passed
@jiachengxu jiachengxu deleted the fix-13342 branch May 9, 2023 14:53
@alexmt
Copy link
Collaborator

alexmt commented May 19, 2023

/cherry-pick release-2.6

@gcp-cherry-pick-bot
Copy link

Cherry-pick failed with Merge error 42bdb5ab1b22d6196db43e1a2557dd686dc841df into temp-cherry-pick-651874-release-2.6

@alexmt
Copy link
Collaborator

alexmt commented May 19, 2023

/cherry-pick release-2.7

gcp-cherry-pick-bot bot pushed a commit that referenced this pull request May 19, 2023
…Fixes #13342 (#13360)

fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes #13342 (#13360)

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
alexmt pushed a commit to alexmt/argo-cd that referenced this pull request May 24, 2023
…Fixes argoproj#13342 (argoproj#13360)

fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes argoproj#13342 (argoproj#13360)

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
crenshaw-dev pushed a commit that referenced this pull request May 24, 2023
…Fixes #13342 (#13360) (#13724)

fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes #13342 (#13360)

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
Co-authored-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
crenshaw-dev pushed a commit that referenced this pull request May 27, 2023
…Fixes #13342 (#13360) (#13669)

fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes #13342 (#13360)

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
Co-authored-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
schakrad pushed a commit to schakrad/argo-cd that referenced this pull request Jul 24, 2023
…Fixes argoproj#13342 (argoproj#13360) (argoproj#13669)

fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes argoproj#13342 (argoproj#13360)

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
Co-authored-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
Signed-off-by: schakrad <58915923+schakrad@users.noreply.github.com>
yyzxw pushed a commit to yyzxw/argo-cd that referenced this pull request Aug 9, 2023
…Fixes argoproj#13342 (argoproj#13360)

fix: CMPv2 does not allow symlinks to adjacent files in same git repo. Fixes argoproj#13342 (argoproj#13360)

Signed-off-by: Jiacheng Xu <xjcmaxwellcjx@gmail.com>
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.

Argo CD CMPv2 does not allow symlinks to adjacent files in same git repo
3 participants