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

cleanup: regex not being evaluated in quoted expression #605

Merged
merged 3 commits into from
Jul 31, 2024

Conversation

ryansavino
Copy link
Contributor

Cleanup never happening for these directories.
Regex not evaluated in the rm statement.

@ryansavino
Copy link
Contributor Author

@sctb512 @imeoer Not sure why the checks and tests are failing. Anything I need to look at here?

Copy link

@larrydewey larrydewey left a comment

Choose a reason for hiding this comment

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

Looks good to me. Just a small adjustment to the quoting. Mostly a nit

misc/snapshotter/snapshotter.sh Outdated Show resolved Hide resolved
misc/snapshotter/snapshotter.sh Outdated Show resolved Hide resolved
misc/snapshotter/snapshotter.sh Outdated Show resolved Hide resolved
misc/snapshotter/snapshotter.sh Outdated Show resolved Hide resolved
@apostasie
Copy link
Contributor

@sctb512 @imeoer Not sure why the checks and tests are failing. Anything I need to look at here?

Some of the CI bustages are being fixed here: #606 - so, as soon as this is merged, if you could rebase, that would be nice.

kube e2e kubeconf test will still be bust though - needs more work to fix.

@@ -141,14 +141,14 @@ EOF
"${CONTAINER_RUNTIME_CONFIG}".bak
else
sed -i '/\[plugins\..*\.containerd\]/a\disable_snapshot_annotations = false' \
"${CONTAINER_RUNTIME_CONFIG}".bak
"${CONTAINER_RUNTIME_CONFIG}".bak
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you make this one and the change on line 151 to follow what's in the line 148?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

bash -c "rm -f ${NYDUS_BINARY_DIR}/nydus*"
bash -c "rm -rf ${NYDUS_CONFIG_DIR}/*"
bash -c "rm -rf ${SNAPSHOTTER_SCRYPT_DIR}/*"
bash -c "rm -rf ${NYDUS_LIB_DIR}/*"
Copy link

Choose a reason for hiding this comment

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

This doesn't change anything with respect to pathname expansion : ${NYDUS_LIB_DIR}/* is expanded all the same above and in the original code. The Regex not evaluated in the rm statement. sentence in the description is thus incorrect.

The problem is that the result of the expansion is passed to rm as a single argument. This causes rm to look for an file that doesn't exist if this argument contains several items, e.g. /path/to/nydus/lib/dir/FOO /path/to/nydus/lib/dir/BAR.

Also, bash -c "" doesn't buy anything here, you could just make it :

Suggested change
bash -c "rm -rf ${NYDUS_LIB_DIR}/*"
rm -rf ${NYDUS_LIB_DIR}/*

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Even this command wasn't working during my testing. It had to do with the fact that the script is required to run as sudo.

I found this link, which I think helps explain the issue:
https://superuser.com/questions/980472/remove-files-from-a-root-owned-directory-using-sudo-with-wildcards

Copy link

Choose a reason for hiding this comment

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

The link above would explain the issue if you needed to do something like :

    sudo bash -c "rm -rf ${NYDUS_LIB_DIR}/*"

as the top level shell running the script might not be able to access the content of the ${NYDUS_LIB_DIR}/ directory.

If the script itself is run with sudo then it will be able to access the directory content and honor the pathname expansion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think I understand now. Fixed it.

Cleanup never happening for these directories.
Regex needed to be passed outside of quotes.
Quoted variable references only.

Signed-Off-By: Ryan Savino <ryan.savino@amd.com>
When no containerd-nydus-grpc pid is found, script will exit on this line.

Signed-Off-By: Ryan Savino <ryan.savino@amd.com>
Signed-Off-By: Ryan Savino <ryan.savino@amd.com>
misc/snapshotter/snapshotter.sh Outdated Show resolved Hide resolved
misc/snapshotter/snapshotter.sh Outdated Show resolved Hide resolved
misc/snapshotter/snapshotter.sh Outdated Show resolved Hide resolved
Copy link
Contributor

@ChengyuZhu6 ChengyuZhu6 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
Collaborator

@imeoer imeoer 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!

@imeoer imeoer merged commit 2735f53 into containerd:main Jul 31, 2024
12 of 16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants