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

Quadlet - make sure the order of the UnitsDir is deterministic #24062

Merged

Conversation

ygalblum
Copy link
Contributor

Does this PR introduce a user-facing change?

No

None

Resolves: #24047

@openshift-ci openshift-ci bot added release-note-none approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Sep 24, 2024
Copy link

Ephemeral COPR build failed. @containers/packit-build please check.

@ygalblum ygalblum force-pushed the quadlet-restore-dir-order branch from 25e8717 to e1f3a61 Compare September 24, 2024 22:34
Copy link
Member

@edsantiago edsantiago 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 for getting to this. Two requests, nonblocking.

Comment on lines 227 to 228
dir1=$PODMAN_TMPDIR/02_$(random_string)
dir2=$PODMAN_TMPDIR/01_$(random_string)
Copy link
Member

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?

Copy link
Contributor Author

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.

@ygalblum ygalblum force-pushed the quadlet-restore-dir-order branch from e1f3a61 to a2c83a8 Compare September 25, 2024 13:58
# 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
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Stickler away :)

@ygalblum ygalblum force-pushed the quadlet-restore-dir-order branch from a2c83a8 to 2a73637 Compare September 25, 2024 14:17
Copy link
Member

@giuseppe giuseppe left a comment

Choose a reason for hiding this comment

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

LGTM

return dirs
}

func addDirToDirs(path string, dirs []string, visitedDirs map[string]struct{}) []string {
Copy link
Member

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

Copy link
Contributor Author

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

Copy link
Contributor Author

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]>
@ygalblum ygalblum force-pushed the quadlet-restore-dir-order branch from 2a73637 to ebbec00 Compare September 26, 2024 14:57
Copy link
Member

@Luap99 Luap99 left a comment

Choose a reason for hiding this comment

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

Thanks
/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Sep 27, 2024
Copy link
Contributor

openshift-ci bot commented Sep 27, 2024

[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:
  • OWNERS [Luap99,giuseppe,ygalblum]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 87dcf9d into containers:main Sep 27, 2024
74 of 80 checks passed
@ygalblum ygalblum deleted the quadlet-restore-dir-order branch September 27, 2024 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. release-note-none
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Regression: Quadlet: conflict names is nondeterministically failing
4 participants