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 deprecated use of hdr.Xattrs (SA1019) #1985

Merged
merged 2 commits into from
Jun 27, 2024

Conversation

Honny1
Copy link
Member

@Honny1 Honny1 commented Jun 24, 2024

This PR fixes warning deprecated use of hdr.Xattrs (SA1019) found by golangci when the staticcheck linter is enabled.

Partially fixes:

@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch from bebf76f to 6bcee99 Compare June 24, 2024 12:01
@Honny1 Honny1 marked this pull request as ready for review June 24, 2024 13:03
@rhatdan
Copy link
Member

rhatdan commented Jun 24, 2024

/approve
LGTM
@giuseppe @nalind @mtrmac @saschagrunert PTAL

Copy link
Contributor

openshift-ci bot commented Jun 24, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Honny1, rhatdan

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

@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch from 6bcee99 to 475d1b5 Compare June 24, 2024 13:31
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

Thanks!

This LGTM locally, but this is fairly critical low-level code. Could you check that the packages do have some tests that cover the changed code, please? (One possible approach would be, for each instance, to just delete the Xattr handling code, and ensure that at least one c/storage test fails. Ideally the tests that fail should go all the way between a local file and a tar stream, not just a local unit test on ReadSecurityXattrToTarHeader or so.)

Also Cc: @nalind for expert insights.

pkg/archive/archive.go Outdated Show resolved Hide resolved
@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch 3 times, most recently from 2514d3c to 76ad219 Compare June 24, 2024 18:44
@rhatdan
Copy link
Member

rhatdan commented Jun 24, 2024

@mtrmac PTANL

@mtrmac
Copy link
Collaborator

mtrmac commented Jun 24, 2024

I’m fine with the code, but I’d like to hear an assurance that this is covered by tests. (Yes, I could go verify that myself…)

@Honny1
Copy link
Member Author

Honny1 commented Jun 24, 2024

I checked the unit tests by commenting out the parts of the code that were changed if the tests fail. The tests did not fail for the readUserXattrToTarHeader, (o overlayWhiteoutConverter) ConvertWrite, writeZstdChunkedStream functions. I haven't tried code changes that are specific to the darwin os. Should I also try to run unit tests of padman with the imported local storage?

@mtrmac
Copy link
Collaborator

mtrmac commented Jun 24, 2024

I’d guess that if c/storage does not test these somewhat obscure aspects of layer extraction itself, Podman is unlikely to; but triggering a Podman CI run with a modified c/storage is probably much cheaper than manual analysis, so, sure, go for it.

continue
}
if err := system.Lsetxattr(path, key, []byte(value), 0); err != nil {
if err := system.Lsetxattr(path, xattr_key, []byte(value), 0); err != nil {
Copy link
Member

Choose a reason for hiding this comment

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

please use xattrKey if you really need to change it

@Honny1
Copy link
Member Author

Honny1 commented Jun 26, 2024

@mtrmac I ran podman CI with imported c/storage with changes in this PR. CI passes see the PR that runs the tests.

@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch 2 times, most recently from bb85554 to 0246ea4 Compare June 26, 2024 10:18
@Honny1
Copy link
Member Author

Honny1 commented Jun 26, 2024

I checked the unit tests by commenting out the parts of the code that were changed if the tests fail. The tests did not fail for the readUserXattrToTarHeader, (o overlayWhiteoutConverter) ConvertWrite, writeZstdChunkedStream functions. I haven't tried code changes that are specific to the darwin os. Should I also try to run unit tests of padman with the imported local storage?

I added an xattr to TestTarUntarWithXattr which is a user xattr. So the test fails for the commented change in readUserXattrToTarHeader.

@Honny1 Honny1 requested a review from mtrmac June 26, 2024 16:18
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

If I understand it correctly, with this PR we have xattr test coverage for archive.go. Great!


I can’t see any c/storage test at all exercising compressor.ZstdCompressor; I can’t see any for the whiteout converter either, but there it’s quite possible I have missed one.

*shrug* if that’s the case, I think it can be reasonably argued it’s not the responsibility of this PR to add missing tests to entire large features.

pkg/archive/archive_unix_test.go Outdated Show resolved Hide resolved
@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch from 0246ea4 to f0e6411 Compare June 26, 2024 18:11
@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch from f0e6411 to 965fb12 Compare June 26, 2024 18:12
Copy link
Collaborator

@mtrmac mtrmac left a comment

Choose a reason for hiding this comment

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

/lgtm

Thanks!

pkg/archive/archive_unix_test.go Outdated Show resolved Hide resolved
@openshift-ci openshift-ci bot added the lgtm label Jun 26, 2024
@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch from 965fb12 to 1b68ac8 Compare June 26, 2024 18:27
@openshift-ci openshift-ci bot removed the lgtm label Jun 26, 2024
@mtrmac
Copy link
Collaborator

mtrmac commented Jun 26, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 26, 2024
@mtrmac
Copy link
Collaborator

mtrmac commented Jun 26, 2024

@Honny1 the tests are failing

@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch from 1b68ac8 to dcf95c9 Compare June 26, 2024 19:22
@openshift-ci openshift-ci bot removed the lgtm label Jun 26, 2024
@Honny1 Honny1 force-pushed the fix-deprecated-hdr_Xattrs branch from dcf95c9 to f764eb9 Compare June 26, 2024 20:04
@Honny1 Honny1 requested a review from mtrmac June 27, 2024 08:57
@Honny1
Copy link
Member Author

Honny1 commented Jun 27, 2024

@mtrmac The tests are passing.

@mtrmac
Copy link
Collaborator

mtrmac commented Jun 27, 2024

/lgtm

@openshift-ci openshift-ci bot added the lgtm label Jun 27, 2024
@openshift-merge-bot openshift-merge-bot bot merged commit 52b643e into containers:main Jun 27, 2024
18 checks passed
@Honny1 Honny1 deleted the fix-deprecated-hdr_Xattrs branch July 1, 2024 15:53
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.

4 participants