Skip to content

hack/env: Remove tmp volume - #16686

Closed
detiber wants to merge 1 commit into
openshift:masterfrom
detiber:tmpfs
Closed

detiber wants to merge 1 commit into
openshift:masterfrom
detiber:tmpfs

Conversation

@detiber

@detiber detiber commented Oct 4, 2017 •

Copy link
Copy Markdown
Contributor

hack/env: Remove tmp volume

  • Use host TMPDIR or pass in /tmp and /var/tmp from host instead of using a volume for /tmp
  • Add BASEVARTMPDIR variable and update tito to use it

Resolves: #15573
Removes the use of a volume for /tmp introduced here: #15770
Resolves: #16273

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: detiber
We suggest the following additional approver: stevekuznetsov

Assign the PR to them by writing /assign @stevekuznetsov in a comment when ready.

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-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 4, 2017
@detiber

detiber commented Oct 4, 2017

Copy link
Copy Markdown
Contributor Author

/assign @smarterclayton @jim-minter
/unassign @jhadvig

Comment thread hack/lib/build/environment.sh Outdated
set -o errexit
local release_image="${OS_BUILD_ENV_IMAGE}"
local additional_context="${OS_BUILD_ENV_DOCKER_ARGS:-}"
local additional_context="${OS_BUILD_ENV_DOCKER_ARGS:-} --tmpfs /tmp:exec"

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.

what default limits do /tmpfs have?

@detiber detiber Oct 4, 2017 •

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.

@smarterclayton this tells me it is rw, noexec, nosuid, size=65536k

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.

Inspecting a container run without specifying any mount options:

docker run --rm --tmpfs /tmp -it centos:7 mount | grep /tmp
tmpfs on /tmp type tmpfs (rw,nosuid,nodev,noexec,relatime,context="system_u:object_r:container_file_t:s0:c280,c857")

@jim-minter

Copy link
Copy Markdown
Contributor

Great :)
I guess a follow-up will be to remove references to OS_BUILD_ENV_TMP_VOLUME in openshift/aos-cd-jobs.

@detiber

detiber commented Oct 4, 2017

Copy link
Copy Markdown
Contributor Author

@jim-minter like this?

@jim-minter

Copy link
Copy Markdown
Contributor

@detiber ideal.

@mfojtik

mfojtik commented Oct 5, 2017

Copy link
Copy Markdown
Contributor

yey, this might actually fix a tons of etcd flakes :)

@jim-minter

Copy link
Copy Markdown
Contributor

On IRC @smarterclayton requested that hack/env respect $TMPDIR. It should use mktemp to create a dedicated directory under $TMPDIR (and clean up after) and bind mount that to /tmp in the container.
That way if $TMPDIR is running on a tmpfs on the host, so it is in the container -- and if not, not.

@detiber detiber changed the title hack/env: use tmpfs for /tmp instead of volume [WIP] hack/env: use tmpfs for /tmp instead of volume Oct 6, 2017
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 6, 2017
@detiber detiber changed the title [WIP] hack/env: use tmpfs for /tmp instead of volume hack/env: Remove tmp volume Oct 6, 2017
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 6, 2017
@detiber

detiber commented Oct 6, 2017

Copy link
Copy Markdown
Contributor Author

@jim-minter @stevekuznetsov @smarterclayton ptal, This now respects $TMPDIR if set, otherwise mounts in a subdirectory of both /tmp and /var/tmp. I also added a $BASEVARTMP var to hack/lib/util/environment.sh so that scripts can distinguish between fast/volatile temp space and slower/persistent temp space, with both getting overridden by $TMPDIR if set to conform as closely to both POSIX and FHS standards as possible.

@stevekuznetsov stevekuznetsov left a comment

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.

Overall seems reasonable to me

Comment thread hack/env Outdated

# NOTE: only committed code is built.
source "$(dirname "${BASH_SOURCE}")/lib/init.sh"
OS_TMP_ENV_SET=y source "$(dirname "${BASH_SOURCE}")/lib/init.sh"

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.

smells bad

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.

This is to prevent os::util::environment::setup_tmpdir_vars from being called, otherwise we are making a quite a few unnecessary temporary directories that are not used by hack/env.

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.

Are they not? The output from os::log::* for instance will go to _output/scripts/env/logs/script.log

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.

I've removed it with the latest push.

Comment thread hack/lib/build/environment.sh Outdated
local tmpdir_template="openshift-env-XXXXXXXXXX"
if [[ -n "${TMPDIR:-}" ]]; then
# If TMPDIR is specified, respect it
local container_tmpdir=$(mktemp -d --tmpdir ${tmpdir_template})

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 (local) with expressions that evaluate, like subshells

Comment thread hack/lib/build/environment.sh Outdated
# get the value of TMPDIR from the container
local container_tmpdir=$(docker inspect -f '{{range $index, $value := .Config.Env}}{{if eq (index (split $value "=") 0) "TMPDIR"}}{{index (split $value "=") 1}}{{end}}{{end}}' "${container}")
os::log::debug "Removing container tmp directory: ${container_tmpdir}"
rm -rf "${container_tmpdir}" || os::log::warning "Failed to remove tmpdir: ${container_tmpdir}"

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.

if ! rm -rf; then
    os::log::warning ...
fi

os::log::debug "Removing container tmp directories: ${container_tmpdirs[@]}"
for tmpdir in "${container_tmpdirs[@]}"; do
for tmpdir_prefix in /tmp /var/tmp; do
if [[ "${tmpdir}" == ${tmpdir_prefix}/* ]]; then

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.

mixed indents

@detiber

detiber commented Oct 9, 2017

Copy link
Copy Markdown
Contributor Author

/retest

- Use host TMPDIR or pass in /tmp and /var/tmp from host instead of
  using a volume for /tmp
- Add BASEVARTMPDIR variable and update tito to use it
@detiber

detiber commented Oct 9, 2017

Copy link
Copy Markdown
Contributor Author

/retest

1 similar comment
@detiber

detiber commented Oct 10, 2017

Copy link
Copy Markdown
Contributor Author

/retest

@detiber

detiber commented Oct 10, 2017

Copy link
Copy Markdown
Contributor Author

@smarterclayton @stevekuznetsov I believe all issues and comments have been addressed.

@openshift-ci-robot

Copy link
Copy Markdown

@detiber: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/openshift-jenkins/experimental/integration adaccdc link /test origin-it

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@detiber

detiber commented Oct 12, 2017

Copy link
Copy Markdown
Contributor Author

@stevekuznetsov @smarterclayton anything else needed to get this in the queue?

@stevekuznetsov

Copy link
Copy Markdown
Contributor

This LGTM -- @smarterclayton any last comments?

@bparees

bparees commented Nov 3, 2017

Copy link
Copy Markdown
Contributor

this is supposedly a fix to one of our top flakes #16273

@mfojtik since your team owns the flake, can you figure out how to get this PR merged?

@openshift-merge-robot

Copy link
Copy Markdown
Contributor

@detiber PR needs rebase

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 10, 2017
@mfojtik

mfojtik commented Dec 5, 2017

Copy link
Copy Markdown
Contributor

@detiber can you please rebase?

@stevekuznetsov

Copy link
Copy Markdown
Contributor

Superseded by #18242

/close

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. 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.

9 participants