-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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(appset): update gitlab SCM provider to search on parent folder (#16253) #21491
fix(appset): update gitlab SCM provider to search on parent folder (#16253) #21491
Conversation
❌ Preview Environment deleted from BunnyshellAvailable commands (reply to this comment):
|
acc2115
to
8974f93
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #21491 +/- ##
==========================================
+ Coverage 53.35% 55.25% +1.90%
==========================================
Files 337 337
Lines 56846 56837 -9
==========================================
+ Hits 30330 31406 +1076
+ Misses 23876 22744 -1132
- Partials 2640 2687 +47 ☔ View full report in Codecov by Sentry. |
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.
Thanks for the PR! Code LGTM. Could we get some test coverage here? https://github.com/argoproj/argo-cd/blob/master/applicationset/services/pull_request/gitlab_test.go
I'm not sure I can add tests on some remote API changes... the function is already tested and detects all the cases. I don't see the point of testing this 404 thing. The |
I had a second look, and while I could create a case like: case "/api/v4/projects/27084533/repository/tree?path=argocd/file.txt&ref=master":
w.WriteHeader(http.StatusNotFound) There's no way to trigger it by calling |
@crenshaw-dev how to get that ported to older releases as it's a fix for a bug linked to Gitlab, not a real bug in Argo, but impact mostly all previous versions ? |
There are two existing tests which should cover this code path: case "/api/v4/projects/27084533/repository/tree?path=argocd&ref=master":
_, err := io.WriteString(w, `[{"id":"ca14f2a3718159c74572a5325fb4bfb0662a2d3e","name":"ingress.yaml","type":"blob","path":"argocd/ingress.yaml","mode":"100644"},{"id":"de2a53a73b1550b3e0f4d37ea0a6d878bf9c5096","name":"install.yaml","type":"blob","path":"argocd/install.yaml","mode":"100644"}]`)
if err != nil {
t.Fail()
}
case "/api/v4/projects/27084533/repository/tree?path=.&ref=master":
_, err := io.WriteString(w, `[{"id":"f2bf99fa8f7a27df9c43d2dffc8c8cd747f3181a","name":"argocd","type":"tree","path":"argocd","mode":"040000"},{"id":"68a3125232e01c1583a6a6299534ce10c5e7dd83","name":"manifests","type":"tree","path":"manifests","mode":"040000"}]`)
if err != nil {
t.Fail()
} I think we should 1) modify the existing tests to reproduce the bug (i.e. return a 404 when a file path is specified) and 2) add new tests to reflect the new API call and response.
We'll cherry-pick it and cut patch releases. A bug caused by an external change is still a bug as far as patching goes imo. |
we can't reproduce the bug... because the patch removes the call that was returning the 404... and the new code never calls the gitlab API with a file path, only with a directory path... I can add the test I provided just above, which would replicate the Gitlab API (new) behaviour... but the code just never calls the API this way anymore... |
You can run the old code against the new test and confirm that the test fails. Then we can leave that test in place to assure that no one re-introduces code that assumes the old API behavior.
Yep, we should have tests that handle the directory path case. I'm not sure exactly what the API call path will look like, but our tests should have that path and a corresponding test response. |
fix argoproj#16253 Signed-off-by: Prune <prune@lecentre.net>
Signed-off-by: Prune <prune@lecentre.net>
d6d7d5a
to
d319eb6
Compare
OK I think I got it :) It is cumbersome as the |
Signed-off-by: Prune <prune@lecentre.net>
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.
LGTM! I'm still a bit wary of any change that could cause app deletion... how would you feel about just cherry-picking to 2.14 for now and giving it a few weeks before cherry-picking back further?
/cherry-pick release-2.14 |
as you wish. But this change should not remove any app... works the same, it's just not searching for the directory straight away, but parses all the files/folders in the parent folder... there's no behaviour change. |
I agree, but also I don't entirely trust my eyes or even the tests. I've been unpleasantly surprised too many times. :-) |
…16253) (#21491) * (fix:appset) update gitlab SCM provider to search on parent folder fix #16253 Signed-off-by: Prune <prune@lecentre.net> * adding test-case that replicated the new Gitlab API behaviour Signed-off-by: Prune <prune@lecentre.net> * add comments to the case Signed-off-by: Prune <prune@lecentre.net> --------- Signed-off-by: Prune <prune@lecentre.net>
…16253) (#21491) (#21503) * (fix:appset) update gitlab SCM provider to search on parent folder fix #16253 * adding test-case that replicated the new Gitlab API behaviour * add comments to the case --------- Signed-off-by: Prune <prune@lecentre.net> Co-authored-by: Prune Sebastien THOMAS <prune@lecentre.net>
Thank you for addressing the issue! Will there be a patch release to include this fix sooner, or will it only be part of version 2.14 scheduled for February? |
…rgoproj#16253) (argoproj#21491) * (fix:appset) update gitlab SCM provider to search on parent folder fix argoproj#16253 Signed-off-by: Prune <prune@lecentre.net> * adding test-case that replicated the new Gitlab API behaviour Signed-off-by: Prune <prune@lecentre.net> * add comments to the case Signed-off-by: Prune <prune@lecentre.net> --------- Signed-off-by: Prune <prune@lecentre.net> Signed-off-by: Brett C. Dudo <brett@dudo.io>
…rgoproj#16253) (argoproj#21491) * (fix:appset) update gitlab SCM provider to search on parent folder fix argoproj#16253 Signed-off-by: Prune <prune@lecentre.net> * adding test-case that replicated the new Gitlab API behaviour Signed-off-by: Prune <prune@lecentre.net> * add comments to the case Signed-off-by: Prune <prune@lecentre.net> --------- Signed-off-by: Prune <prune@lecentre.net>
…rgoproj#16253) (argoproj#21491) * (fix:appset) update gitlab SCM provider to search on parent folder fix argoproj#16253 Signed-off-by: Prune <prune@lecentre.net> * adding test-case that replicated the new Gitlab API behaviour Signed-off-by: Prune <prune@lecentre.net> * add comments to the case Signed-off-by: Prune <prune@lecentre.net> --------- Signed-off-by: Prune <prune@lecentre.net> Signed-off-by: flbla <flbla@users.noreply.github.com>
@dfl-aeb we'll ship it in the next 2.14 RC. If things look good after releasing the bugfix in 2.14, we can consider cherry-picking to other supported releases. |
We're fine with the 2.14 RC thx |
…rgoproj#16253) (argoproj#21491) * (fix:appset) update gitlab SCM provider to search on parent folder fix argoproj#16253 Signed-off-by: Prune <prune@lecentre.net> * adding test-case that replicated the new Gitlab API behaviour Signed-off-by: Prune <prune@lecentre.net> * add comments to the case Signed-off-by: Prune <prune@lecentre.net> --------- Signed-off-by: Prune <prune@lecentre.net>
Fixes [#16253]
This PR solves the ISsue with Gitlab 17.7 (probably others) where using the
ListTree
API request and specifying a path to a file returns a 404.This is a change in the API and prevent usage of files in the Gitlab SCM
PathExist
.This PR changes the way we do the search, by looking for all individual entries in the parent folder, whatever we're looking for a file or a folder.
Pros
Cons
Checklist: