Skip to content

Fix nits from #2312 #2328

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

Merged
merged 4 commits into from
May 15, 2025
Merged

Conversation

mtrmac
Copy link
Collaborator

@mtrmac mtrmac commented May 6, 2025

Addresses most of #2312 (review) . See individual commit messages for details.

@@ -160,9 +160,9 @@ func readEstargzChunkedManifest(blobStream ImageSourceSeekable, blobSize int64,
}

func openTmpFile(tmpDir string) (*os.File, error) {
file, err := os.OpenFile(tmpDir, unix.O_TMPFILE|unix.O_RDWR|unix.O_CLOEXEC|unix.O_EXCL, 0o600)
fd, err := unix.Open(tmpDir, unix.O_TMPFILE|unix.O_RDWR|unix.O_CLOEXEC|unix.O_EXCL, 0o600)
Copy link
Contributor

Choose a reason for hiding this comment

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

Back when reviewing the original commit I checked that

  • os.OpenFile flags argument type is int (i.e. a generic one);
  • it is passed almost as is onto syscall.Open ("almost" since O_LARGEFILE and O_CLOEXEC are added);
  • os.O_*, syscall.O_*, and unix.O_* flag values should be equal (although there is no guarantee);
  • a lot of existing code uses unix.O_* flags with os.OpenFile;

and so I guesses it's OK as it is.

With this change, though

  • we lose the ability to retry on EINTR;
  • as far as I understand, os.OpenFile adds the file to the internal poller, while the new code doesn't (which probably doesn't matter here).

All in all, I slightly prefer the old way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

we lose the ability to retry on EINTR;

I don’t know why that should happen on a local filesystem operation

as far as I understand, os.OpenFile adds the file to the internal poller

The Linux implementation would try to use epoll, and at least on XFS that’s not possible and fails.

Copy link
Contributor

Choose a reason for hiding this comment

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

The Linux implementation would try to use epoll, and at least on XFS that’s not possible and fails.

Yes it will always fail so it shouldn't matter either way.

I routinely use strace to debug things and every time I just smile at how the Go runtime always tries and fails to add a local file to epoll, even in the case where it knows it's a regular file it just opened. It has never worked, and almost certainly never will. The modern way to do async I/O that works for local files and network sockets is io_uring. But, not relevant here. The "try and fail to add to epoll every time" though is a very Go thing to do.

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 after the Don't mix os.OpenFile with x/sys/unix.O_* flags patch is dropped

@mtrmac mtrmac force-pushed the DifferOutput-nits branch from 2513b99 to 0049fbf Compare May 7, 2025 17:24
@mtrmac
Copy link
Collaborator Author

mtrmac commented May 7, 2025

LGTM after the Don't mix os.OpenFile with x/sys/unix.O_* flags patch is dropped

I continue to think the mixing is incorrect, but there are several other pre-existing instances in the repo, and there is a unit test, so, fair enough. Dropped.

@mtrmac mtrmac force-pushed the DifferOutput-nits branch from 0049fbf to 62510fb Compare May 14, 2025 17:53
@mtrmac
Copy link
Collaborator Author

mtrmac commented May 14, 2025

Rebased, PTAL.

mtrmac added 4 commits May 14, 2025 20:53
Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This ultimately amounts to the same thing (and os.File.Seek is
a tiny bit more costly, with some atomic operations) - using
os.File.Seek is more consistent with the surrounding code
relying on uses through os.File, as well as a tiny bit
shorter.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
The callers don't really need to know, and this way we don't
need to get the details of the syntax correct.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
AFAICS this does not apply to that line of code.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
@mtrmac mtrmac force-pushed the DifferOutput-nits branch from 62510fb to 108b5b1 Compare May 14, 2025 18:53
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

Copy link
Contributor

@kolyshkin kolyshkin left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

openshift-ci bot commented May 14, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe, kolyshkin, mtrmac

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 [giuseppe,kolyshkin,mtrmac]

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

@rhatdan
Copy link
Member

rhatdan commented May 15, 2025

/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 15, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 78f4258 into containers:main May 15, 2025
20 checks passed
@mtrmac mtrmac deleted the DifferOutput-nits branch May 15, 2025 17:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants