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

pipeline-utils: add registry_login() and prep_container_storage() #309

Merged
merged 2 commits into from
Sep 25, 2018

Conversation

miabbott
Copy link
Member

@miabbott miabbott commented Sep 21, 2018

This adds two utility functions for logging into a container registry and setting up container storage inside a container. The latter allows us to pull container images from inside the pipeline container.

Split out from #308

@openshift-ci-robot openshift-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 21, 2018
// re-implementation of some functionality from scripts/pull-mount-oscontainer
// sets up local container storage so the pipeline can pull container images
// from inside another container
def prep_container_storage(hostStorage, localStorage) {
Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm...maybe I chose the wrong names here...maybe they should be oldStorage and newStorage?

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 using hostStorage and containerStorage? That may be a bit clearer.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think hostStorage was a mistake on my part.

As far as I can tell, the host container storage isn't ever mounted into the assembler container (as of now), so we are really just deleting the "typical" location of the container storage in the container.

For example,scripts/pull-mount-oscontainer deletes /var/lib/containers in its container, then bind mounts something like $WORKSPACE/containers to /var/lib/containers. https://github.com/openshift/os/blob/master/scripts/pull-mount-oscontainer#L21-L23)

I think something more accurate would be oldContainerStorage and newContainerStorage

What do you think?

Copy link
Member

Choose a reason for hiding this comment

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

I actually discovered that podman/buildah support a --root argument and have been using that in coreos/coreos-assembler#90

@miabbott
Copy link
Member Author

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 24, 2018
@miabbott
Copy link
Member Author

I'd like to improve this slightly to verify the proposed mount point isn't an overlay filesystem

This adds a simple function to login to a container registry using
username, password, and registry name as args.
@miabbott miabbott force-pushed the extra_util_functions branch from 829caa6 to ed1d95e Compare September 25, 2018 17:31
@miabbott
Copy link
Member Author

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Sep 25, 2018
@@ -139,6 +139,27 @@ def sh_capture(cmd) {
return sh(returnStdout: true, script: cmd).trim()
}

def registry_login(username, password, registry) {
sh "podman login -u '${username}' -p '${password}' ${registry}"
Copy link
Member

Choose a reason for hiding this comment

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

Note: I believe this will populate ${XDG_RUNTIME_DIR}/containers/auth.json (EG: /run/user/1000/containers/auth.json). Let's make sure this file doesn't get shown via the output or links.

Copy link
Member Author

Choose a reason for hiding this comment

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

That should be outside the $WORKSPACE, so the JSON shouldn't get archived anywhere. And there's no output from the podman login except Login Succeeded!

For example, here -

podman login -u "${username}" -p "${password}" ${registry}

...looks like this from the pipeline logs

+ set +x
podman login -u unused -p <password> registry.svc.ci.openshift.org
Login Succeeded!

echo 'Must supply non-overlay location'
exit 1
fi
rm -rf \$container_storage && mkdir -p \$container_storage
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor nit, \${container_storage} is more consistent

Copy link
Member Author

Choose a reason for hiding this comment

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

That will work for shell variables?

Copy link
Contributor

Choose a reason for hiding this comment

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

This re-implements some of what is contained in
`scripts/pull-mount-oscontainer` to allow parts of the pipeline to
pull container images from inside another container.
@miabbott miabbott force-pushed the extra_util_functions branch from ed1d95e to e32f240 Compare September 25, 2018 19:00
@miabbott
Copy link
Member Author

@yuqi-zhang pushed a new commit with your suggested changes

Copy link
Member

@ashcrow ashcrow left a comment

Choose a reason for hiding this comment

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

Will defer to @yuqi-zhang for merge.

@yuqi-zhang
Copy link
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 25, 2018
@openshift-merge-robot openshift-merge-robot merged commit defa04c into openshift:master Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants