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

Use the same way to create tmp directories at hacks #116044

Closed
wants to merge 1 commit into from

Conversation

mhmxs
Copy link
Contributor

@mhmxs mhmxs commented Feb 24, 2023

What type of PR is this?

This change eliminates different ways to create temp directories in scripts at hack

/kind cleanup
/sig node
/release-note-none

What this PR does / why we need it:

It makes sense to use the same method for temp folder creation.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?


Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:


@k8s-ci-robot k8s-ci-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. sig/node Categorizes an issue or PR as relevant to SIG Node. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 24, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @mhmxs. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@k8s-ci-robot k8s-ci-robot added the needs-priority Indicates a PR lacks a `priority/foo` label and requires one. label Feb 24, 2023
@mhmxs
Copy link
Contributor Author

mhmxs commented Feb 24, 2023

/release-note-none

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Feb 24, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Feb 24, 2023

/triage accepted
/priority important-longterm

@k8s-ci-robot k8s-ci-robot added triage/accepted Indicates an issue or PR is ready to be actively worked on. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. and removed needs-triage Indicates an issue or PR lacks a `triage/foo` label and requires one. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Feb 24, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Feb 24, 2023

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Feb 24, 2023
@bart0sh bart0sh added this to Needs Reviewer in SIG Node PR Triage Feb 24, 2023
@mhmxs
Copy link
Contributor Author

mhmxs commented Feb 26, 2023

/retest

3 similar comments
@mhmxs
Copy link
Contributor Author

mhmxs commented Feb 26, 2023

/retest

@mhmxs
Copy link
Contributor Author

mhmxs commented Feb 26, 2023

/retest

@mhmxs
Copy link
Contributor Author

mhmxs commented Feb 26, 2023

/retest

@k8s-ci-robot k8s-ci-robot added sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. area/provider/gcp Issues or PRs related to gcp provider sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. labels Feb 27, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Apr 11, 2023

/retest

@bart0sh
Copy link
Contributor

bart0sh commented Apr 11, 2023

@mhmxs If you still need this PR then please rebase, if not, please close the PR.

@k8s-ci-robot k8s-ci-robot added do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Apr 18, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Apr 18, 2023

/retest

@bart0sh
Copy link
Contributor

bart0sh commented Apr 18, 2023

@mhmxs please, squash your commits. This should help to get rid of do-not-merge/contains-merge-commits label and proceed further with this pr.

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/contains-merge-commits Indicates a PR which contains merge commits. label Apr 18, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Apr 18, 2023

/retest

@@ -27,7 +27,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh"

# create a nice clean place to put our new vendor tree
mkdir -p "${KUBE_ROOT}/_tmp"
_tmpdir="$(mktemp -d "${KUBE_ROOT}/_tmp/kube-vendor.XXXXXX")"
_tmpdir="$(kube::realpath "$(mktemp -d "${KUBE_ROOT}/_tmp/$(basename "$0").XXXXXX")")"
Copy link
Contributor

Choose a reason for hiding this comment

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

This is repeated everywhere. Would it make sense to wrap it into a function, e.e. kube::mktemp or something similar?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Make sense, I just followed @thockin 's instructions.

@@ -27,7 +27,7 @@ if [[ "${KUBERNETES_PROVIDER:-gce}" != "gce" ]]; then
fi

KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
source "${KUBE_ROOT}/hack/lib/util.sh"
source "${KUBE_ROOT}/hack/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.

How this kind of changes are related to creating tmp directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bart0sh
Because kube::realpath lives at init.sh and init includes util, so made sense to include init everywhere.

kube::realpath() {

Copy link
Contributor

Choose a reason for hiding this comment

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

Makes sense to me. Thank you for the explanations!

Copy link
Member

Choose a reason for hiding this comment

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

See above comment - let's not make changes (especially under cluster) unless we REALLY know why.

@bart0sh bart0sh moved this from Waiting on Author to Needs Reviewer in SIG Node PR Triage Apr 18, 2023
@bart0sh
Copy link
Contributor

bart0sh commented Apr 18, 2023

/assign @pacoxu @SergeyKanzhelev

@k8s-ci-robot
Copy link
Contributor

@mhmxs: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-kubernetes-local-e2e ed8b4b7 link false /test pull-kubernetes-local-e2e

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.

@pacoxu
Copy link
Member

pacoxu commented Apr 19, 2023

/cc @thockin

@mhmxs
Copy link
Contributor Author

mhmxs commented Apr 19, 2023

@bart0sh Seems local-e2e job fails all the time. I don't understand how the errors are relevant to my change, so i have to investigate more. I'm a newbie here, so I need some time to understand what is going on.

@bart0sh
Copy link
Contributor

bart0sh commented Apr 20, 2023

@mhmxs

Seems local-e2e job fails all the time.

Did you try to rebase on top of the latest master? It might help if the failure is caused by something else.

Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

Breaking this up would help reviewability a lot. 1 commit, 1 idea.

@@ -24,7 +24,7 @@ KUBE_ROOT=$(cd "$(dirname "${BASH_SOURCE[0]}")"/.. && pwd)

DEFAULT_KUBECONFIG="${HOME:-.}/.kube/config"

source "${KUBE_ROOT}/hack/lib/util.sh"
source "${KUBE_ROOT}/hack/lib/init.sh"
Copy link
Member

Choose a reason for hiding this comment

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

init.sh has a lot of stuff, including changin global vars - I don't think I would make this sort change unless you know why you need to

@@ -27,7 +27,7 @@ if [[ "${KUBERNETES_PROVIDER:-gce}" != "gce" ]]; then
fi

KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
source "${KUBE_ROOT}/hack/lib/util.sh"
source "${KUBE_ROOT}/hack/lib/init.sh"
Copy link
Member

Choose a reason for hiding this comment

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

See above comment - let's not make changes (especially under cluster) unless we REALLY know why.

# If the master image is not set, we use the latest GCI image.
# Otherwise, we respect whatever is set by the user.
export MASTER_IMAGE=${KUBE_GCE_MASTER_IMAGE:-${GCI_VERSION}}
: "${GCI_VERSION?= required}"
Copy link
Member

@thockin thockin Apr 21, 2023

Choose a reason for hiding this comment

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

Even I don't know this syntax. This seems unrelated to the topic of this PR and should at least be in a different commit if not a whole new PR.

Everything under cluster/ is overly brittle and needs extra attention

ETCD_VERSION=${ETCD_VERSION:-3.5.7}
ETCD_HOST=${ETCD_HOST:-127.0.0.1}
ETCD_PORT=${ETCD_PORT:-2379}
ETCD_VERSION="${ETCD_VERSION:-3.5.7}"
Copy link
Member

Choose a reason for hiding this comment

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

Can you break quoting changes out to a separate commit

TMP_DIR=${TMP_DIR:-$(kube::realpath "$(mktemp -d -t "$(basename "$0").XXXXXX")")}
LOG_SPEC="${LOG_SPEC:-""}"
LOG_DIR="${LOG_DIR:-"/tmp"}"
TMP_DIR="${TMP_DIR:-$(kube::realpath "$(mktemp -d -t "$(basename "$0").XXXXXX")")}"
Copy link
Member

Choose a reason for hiding this comment

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

Quoting changes to a different commit, please?

@@ -19,7 +19,7 @@ set -o nounset
set -o pipefail

KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/../..
source "${KUBE_ROOT}/hack/lib/util.sh"
source "${KUBE_ROOT}/hack/lib/init.sh"
Copy link
Member

Choose a reason for hiding this comment

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

As above - I'd like to know why?

@@ -36,7 +36,7 @@ skip=${SKIP-"\[Flaky\]|\[Slow\]|\[Serial\]"}
# Currently, parallelism only affects when REMOTE=true. For local test,
# ginkgo default parallelism (cores - 1) is used.
parallelism=${PARALLELISM:-8}
artifacts="${ARTIFACTS:-"/tmp/_artifacts/$(date +%y%m%dT%H%M%S)"}"
artifacts="${ARTIFACTS:-$(kube::realpath "$(mktemp -d -t "$(basename "$0").XXXXXX")")/_artifacts/$(date +%y%m%dT%H%M%S)}"
Copy link
Member

Choose a reason for hiding this comment

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

If we are going to repeat the pattern everywhere, why not capture it as

function kube::util::mktemp-dir() {
    local script="$0"
    if [[ -n "$1" ]]; then
        script="$1"
    fi
    base="$(basename "${script}")"
    mktemp -d -t "${base}.XXXXXX"
}

@thockin
Copy link
Member

thockin commented Apr 21, 2023

It's also uncclear to me why readlink and realpath are in init and not util (and named as such)

@bart0sh bart0sh moved this from Needs Reviewer to Waiting on Author in SIG Node PR Triage Apr 25, 2023
@k8s-ci-robot
Copy link
Contributor

PR needs rebase.

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.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 5, 2023
@bart0sh
Copy link
Contributor

bart0sh commented May 11, 2023

@mhmxs please address remaining comments to go further with this PR, thanks.

@mhmxs
Copy link
Contributor Author

mhmxs commented May 11, 2023

@mhmxs please address remaining comments to go further with this PR, thanks.

@bart0sh I haven't forget, but the suggestion is to cut this PR into 2-3 separated ones, which makes sense, because it helps identify which change broke e2e testing. So I think we should close this one, and let me split it.

@mhmxs mhmxs closed this May 11, 2023
SIG Node PR Triage automation moved this from Waiting on Author to Done May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/provider/gcp Issues or PRs related to gcp provider area/test cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. priority/important-longterm Important over the long term, but may not be staffed and/or may need multiple releases to complete. release-note-none Denotes a PR that doesn't merit a release note. sig/api-machinery Categorizes an issue or PR as relevant to SIG API Machinery. sig/cloud-provider Categorizes an issue or PR as relevant to SIG Cloud Provider. sig/instrumentation Categorizes an issue or PR as relevant to SIG Instrumentation. sig/node Categorizes an issue or PR as relevant to SIG Node. sig/scalability Categorizes an issue or PR as relevant to SIG Scalability. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. triage/accepted Indicates an issue or PR is ready to be actively worked on.
Development

Successfully merging this pull request may close these issues.

None yet

6 participants