-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Quadlet - make sure the order of the UnitsDir is deterministic #24062
Quadlet - make sure the order of the UnitsDir is deterministic #24062
Conversation
Ephemeral COPR build failed. @containers/packit-build please check. |
25e8717
to
e1f3a61
Compare
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.
Thank you for getting to this. Two requests, nonblocking.
test/system/252-quadlet.bats
Outdated
dir1=$PODMAN_TMPDIR/02_$(random_string) | ||
dir2=$PODMAN_TMPDIR/01_$(random_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.
I was thinking about this yesterday... and think the original form, without 02/01, is preferable. Your way would catch deterministic sorting; the original way catches a broader class of failures (albeit at the cost of them being flaky and hard to debug).
Would you mind fixing Image
as I suggested in the bug report, at least in the dir2 file? Something like Image=YOU-SHOULD-NEVER-SEE-THIS-BAD-BAD-BAD
? Just to help future maintainers?
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 review. Done and Done.
e1f3a61
to
a2c83a8
Compare
test/system/252-quadlet.bats
Outdated
# If two directories in the search have files with the same name, quadlet should | ||
# only process the first name | ||
# prepend the directory name to make test that the order set in QUADLET_UNIT_DIRS is kept |
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.
Thank you! Sorry to be a stickler but this comment no longer makes any sense
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.
Stickler away :)
a2c83a8
to
2a73637
Compare
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
cmd/quadlet/main.go
Outdated
return dirs | ||
} | ||
|
||
func addDirToDirs(path string, dirs []string, visitedDirs map[string]struct{}) []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.
maybe it would have been cleaner to define a helper type
type searchPaths struct {
sorted []string
// map to store paths so we can quickly check if we saw them already and not loop in case of symlinks
visitedDirs map[string]struct{}
}
And then define a Add() method on it and pass the struct as pointer around.
But given you have written the code already am I also good with the current version, let me know if you like to change it. If not I will merge it
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.
Great idea. I'll implement it
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.
@Luap99 Done
Change getUnitDirs to maintain a slice in addition to the map and return the slice Add helper functions to make the code more readable Adjust unit tests Restore system test Signed-off-by: Ygal Blum <[email protected]>
2a73637
to
ebbec00
Compare
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
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: giuseppe, Luap99, ygalblum The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
87dcf9d
into
containers:main
Does this PR introduce a user-facing change?
No
Resolves: #24047