Nothing Special   »   [go: up one dir, main page]

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

Two xfs file systems with same UUID can not be mounted on the same sy… #6650

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

henry118
Copy link
Member
@henry118 henry118 commented Mar 8, 2022

Fixes issue: #6587

Two xfs file systems with same UUID can not be mounted on the same system. However devmapper snapshots will have same UUID as original filesystem.

This patch fixes the bug by mounting a xfs file system with "nouuid" option.

Signed-off-by: Henry Wang henwang@amazon.com

@k8s-ci-robot
Copy link

Hi @henry118. Thanks for your PR.

I'm waiting for a containerd member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member
@kzys kzys left a comment

Choose a reason for hiding this comment

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

The change looks good to me.

Is it possible to reproduce the issue by expanding https://github.com/containerd/containerd/blob/main/snapshots/devmapper/snapshotter_test.go? Does GitHub Actions have mkfs.xfs?

@theopenlab-ci
Copy link
theopenlab-ci bot commented Mar 9, 2022

Build succeeded.

  • containerd-build-arm64 : RETRY_LIMIT in 3m 37s (non-voting)
  • containerd-test-arm64 : RETRY_LIMIT in 5m 40s (non-voting)
  • containerd-integration-test-arm64 : RETRY_LIMIT in 25m 02s (non-voting)

@henry118
Copy link
Member Author
henry118 commented Mar 9, 2022

The errors happens after mkfs, when a snapshot is actually mounted for multiple containers. I am not sure if there is a way to reproduce it with unit tests. Any suggestions?

@kzys
Copy link
Member
kzys commented Mar 9, 2022

If we make two snapshots with xfs and mount both of them, would it reproduce the error? A lot of containerd tests actually run syscalls such as mount.

@henry118
Copy link
Member Author
henry118 commented Mar 9, 2022

Can you point me some sample unit tests as you mentioned? so I can use them as references for implementing the new test cases... Thanks!

@kzys
Copy link
Member
kzys commented Mar 9, 2022

How about this one? I believe that mount here is not mocked.

mounts, err := snapshotter.Prepare(ctx, "prepare-2", "layer-1")
assert.NilError(t, err)
err = mount.WithTempMount(ctx, mounts, baseApplier.Apply)
assert.NilError(t, err)

@henry118
Copy link
Member Author
henry118 commented Mar 9, 2022

Great thanks, will look into it.


ctx := context.Background()
ctx = namespaces.WithNamespace(ctx, "testsuite")
tempDir, err := os.MkdirTemp("", "snapshot-suite-usage")
Copy link
Member

Choose a reason for hiding this comment

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

You can use t.TempDir instead

Copy link
Member Author

Choose a reason for hiding this comment

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

this logic was taken from https://github.com/containerd/containerd/blob/main/snapshots/devmapper/snapshotter_test.go#L89

I think it was chosen because we want to explicitly specify a pattern for the temp directory?

Copy link
Member

Choose a reason for hiding this comment

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

I believe, we simply didn't have t.TempDir when we first wrote that code. It is added in Go 1.15.

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably. However i still believe the original logic works better. For instance we can easily locate the path when we have to debug a failing test case with an explicitly specified dir pattern. I actually found it useful when I wrote this unit test. But if you have a strong opinion about this I am fine with making the change.

Comment on lines +166 to +169
var (
sizeBytes int64 = 1048576 // 1MB
baseApplier = fstest.Apply(fstest.CreateRandomFile("/a", 12345679, sizeBytes, 0777))
)
Copy link
Member

Choose a reason for hiding this comment

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

We don't need them.

Copy link
Member Author

Choose a reason for hiding this comment

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

Why? baseApplier is needed to create a snapshot.

Copy link
Member

Choose a reason for hiding this comment

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

I think (not 100% sure, sorry) that Prepare() returns a XFS-formatted devmapper device. So mounting two of them is enough to reproduce the original issue. Would it work?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. we have to prepare an additional snapshot from a base one.

err := dmsetup.CreatePool(config.PoolName, loopDataDevice, loopMetaDevice, 64*1024/dmsetup.SectorSize)
assert.NilError(t, err, "failed to create pool %q", config.PoolName)

snap, err := NewSnapshotter(context.Background(), config)
Copy link
Member

Choose a reason for hiding this comment

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

How about taking the passed ctx instead of making a new one?

Copy link
Member Author
@henry118 henry118 Mar 10, 2022

Choose a reason for hiding this comment

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

Sounds good. Updated

Two xfs file systems with same UUID can not be mounted on the same system.
However devmapper snapshots will have same UUID as original filesystem.

This patch fixes the bug by mounting a xfs file system with "nouuid" option.

Signed-off-by: Henry Wang <henwang@amazon.com>
Copy link
Member
@kzys kzys left a comment

Choose a reason for hiding this comment

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

LGTM

/ok-to-test

@theopenlab-ci
Copy link
theopenlab-ci bot commented Mar 10, 2022

Build succeeded.

  • containerd-build-arm64 : RETRY_LIMIT in 3m 37s (non-voting)
  • containerd-test-arm64 : RETRY_LIMIT in 5m 41s (non-voting)
  • containerd-integration-test-arm64 : RETRY_LIMIT in 24m 27s (non-voting)

@FFFrog
Copy link
FFFrog commented Mar 10, 2022

/ok-to-test

@FFFrog
Copy link
FFFrog commented Mar 10, 2022

recheck

1 similar comment
@FFFrog
Copy link
FFFrog commented Mar 10, 2022

recheck

@theopenlab-ci
Copy link
theopenlab-ci bot commented Mar 10, 2022

Build succeeded.

@kzys
Copy link
Member
kzys commented Mar 10, 2022

@FFFrog /ok-to-test works only if the comment is made by the people in this containerd org. We don't support recheck.

Copy link
Member
@estesp estesp left a comment

Choose a reason for hiding this comment

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

LGTM

@estesp estesp merged commit e771443 into containerd:main Mar 11, 2022
@henry118 henry118 deleted the xfs branch March 11, 2022 17:34
@estesp estesp added the cherry-pick/1.6.x Change to be cherry picked to release/1.6 branch label Mar 14, 2022
@thaJeztah thaJeztah removed the cherry-pick/1.6.x Change to be cherry picked to release/1.6 branch label Mar 24, 2022
@thaJeztah thaJeztah added the cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch label Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-picked/1.6.x PR commits are cherry-picked into release/1.6 branch ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants