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

librarian-puppet install with destructive mode doesn't make atomic changes #73

Open
lelutin opened this issue Sep 2, 2019 · 1 comment

Comments

@lelutin
Copy link

lelutin commented Sep 2, 2019

Currently, librarian-puppet install when used with the destructive mode does not use an atomic action when replacing the install_path. As seen in the install action0, it starts by removing everything and creating a new empty directory and then recreates all of the modules.

This means that during the whole time that librarian-puppet is recreating all of the module directories, lots of things are missing! If one is using librarian-puppet on the puppetmaster, this can impact puppet clients that start their run during this period: some modules are missing entirely, causing errors, and in some more dire cases some things can end up being modified on the client because of the missing bits.

I think librarian-puppet can do a bit better. one method would be to create a temporary directory right beside the install_path, place all of the files in that temp dir, and then once everything is done and no errors happened, rename the current install_path to take it out of the way, and rename the temp dir as the new install_path. This renaming operation would make the change atomic. once the rename is done, the install action could remove the tmp dir.

@anarcat
Copy link

anarcat commented Oct 4, 2019

A workaround is to deploy librarian stuff to another directory and then swap the directories, something like this:

https://redmine.koumbit.net/projects/git-hooks/repository/revisions/master/entry/post-receive-puppet-r10k#L57

The magic code is:

sudo "${SCRIPT_DIR}"/swap_puppet_branches "$TMPDIR" "$DEPLOYDIR" "$GRAVEYARD_DIR" 

Which basically swaps the temporary deployment directory with the temp directory, moving the old deployment directory to a "graveyard".

Earlier, there's also a hack to use a shared cache for librarian:

                git clone --branch="$branch" "${ORIG_GIT_DIR}" "$TMPDIR"
                if [ ! -z "${LIBRARIAN_TMP_DIR}" ] ; then
                    mkdir -p "${LIBRARIAN_TMP_DIR}"
                    ln -s "${LIBRARIAN_TMP_DIR}" '.tmp'
                    umask 002 '.tmp'
                fi

It would be useful to have a setting to tell librarian where to find its cache to avoid such a hack.

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

No branches or pull requests

2 participants