-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Improvements and docs for pj-on-kind.sh. #14355
Conversation
220c867
to
cc7b95e
Compare
config/pj-on-kind.sh
Outdated
|
||
../prow/pj-on-kind.sh "$@" | ||
$(dirname "${BASH_SOURCE[0]}")/../prow/pj-on-kind.sh "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! To promote readability you could tweak to something like:
dir="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
export CONFIG_PATH="$dir/../prow/config.yaml"
export JOB_CONFIG_PATH="$dir/jobs"
"$dir/../prow/pj-on-kind.sh" "$@"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation and code looks good! I made one suggestion that you can choose to take. Unhold at your leisure.
/lgtm
/hold
LGTM label has been added. Git tree hash: daff4f9f6bca3b87ba5ae2e025b46f8d8ef83abe
|
config/pj-on-kind.sh
Outdated
export CONFIG_PATH="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/../prow/config.yaml)" | ||
export JOB_CONFIG_PATH="$(readlink -f $(dirname "${BASH_SOURCE[0]}")/jobs)" | ||
export CONFIG_PATH="$(realpath $(dirname "${BASH_SOURCE[0]}")/../prow/config.yaml)" | ||
export JOB_CONFIG_PATH="$(realpath $(dirname "${BASH_SOURCE[0]}")/jobs)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
realpath
is not natively installed on mac FWIW.
instead this is more portable:
export JOB_CONFIG_PATH="$(realpath $(dirname "${BASH_SOURCE[0]}")/jobs)" | |
export JOB_CONFIG_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)/jobs" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'm surprised there isn't a portable command to canonicalize paths.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, cd "${path}" && pwd -P
is pretty much the only method doable on POSIX, unless you write your own binary against the C stdlib.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pwd -P
(-P
== "physical" will follow symlinks for the current working directory and is in all POSIX versions IIRC. -L
== logical will not)
prow/pj-on-kind.sh
Outdated
@@ -77,7 +82,7 @@ function ensureInstall() { | |||
# Install kind and set up cluster if not already done. | |||
if ! command -v kind >/dev/null 2>&1; then | |||
echo "Installing kind..." | |||
GO111MODULE="on" go get sigs.k8s.io/kind@v0.4.0 | |||
GO111MODULE="on" go get sigs.k8s.io/kind@v0.5.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v0.5.1
has minor fixes (windows mainly but...) and is otherwise compatible
prow/pj-on-kind.sh
Outdated
job_config="${JOB_CONFIG_PATH:-}" | ||
out_dir="${OUT_DIR:-/etc/prowjob-out/${job}}" | ||
kind_config="${KIND_CONFIG:-}" | ||
node_dir="${NODE_DIR:-/etc/kind-node}" # Any pod hostPath mounts should be under this dir to reach the true host via the kind node. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: this is sort of a mis-use of /etc
, this should probably under /var/
, /run
or /mnt
?
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard
./shrug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going off of https://cloud.google.com/container-optimized-os/docs/concepts/disks-and-filesystem
Looks like I can use /mnt/disks/kind-node
instead. Should I change /etc/prowjob-out
to /mnt/disks/prowjob-out
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So inside the kind node you should be able to do any path, I would do one of the listed ones or invent your own /prow just because these are fairly standardized.
On the host machine I'd think you'd write to something in Home owned by the user. /etc is for system config.
Why is this running on COS directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this running on COS directly?
I want the generated pod.yaml files to be suitable for use in a real cluster in addition to the kind cluster. I tried to use a path like /prow
, but COS doesn't allow that.
@@ -25,29 +25,34 @@ function main() { | |||
|
|||
# Generate PJ and Pod. | |||
mkpj "--config-path=${config}" "${job_config}" "--job=${job}" > "${PWD}/pj.yaml" | |||
mkpod --build-id=snowflake "--prow-job=${PWD}/pj.yaml" --local "--out-dir=/output/${job}" > "${PWD}/pod.yaml" | |||
mkpod --build-id=snowflake "--prow-job=${PWD}/pj.yaml" --local "--out-dir=${out_dir}" > "${PWD}/pod.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
might be better to write to a tempdir instead of PWD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used a tempdir initially, but I switched to using PWD so that the pj.yaml and pod.yaml can be easily inspected and modified. WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm yeah. I tend to avoid writing to PWD in tools but...
You could also tee them to the shell?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could also tee them to the shell?
Yeah that would work, but seems a little less convenient. pod.yaml and pj.yaml are in the .gitignore for config/
and prow/
at least so I think this is probably ok for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that tee would result in too much stdout clutter.
I would prefer it if it wrote to a tempdir and echoed something like Created foo/dir.yaml
. It's a nit, but this way I don't have to delete them to get them off my git status
readout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I fixed the .gitignore
so that the files will be ignored anywhere in the repo. Echoing the temp dir could work, but switching directories every time pj-on-kind.sh is run would be annoying when trying to make iterative changes to the pod.yaml and pj.yaml. It would also make it harder to modify the files (currently you can just comment out the file generation to use your own pj.yaml and pod.yaml, but using a temp dir would make this harder)
prow/pod-utils/gcs/upload.go
Outdated
@@ -174,6 +174,11 @@ type localFileWriter struct { | |||
|
|||
func (w *localFileWriter) Write(b []byte) (int, error) { | |||
if w.file == nil { | |||
if dir := path.Dir(w.filePath); dir != "." { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this check should be unecessary?
package main
import (
"os"
"fmt"
)
func main() {
fmt.Println(os.Mkdir(".", os.ModePerm))
fmt.Println(os.MkdirAll(".", os.ModePerm))
}
mkdir .: File exists
<nil>
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doc is incredibly helpful, especially as someone who started using this script to test things.
The script does the following: | ||
1. Installs [mkpj], [mkpod], and [Kind] if they are not found in the path. A [Kind] | ||
cluster named `mkpod` is created if one does not already exist. | ||
1. Uses [mkpj] to generate a YAML ProwJob CRD given job name, config, and git refs (if applicable). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is a CRD?
(CRD is mentioned earlier in the doc, but it would make the most sense to explain the acronym here)
for [prow.istio.io](https://prow.istio.io). | ||
To test ProwJobs for the [prow.k8s.io] instance use [`config/pj-on-kind.sh`](/config/pj-on-kind.sh). | ||
|
||
##### Example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
##### Example | |
##### Example | |
This command runs the Prow job [`pull-test-infra-yamllint`](https://github.com/kubernetes/test-infra/blob/170921984a34ca40f2763f9e71d6ce6e033dec03/config/jobs/kubernetes/test-infra/test-infra-presubmits.yaml#L94-L107) locally |
This explicitly calls out that the command is a Prow Job name, and that it's identical to the name of the configuration objects in config/jobs/...
@@ -25,29 +25,34 @@ function main() { | |||
|
|||
# Generate PJ and Pod. | |||
mkpj "--config-path=${config}" "${job_config}" "--job=${job}" > "${PWD}/pj.yaml" | |||
mkpod --build-id=snowflake "--prow-job=${PWD}/pj.yaml" --local "--out-dir=/output/${job}" > "${PWD}/pod.yaml" | |||
mkpod --build-id=snowflake "--prow-job=${PWD}/pj.yaml" --local "--out-dir=${out_dir}" > "${PWD}/pod.yaml" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that tee would result in too much stdout clutter.
I would prefer it if it wrote to a tempdir and echoed something like Created foo/dir.yaml
. It's a nit, but this way I don't have to delete them to get them off my git status
readout.
cc7b95e
to
d5d9154
Compare
New changes are detected. LGTM label has been removed. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cjwagner, clarketm The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
d5d9154
to
96aff6c
Compare
I think I've addressed everything. PTAL. |
/hold cancel |
96aff6c
to
8a6f613
Compare
prow/build_test_update.md
Outdated
and become visible to users by posting results to GitHub (if desired). Changes | ||
to existing jobs can be trialed on canary jobs. | ||
|
||
ProwJobs can also be manually triggered by generating a YAML ProwJob [CRD](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/) resource |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: "Custom Resource Definition resource"
8a6f613
to
8fad953
Compare
|
||
# Deploy pod and watch. | ||
echo "Applying pod to the mkpod cluster. Configure kubectl for the mkpod cluster with:" | ||
echo '> export KUBECONFIG="$(kind get kubeconfig-path --name="mkpod")"' | ||
echo '> export KUBECONFIG="$(kind get kubeconfig-path --name=mkpod)"' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly off topic but kubernetes-sigs/kind#850 for future direction there
code lgtm |
/cc @BenTheElder @clarketm @chases2