-
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
generate DRA job configs from a Jinja template #34010
base: master
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
7c3a83c
to
2f75bbd
Compare
d030275
to
c5999e8
Compare
config/jobs/kubernetes/sig-node/dynamic-resource-allocation-canary.ini
Outdated
Show resolved
Hide resolved
# on a kind cluster with containerd updated to a version with CDI support. | ||
# | ||
# Compared to ci-kind-dra, this one enables all DRA-related features. | ||
[ci-kind-dra-all] |
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.
Can we make it so that we have common settings for normal periodics, normal presubmits, and canary presubmits?
There's still going to be a lot of duplication if we have to have three copies of this section and the ones below.
The same applies to the actual .jinja
template. The entries in the periodics
and presubmits
should be built from a single source.
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.
Thank you. This makes sense. Will do.
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.
Updated. Now gen.py generates 3 files: dynamic-resource-allocation-canary.yaml, dynamic-resource-allocation-pull.yaml and dynamic-resource-allocation-ci.yaml from dynamic-resource-allocation.conf and dynamic-resource-allocation.jinja
PTAL.
3259e4d
to
499379c
Compare
499379c
to
2e1e253
Compare
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 very promising.
How to solve indention was my biggest concern when thinking about how to use Jinja. I am not sure whether this is addressed here (need to check test results).
config/jobs/kubernetes/sig-node/dynamic-resource-allocation.conf
Outdated
Show resolved
Hide resolved
config/jobs/kubernetes/sig-node/dynamic-resource-allocation.conf
Outdated
Show resolved
Hide resolved
config/jobs/kubernetes/sig-node/dynamic-resource-allocation.jinja
Outdated
Show resolved
Hide resolved
testgrid-tab-name: {{job_name}} | ||
description: {{description}} | ||
testgrid-alert-email: {{testgrid_alert_email}} | ||
fork-per-release: "true" |
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.
Canaries shouldn't get forked.
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.
done
config/jobs/kubernetes/sig-node/dynamic-resource-allocation.jinja
Outdated
Show resolved
Hide resolved
@pohly @kannon92 @SergeyKanzhelev @haircommander
Thank you. After fixing review comments, I'm going to remove -pull and -ci yamls from this PR, so we can only test -canary. I personally like it. Using it would allow us to
WDYT guys? |
4234630
to
28eda1b
Compare
There's a genuine unit test failure:
|
If someone modifies the template locally and then submits only the updated canary YAML, it is impossible for others to review or replicate how they where generated. It may also be harder to verify that the changes for the canary jobs then get applied as tested to the actual jobs. I think I prefer the approach with @elieser1101 can be our first |
2ed5a55
to
1da3e45
Compare
@@ -0,0 +1,120 @@ | |||
{%- if header %}{%- if kind == "ci" %}periodics:{%- else %}presubmits: |
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.
Can this {%- if header %}
be dropped?
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.
Can you suggest how to do it? I don't like this trick either, but couldn't find a better way to make periodics:
and presubmits:
appear in a result content only once, at the beginning of the file.
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 that is the purpose - that wasn't clear to me. Can you perhaps add a comment to the dra.jinja
explaining this trick?
I don't have a better alternative.
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.
renamed the variable and added a comment
curl -sSL https://kind.sigs.k8s.io/dl/latest/linux-amd64.tgz | tar xvfz - -C "${PATH%%:*}/" kind | ||
kind build node-image --image=dra/node:latest . | ||
trap 'kind export logs "${ARTIFACTS}/kind"; kind delete cluster' EXIT | ||
{%- if kind == "canary" %} |
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 does this check "canary"?
This seems to overload the meaning of "canary":
- For canary PR jobs (= dra-canary.yaml).
- The "all features enabled" CI and presubmit jobs.
Let's use "canary" for "part of dra-canary.yaml" and something else for feature gates. How about "alpha"?
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.
with_all_features
was set to true
only for two canary jobs in your PR.
However, I agree that a separate option would be more appropriate here. How about all_features
?
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.
Works for me.
|
||
echo "Verifying generated jobs" | ||
hack/run-in-python-container.sh \ | ||
python3 hack/generate-jobs.py config/jobs/kubernetes/sig-node/*.conf --only-verify |
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.
We can start with only working on "our" (= SIG Node) jobs here for now. But in a future PR this should get extended to other generated 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.
Yes. Fortunately it's just a matter of adding new patterns to the command line. generate-jobs.py
already supports this.
1da3e45
to
5f4f709
Compare
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bart0sh The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
5e5c437
to
51f4171
Compare
/hold |
@pohly Can you look at failing canary jobs and suggest how to fix them? I'm looking as well, but couldn't find a reason yet. |
@@ -0,0 +1,129 @@ | |||
{# `beginning` variable is set to `true` by the generate-job.py for the first processed job and to `false` for the rest of the jobs #} | |||
{%- if beginning %}{%- if kind == "ci" %}periodics:{%- else %}presubmits: |
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 actually like header
better: "head" and "tail" is used for the top and bottom of files, but "beginning" could be for anything.
Perhaps set "header" to:
# GENERATED FILE - DO NOT EDIT!
#
# Instead, modify dra.jinja and run `make generate-jobs`.
and then inject that value here if non-empty?
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.
Thank you for the suggestion. Done. I defined header in the script as it's generic enough. Previously it was defined for the first job in the template, which is harder to understand in my opinion.
51f4171
to
7f1008f
Compare
0981b0d
to
ecd5495
Compare
ecd5495
to
34b1edd
Compare
command: | ||
- runner.sh | ||
args: | ||
- /bin/sh | ||
- /bin/bash |
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 should fix the https://prow.k8s.io/view/gs/kubernetes-ci-logs/pr-logs/directory/canary-kind-dra/1875675905863454720 failure:
/bin/sh: 6: Syntax error: "(" unexpected
Arrays are a bash feature, so features=( ... )
only works in bash.
with tmp: | ||
header = ( | ||
"# GENERATED FILE - DO NOT EDIT!\n#\n# " | ||
"Instead, modify template and run `make generate-jobs`.\n" |
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.
Someone not familiar with this mechanism will have to ask "which template?"
Let's answer that right away:
"Instead, modify template and run `make generate-jobs`.\n" | |
"Instead, modify %s and run `make generate-jobs`.\n" % os.path.basename(template_path) |
I think dropping the path is okay because generated file and template will typically (always?) be in the same directory.
/cc @pohly @kannon92 @SergeyKanzhelev @haircommander