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(appset): new globbing not used until cache expires #21686

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

agaudreault
Copy link
Member

@agaudreault agaudreault commented Jan 27, 2025

When using appset with applicationsetcontroller.enable.new.git.file.globbing: "true", it takes up to 24h hours for the new globbing to apply. This is because the repo server contains a cache that by default expires every 24h.

To prevent this, the globbing algorithm used is used along with the pattern in the cache key.

New tests were to the new globbing to clarify it's behaviour, and a problem was found were, depending on the OS, chdir(m.root) can set a different value than m.root as the working directory.

For instance, during the unit test, on MacOs, /var/tmp/.... will result in /private/var/tmp/.... when used as a current working directory.

Signed-off-by: Alexandre Gaudreault <[email protected]>
Signed-off-by: Alexandre Gaudreault <[email protected]>
@agaudreault agaudreault requested a review from a team as a code owner January 27, 2025 23:17
Copy link

bunnyshell bot commented Jan 27, 2025

❗ Preview Environment stop on Bunnyshell failed

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🔴 /bns:stop to stop again the environment
  • 🔵 /bns:start to start the environment
  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

if err != nil {
return nil, err
}
cwd, err = os.Getwd()
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cwd, err = os.Getwd()
// Depending on the OS, this can be different from m.root. Get the OS-specific path
// for cross-platform compatibility.
cwd, err = os.Getwd()

Copy link
Member

Choose a reason for hiding this comment

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

Are they different because os.Getwd() is indeterministic when a folder can be reached by multiple paths via symlinks?

Copy link
Member

@rumstead rumstead left a comment

Choose a reason for hiding this comment

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

Overall LGTM, some minor test cases need to be adjusted in reposerver/cache/cache_test

EDIT: I just asked some questions for my own understanding

@@ -421,10 +421,16 @@ func (m *nativeGitClient) Fetch(revision string) error {
func (m *nativeGitClient) LsFiles(path string, enableNewGitFileGlobbing bool) ([]string, error) {
if enableNewGitFileGlobbing {
// This is the new way with safer globbing
err := os.Chdir(m.root)
cwd := m.root
Copy link
Member

Choose a reason for hiding this comment

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

Just for my understanding, this was just added for debugging and doesn't make any material change?

Signed-off-by: Alexandre Gaudreault <[email protected]>
@agaudreault agaudreault marked this pull request as draft February 7, 2025 15:20
Copy link

codecov bot commented Feb 7, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 55.63%. Comparing base (b4a63ae) to head (85d7365).
Report is 30 commits behind head on master.

Files with missing lines Patch % Lines
util/git/client.go 57.14% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #21686      +/-   ##
==========================================
+ Coverage   55.59%   55.63%   +0.04%     
==========================================
  Files         340      339       -1     
  Lines       57419    56818     -601     
==========================================
- Hits        31924    31613     -311     
+ Misses      22807    22555     -252     
+ Partials     2688     2650      -38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

3 participants