Skip to content

hack/env: mount a volume for /tmp - #15770

Merged
openshift-merge-robot merged 1 commit into
openshift:masterfrom
detiber:tmpdir
Aug 18, 2017
Merged

openshift-merge-robot merged 1 commit into
openshift:masterfrom
detiber:tmpdir

Conversation

@detiber

@detiber detiber commented Aug 14, 2017 •

Copy link
Copy Markdown
Contributor

Somewhat related to: #15573

This change creates and mounts a volume to use for /tmp when running hack/env

@openshift-merge-robot openshift-merge-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 14, 2017
@detiber

detiber commented Aug 14, 2017

Copy link
Copy Markdown
Contributor Author

/assign @stevekuznetsov @smarterclayton

@detiber

detiber commented Aug 14, 2017

Copy link
Copy Markdown
Contributor Author

/unassign @jhadvig @fabianofranz

@detiber

detiber commented Aug 14, 2017

Copy link
Copy Markdown
Contributor Author

@stevekuznetsov grr, it looks like hack/build-rpm-release and other scripts run make clean before copying the tito artifacts over.

@smarterclayton

Copy link
Copy Markdown
Contributor

TMPDIR is supposed to be set by the automation to wherever tmpdir content should go. Changing where it is in the image is not necessary.

@detiber

detiber commented Aug 14, 2017

Copy link
Copy Markdown
Contributor Author

@stevekuznetsov latest update instead just updates the release image TMPDIR to be $WORKDIR/tmp

Testing this now, but I am a bit worried that there may be some files left over that would cause problems with some of the verify tests.

Comment thread images/release/golang-1.8/Dockerfile Outdated
git config --system user.email [email protected]

WORKDIR /go/src/github.com/openshift/origin
WORKDIR $WORKDIR

@smarterclayton smarterclayton Aug 14, 2017 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure why you would parameterize workdir - that's not something that images expect to change, and we already have knobs for this.

I guess I'd ask - why are you changing the images?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The main reason I did this was to put WORKDIR to avoid repetition with putting TMPDIR under WORKDIR, since WORKDIR is the directory where the volume is mounted.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Currently, BASETMPDIR is set to "${TMPDIR:-/tmp}/openshift/${sub_dir}", which when using hack/env is currently being set by the release image as /openshifttmp.

Updating the images seemed like the path of least resistance without causing changes to users running the scripts locally that may not want their TMPDIR location overriden.

@detiber
detiber force-pushed the tmpdir branch 2 times, most recently from f2055c0 to 3e9a8bf Compare August 15, 2017 01:57
@openshift-merge-robot openshift-merge-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 15, 2017
@smarterclayton

smarterclayton commented Aug 15, 2017 via email

Copy link
Copy Markdown
Contributor

@detiber

detiber commented Aug 15, 2017

Copy link
Copy Markdown
Contributor Author

@smarterclayton are you suggesting a second volume for the tmpdir or just removing the setting of TMPDIR from the release image and setting it in hack/lib/build/environment instead?

@openshift-merge-robot openshift-merge-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 15, 2017
@detiber

detiber commented Aug 15, 2017

Copy link
Copy Markdown
Contributor Author

@smarterclayton updated to set TMPDIR within hack/env rather than in the image, ptal.

Comment thread hack/lib/build/environment.sh Outdated
tar -cf - "${excluded[@]}" . | docker cp - "${container}:${workingdir}"
fi

local tmpdir="$(docker inspect -f '{{ range .Config.Env }}{{ if eq (index (split . "=") 0) "TMPDIR" }}{{ index (split . "=") 1 }}{{ end }}{{end}}' ${container})"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why does TMPDIR have to exist? I'm really confused here.

The original reason TMPDIR in the image is /openshifttmp is because old versions of docker set a 64mb limit on it, which is far too small for tmp output. If that's fixed in docker now, we can simply remove that setting and restore it to the default of /tmp.

If there is still a limit, then we want to mount a reasonable TMPDIR in, in which case we don't care where on the FS is inside the container or what the container thinks the dir is. We just want to create a volume and mount it to /tmp and set TMPDIR to /tmp. No need to do this reading, or to make it fall within _output.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why does TMPDIR have to exist? I'm really confused here.

In this case, simply because I am trying to set it under the existing volume that we create and mount at $workingdir

The original reason TMPDIR in the image is /openshifttmp is because old versions of docker set a 64mb limit on it, which is far too small for tmp output. If that's fixed in docker now, we can simply remove that setting and restore it to the default of /tmp.

It looks like this is no longer the case, but it appears that /tmp exists on the container fs, which would still have the potential of running out of disk space, since the default is 10G.

If there is still a limit, then we want to mount a reasonable TMPDIR in, in which case we don't care where on the FS is inside the container or what the container thinks the dir is. We just want to create a volume and mount it to /tmp and set TMPDIR to /tmp. No need to do this reading, or to make it fall within _output.

Sounds good, I'll go ahead and fix this up to just create a separate volume and bind mount it to /tmp

@openshift-merge-robot openshift-merge-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Aug 16, 2017
@detiber detiber changed the title move BASETMPDIR under BASEOUTPUTDIR hack/env: mount a volume for /tmp Aug 16, 2017
Comment thread hack/lib/build/environment.sh Outdated

# Create the volume for tmp
os::log::debug "Creating tmp volume ${OS_BUILD_ENV_VOLUME}-tmp"
docker volume create --name "${OS_BUILD_ENV_VOLUME}-tmp" > /dev/null

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we care to reuse these so there isn't churn?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

yeah, reuse would be preferred

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ok, I'll update to re-use

@detiber

detiber commented Aug 16, 2017

Copy link
Copy Markdown
Contributor Author

@stevekuznetsov @smarterclayton I think this should be ready to go now.

Comment thread hack/lib/build/environment.sh Outdated
os::log::debug "Creating volume ${OS_BUILD_ENV_TMP_VOLUME}"
docker volume create --name "${OS_BUILD_ENV_TMP_VOLUME}" > /dev/null
fi
additional_context+=" -v ${OS_BUILD_ENV_TMP_VOLUME}:/tmp"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Indentation oopsie?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed, fixed.

Comment thread hack/lib/build/environment.sh Outdated
}
readonly -f os::build::environment::withsource

function os::build::environment::volume_name(){

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we put spaces between () and {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

Comment thread hack/lib/build/environment.sh Outdated

if docker volume inspect "${volume}" >/dev/null 2>&1; then
os::log::debug "Removing volume ${volume}"
docker volume rm "${volume}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is this going to spit out the volume name on success and if so >/dev/null

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Indeed and it looks like it did previously as well, fixed now.

Comment thread hack/lib/build/environment.sh Outdated
fi
volume="$( echo "${volume}" | tr '[:upper:]' '[:lower:]' )"
export OS_BUILD_ENV_VOLUME="${volume}"
export OS_BUILD_ENV_VOLUME="$( os::build::environment::volume_name "origin-build" "${commit}" "${OS_BUILD_ENV_REUSE_VOLUME:-}" )"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't mix scoping statements and subshells.

export VAR; VAR="$()"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@stevekuznetsov

Copy link
Copy Markdown
Contributor

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Aug 17, 2017
@openshift-merge-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: detiber, stevekuznetsov

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these OWNERS Files:

You can indicate your approval by writing /approve in a comment
You can cancel your approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 17, 2017
@detiber

detiber commented Aug 17, 2017

Copy link
Copy Markdown
Contributor Author

/test cmd

@detiber

detiber commented Aug 17, 2017

Copy link
Copy Markdown
Contributor Author

Looks like cmd test flake is related to: #13944

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

/test all [submit-queue is verifying that this PR is safe to merge]

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

Automatic merge from submit-queue (batch tested with PRs 13379, 15770, 15832, 15839, 15746)

@openshift-merge-robot
openshift-merge-robot merged commit 7de869f into openshift:master Aug 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants