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

Updated lxc-local template #4368

Merged
merged 4 commits into from Dec 11, 2023
Merged

Updated lxc-local template #4368

merged 4 commits into from Dec 11, 2023

Conversation

desultory
Copy link
Contributor

I refactored the script to use functions, added more reasonable checks for existence of the metadata tarball, improved variable naming, added a "--no-dev" option to exclude /dev/ from tarballs (to make creating unprivileged containers easier)

@lxc-jenkins
Copy link

This pull request didn't trigger Jenkins as its author isn't in the allow list.

An organization member must perform one of the following:

  • To have this branch tested by Jenkins, use the "ok to test" command.
  • To have a one time test done, use the "test this please" command.

Those commands are simple Github comments of the format: "jenkins: COMMAND"

# shellcheck disable=SC2086
tar --anchored ${EXCLUDES} --numeric-owner -xpJf "${LXC_FSTREE}" -C "${LXC_ROOTFS}"

prepare_rootfs
Copy link
Member

Choose a reason for hiding this comment

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

What's this? That function isn't defined at this stage and also isn't part of the code being moved to the new unpack_rootfs function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll try to order the commits more properly next time. Doing this, I worked using my final product and tried to re-do the changes I made so they were associated with individual commits. In the future I will likely just commit one change at a time, in order.

Comment on lines 279 to 287
if tar Jxf "${LXC_METADATA}" -C "${LOCAL_TEMP}"; then
echo "Unpacked metadata file: ${LXC_METADATA}"
process_excludes
process_config
process_fstab
process_templates
else
echo "Unable to unpack metadata file: ${LXC_METADATA}" 2>&1
exit 1
Copy link
Member

Choose a reason for hiding this comment

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

Same comment as the other command, if you flip the if statement around, and just call exit 1 in the condition, then you can avoiding needing an else and save a level of indentation for most the function.

templates/lxc-local.in Outdated Show resolved Hide resolved
@@ -302,13 +312,27 @@ prepare_rootfs() {

unpack_rootfs() {
# Unpack the rootfs
echo "Unpacking the rootfs to: ${LXC_ROOTFS}"
if [ -n "${LXC_FSTREE}" ]; then
if [ -f "${LXC_FSTREE}" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

This one too

@@ -302,13 +312,27 @@ prepare_rootfs() {

unpack_rootfs() {
# Unpack the rootfs
echo "Unpacking the rootfs to: ${LXC_ROOTFS}"
if [ -n "${LXC_FSTREE}" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

This one too

Copy link
Member

@stgraber stgraber left a comment

Choose a reason for hiding this comment

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

Looking good overall, just some commit ordering to fix and a bunch of code style things that should result in more readable code.

@stgraber stgraber added the Incomplete Waiting on more information from reporter label Dec 10, 2023
@desultory
Copy link
Contributor Author

I think I've resolved most of these issues, please let me know if I missed any

@stgraber
Copy link
Member

jenkins: test this please

@desultory
Copy link
Contributor Author

I think I've added the missing signoff

@stgraber stgraber removed the Incomplete Waiting on more information from reporter label Dec 10, 2023
@lxc-jenkins
Copy link

Testsuite passed

unpack_metadata() {
# Unpack file that contains the container metadata
# If the file does not exist, just warn and continue.
if [ -n "${LXC_METADATA}" ]; then
Copy link
Member

Choose a reason for hiding this comment

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

Both of those if statements should still get the indent fix.
Making the function immediately return if the medata file isn't passed or if it doesn't exist.

@stgraber stgraber added the Incomplete Waiting on more information from reporter label Dec 11, 2023
@stgraber
Copy link
Member

Looking good, I'll do some history editing, likely squash everything into a single commit with a list of changes and fix a couple more nits I noticed by going through it again, then I'll merge.

Thanks for the work!

@desultory
Copy link
Contributor Author

Thanks for the review, I'm happy to contribute.

@stgraber
Copy link
Member

Ended up rebasing it down to 4 distinct commits that I think represent the changes in this PR pretty well.

@stgraber stgraber merged commit 959b419 into lxc:main Dec 11, 2023
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Incomplete Waiting on more information from reporter
Development

Successfully merging this pull request may close these issues.

None yet

3 participants