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

hack/env: Remove tmp volume #16686

Closed
wants to merge 1 commit into from
Closed

hack/env: Remove tmp volume #16686

wants to merge 1 commit into from

Conversation

detiber
Copy link

@detiber detiber commented Oct 4, 2017

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
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.

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
Copy link
Author

detiber commented Oct 4, 2017

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

@@ -9,7 +9,7 @@
function os::build::environment::create() {
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
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?

Copy link
Author

@detiber detiber Oct 4, 2017

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
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
Contributor

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

@detiber
Copy link
Author

detiber commented Oct 4, 2017

@jim-minter like this?

@jim-minter
Copy link
Contributor

@detiber ideal.

@mfojtik
Copy link
Contributor

mfojtik commented Oct 5, 2017

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

@jim-minter
Copy link
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
Copy link
Author

detiber commented Oct 6, 2017

@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.

Copy link
Contributor

@stevekuznetsov stevekuznetsov left a comment

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

hack/env Outdated
@@ -31,12 +31,12 @@
#

# 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
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
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
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
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.

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
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

# 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
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
Contributor

Choose a reason for hiding this comment

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

mixed indents

@detiber
Copy link
Author

detiber commented Oct 9, 2017

/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
Copy link
Author

detiber commented Oct 9, 2017

/retest

1 similar comment
@detiber
Copy link
Author

detiber commented Oct 10, 2017

/retest

@detiber
Copy link
Author

detiber commented Oct 10, 2017

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

@openshift-ci-robot
Copy link

@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.

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
Copy link
Author

detiber commented Oct 12, 2017

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

@stevekuznetsov
Copy link
Contributor

This LGTM -- @smarterclayton any last comments?

@bparees
Copy link
Contributor

bparees commented Nov 3, 2017

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
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
Copy link
Contributor

mfojtik commented Dec 5, 2017

@detiber can you please rebase?

@stevekuznetsov
Copy link
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