Skip to content
This repository was archived by the owner on Jan 8, 2024. It is now read-only.

[WIP] Use custom cache dir for zypper up/patch commands#151

Open
parlt91 wants to merge 1 commit intoSUSE:masterfrom
parlt91:zyppCacheDir
Open

[WIP] Use custom cache dir for zypper up/patch commands#151
parlt91 wants to merge 1 commit intoSUSE:masterfrom
parlt91:zyppCacheDir

Conversation

@parlt91
Copy link
Contributor

@parlt91 parlt91 commented Jun 11, 2018

Previously the default zypper cache directory was used for
update/patch commands. This cache dir was emptied afterwards.
If a user already had data from previous zypper commands in the
cache, the data would be lost after a zypper-docker up/patch.

Now a custom directory is used for the zypper-docker commands
that will be deleted before the updated image is created.
This way the default zypper cache dir will be preserved.

Signed-off-by: Pascal Arlt parlt@suse.com

@parlt91 parlt91 requested a review from vrothberg June 11, 2018 14:57
Copy link
Contributor

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

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

In addition to the small nitpick, can you add an integration test for this one?

A (hopefully) generic way would be:

  • Pull an opensuse image, clean the zypper cache and create a dummy file in the zypper's default cache.

  • Run some zypper-docker command that uses the cache on the container from the step above.

  • Then check if the dummy file is present in the created image.

I didn't test it, but I am pretty sure it'll work.

cmd := formatZypperCommand(fmt.Sprintf("%s ref", cacheDir), fmt.Sprintf("%s -n %v", cacheDir, zypperCmd))
cmd = cmdWithFlags(cmd, ctx, boolFlags, toIgnore)
cmd += " && " + clean
cmd = makeTemp + " && " + cmd + " && " + rmTemp
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add some comments. It's really hard to read, which is not your fault (given all the function calls), but some explanations would be a big help.

@vrothberg
Copy link
Contributor

An even better way would be to create a hash of zypper's cache directory (see https://stackoverflow.com/questions/545387/linux-compute-a-single-hash-for-a-given-folder-contents). This way, we can be really sure that nothing has changed.

Previously the default zypper cache directory was used for
update/patch commands. This cache dir was emptied afterwards.
If a user already had data from previous zypper commands in the
cache, the data would be lost after a zypper-docker up/patch.

Now a custom directory is used for the zypper-docker commands
that will be deleted before the updated image is created.
This way the default zypper cache dir will be preserved.

Signed-off-by: Pascal Arlt <parlt@suse.com>
@parlt91
Copy link
Contributor Author

parlt91 commented Jun 12, 2018

This PR is currently blocked due to a bug with zypper: openSUSE/zypper#180

@parlt91 parlt91 changed the title Use custom cache dir for zypper up/patch commands [WIP] Use custom cache dir for zypper up/patch commands Jun 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants