Skip to content

Conversation

lsm5
Copy link
Member

@lsm5 lsm5 commented Oct 10, 2025

Problem: While removing cgroupsv1 code, I noticed my neovim Go config automatically changed fileperms to the new octal format and I didn't want that polluting my diffs.

Decision: I thought it best to switch to the new octal format in a dedicated PR.

Action:

  • Cursor switched to new octal format for all fileperm ocurrences in Go source and test files.
  • vendor/, docs/ and non-Go files were ignored.
  • Reviewed manually.

Ref: https://go.dev/ref/spec#Go_1.13

Does this PR introduce a user-facing change?

None

(We can block this until Podman 6 if we're not comfortable with this going in earlier, but it'd be really nice to have it go in sooner (maybe even v5.7, assuming nothing breaks)).

@openshift-ci openshift-ci bot added release-note-none do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Oct 10, 2025
Copy link
Contributor

openshift-ci bot commented Oct 10, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: lsm5

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 10, 2025
@lsm5 lsm5 marked this pull request as ready for review October 10, 2025 17:56
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 10, 2025
@lsm5
Copy link
Member Author

lsm5 commented Oct 10, 2025

@containers/podman-maintainers PTAL

Expect(err).ToNot(HaveOccurred())
mountPath := filepath.Join(podmanTest.TempDir, "secrets")
err = os.Mkdir(mountPath, 0755)
err = os.Mkdir(mountPath, 0o755)
Copy link
Member

@TomSweeneyRedHat TomSweeneyRedHat Oct 10, 2025

Choose a reason for hiding this comment

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

IDK, but there are so many instances of some of these values in a file. Would it make more sense to make them variables so that, in case this ever needs to change again, it's only in one spot per file?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd be cool with that if everyone agrees.

Copy link
Member

Choose a reason for hiding this comment

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

I don't see a strong benifit in doing this, the nice thing about having the modes inline any test reader sees which mode is being used with extra indirections.

I would say it would be much nicer to consolidate the common setup code into a helper function, i.e. create dir under the test tempdir and check for errors so in each test block we only have a single line. But of course that would be a much larger scope which I don't think we need to do here and all at once, we can introduce tests helpers gradually

Copy link
Collaborator

Choose a reason for hiding this comment

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

In a lot of these situations, testing.T.Tempdir() is easier — no Join calls, no naming of the directory, just call Tempdir() and assign to a variable. Historically that was not possible in Ginkgo, reportedly it does work now. Or maybe we can build a utility like that.

Do we need to specify permissions for the directories? In many other projects, the default of 0700 is both safe and sufficient; it’s possible that Podman, with rootless operation, might need the permissions relaxed in some cases.

Clearly a different PR, though.

Copy link
Member

Choose a reason for hiding this comment

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

Do we need to specify permissions for the directories? In many other projects, the default of 0700 is both safe and sufficient; it’s possible that Podman, with rootless operation, might need the permissions relaxed in some cases.

Yeah mode wise when using user namespaces and such we might need world readable when running the container as different uid, etc.. Depends a lot on the context of course.

And on the similar Tmpdir() will try to remove the dir via a normal remove() which is not enough if a file with subuids was created on it as part of a container run, see

podman/test/e2e/common_test.go

Lines 1310 to 1327 in 86eecc9

// rmAll removes the directory and its content, when running rootless we use
// podman unshare to prevent any subuid/gid problems
func rmAll(podmanBin string, path string) {
// Remove cache dirs
if isRootless() {
// If rootless, os.RemoveAll() is failed due to permission denied
cmd := exec.Command(podmanBin, "unshare", "rm", "-rf", path)
cmd.Stdout = GinkgoWriter
cmd.Stderr = GinkgoWriter
if err := cmd.Run(); err != nil {
GinkgoWriter.Printf("%v\n", err)
}
} else {
if err = os.RemoveAll(path); err != nil {
GinkgoWriter.Printf("%q\n", err)
}
}
}

As such I think is is somewhat important that we ensure the tmpfiles stay under the main podmanTest.Tempdir where possible so we can correctly ensure removal in all cases.

@TomSweeneyRedHat
Copy link
Member

TomSweeneyRedHat commented Oct 10, 2025

The machine-wsl test flaked, I've restarted.
LGTM
I've one thought for consideration, otherwise LGTM. I'd vote for getting this into v5.7 unless someone has strong concerns.

@Luap99
Copy link
Member

Luap99 commented Oct 13, 2025

While removing cgroupsv1 code, I noticed my neovim Go config automatically changed fileperms to the new octal format and I didn't want that polluting my diffs.

That more hints like you are using the wrong formatter then, the file mode may only be one example where it shows. I guess you are using gofumpt and not the normal gofmt?

That matters because gofumpt does much more changes and I really really hate these unrelated diff changes, I have been seeing them in other PRs at well. I think @ninja-quokka is on of the people where this is the same issue.

In general style like this must be enforced by the linter/formatters because not doing that will just result in new instances of 0755 that you then format in unrelated PRs most likely over time. And that is just not good.

So I see two ways, either we all agree that we want to format with gofumpt and add it to the linter list, we already have it on in some modules, compare containers/container-libs#352.

Or we keep doing the normal gofmt like it is and contributors must fix there editors to not format with tools like gofumpt and/or not format unrelated code.

I don't see a strong reason for gofumpt, the downside is that anybody not using it right now must fix their editors to add that into their local setup and for new contributors it creates another hurdle of failing the linter for some very nit picky style things. It also creates new friction on linter upgrades as it is possible that some new code must be reformatted, see the PR linked above.

@containers/podman-maintainers WDYT?

@Luap99
Copy link
Member

Luap99 commented Oct 13, 2025

I'd vote for getting this into v5.7 unless someone has strong concerns.

I don't see any reason for or against it, it can be merged anytime as it doesn't chnage anything code logic wise. There is no benifit over blocking the 5.7 release on it in other words if it isn't merged by then.

<integer>{{.UID}}</integer>
<key>SockPathMode</key>
<!-- SockPathMode takes base 10 (384 = 0600) -->
<!-- SockPathMode takes base 10 (384 = 0o600) -->
Copy link
Member

Choose a reason for hiding this comment

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

I don't think the formatter would chnage this btw, this seems to be a comment in an xml file so it likely doesn't matter at all but it isn't really related to the go syntax here at all and using the more comment 0600 mode like you would do on command like chmod would thus make more sense in the context here I would argue.

Copy link
Collaborator

Choose a reason for hiding this comment

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

+1

Copy link
Member Author

Choose a reason for hiding this comment

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

ya, this change was made by cursor and evidently i ignored this in the manual review :|

@ninja-quokka
Copy link
Collaborator

So I see two ways, either we all agree that we want to format with gofumpt and add it to the linter list, we already have it on in some modules, compare containers/container-libs#352.

Or we keep doing the normal gofmt like it is and contributors must fix there editors to not format with tools like gofumpt and/or not format unrelated code.

I don't have a strong opinion either way. I was using gofumpt because I naively assumed "stricter" was better. I've now come to think in a large project like Podman with so many contributors the most important thing when it comes to linters is uniformity of use.

I think we should use gofmt unless someone has strong justification and makes the case for using gofumpt. At that point we should update our CI, docs, validatepr etc.

Having said that I like this current patch and think keeping the code base updated with changing code patterns/standards is a positive thing, I just share the concern with @Luap99 that without correct onboarding of gofumpt new patches will be introduced using the old style and thus undermining this refactoring effort.

@lsm5
Copy link
Member Author

lsm5 commented Oct 13, 2025

I'm ok either way. If we decide on gofumpt, we should enforce it in a CI check, like Lewis mentioned. If I have a vote, I'll say stricter is better, unless it's known to break things. But that could also mean some transition time where a few people might be occupied fixing gofumpt issues to make CI green with gofumpt enabled.

@lsm5
Copy link
Member Author

lsm5 commented Oct 13, 2025

Or we keep doing the normal gofmt like it is and contributors must fix there editors to not format with tools like gofumpt and/or not format unrelated code.

How about new contributors who are already using gofumpt elsewhere? Should they be asked to switch to gofmt and resubmit PRs? (If this is expected to be a rare case, then I guess we can ignore this.)

@Luap99
Copy link
Member

Luap99 commented Oct 13, 2025

Or we keep doing the normal gofmt like it is and contributors must fix there editors to not format with tools like gofumpt and/or not format unrelated code.

How about new contributors who are already using gofumpt elsewhere? Should they be asked to switch to gofmt and resubmit PRs? (If this is expected to be a rare case, then I guess we can ignore this.)

Well gofumpt is AFAIK a superset of the normal gofmt. So a submitter can have code formatter with gofumpt as long as it is only used on the newly written code and thus nor reformat the rest of the file. Given the formatters work file based that seems impossible which means reviews are harder than they should be in which case I am going to ask the submitter to remove the formatting changes please.

I have no real clue what the percentage of users is for each formatter. I am fine with adopting either one personally but I guess that is something that we should decide once with a majority agreement

Though I guess technically there is no requirement to block this PR on it. Though as I said before if there is nothing enforcing the style than this will not solve your problem of formatting unrelated code.

@lsm5
Copy link
Member Author

lsm5 commented Oct 13, 2025

Ack, I'd like to include this as a community cabal topic in that case. I'll fix the xml change in this PR and run another manual review. And for other stuff, I'll use gofmt until we reach a decision.

@Luap99
Copy link
Member

Luap99 commented Oct 14, 2025

re: linter discussion, please let's continue it here: #27291

Problem: While removing cgroupsv1 code, I noticed my neovim Go config
automatically changed fileperms to the new octal format and I didn't
want that polluting my diffs.

Decision: I thought it best to switch to the new octal format in a dedicated PR.

Action:
- Cursor switched to new octal format for all fileperm ocurrences in Go
 source and test files.
- vendor/, docs/ and non-Go files were ignored.
- Reviewed manually.

Ref: https://go.dev/ref/spec#Go_1.13

Signed-off-by: Lokesh Mandvekar <[email protected]>
@lsm5 lsm5 force-pushed the new-octal-format branch from 9cb2e51 to 0caf15b Compare October 15, 2025 13:47
@lsm5
Copy link
Member Author

lsm5 commented Oct 15, 2025

I've removed the xml and comment diffs from this PR. PTAL

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. machine release-note-none

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants