You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "potiuk (via GitHub)" <gi...@apache.org> on 2024/03/28 23:14:50 UTC
[PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
potiuk opened a new pull request, #38601:
URL: https://github.com/apache/airflow/pull/38601
Depending on selective checks, but also on the job executed, we choose whether to run job on public runners or self-hosted runners. So far the set of labels to select the runners were passed in a bit inconsistent way. Outputs of selective checks can only be strings and the `run-as` accepts array of strings (labels) - so we were using fromJSON to convert between the two. And we used runs-on inputs on a number of our workflows to pass the selection.
However this meant that runs-on could be either string or array and that sometimes we passed public/self-hosted labels as strings directly and some of those were hard-coded.
This PR changes it consistently across the board to introduce consistent approach:
* build info have no selective checks results yet, so for them runs-on is hardcoded
* similarly for "windows" and release jobs that are manually run without running selective checks
* selective checks will produce three outuputs - JSON stringiified array of labels:
* default (one that is selected depending on who runs the build)
* public (for cases where we want to force the builds to use public runners
* self-hosted (for cases where we want to force the builds to use self-hosted runners
* all the outputs are named `<type>-runs-on-as-string` to make it clear they are all strings
* all inputs of workflows expectings strings are named the same (with as-string suffix and <type> prefix)
* whenever a job is run, we pass "runs-on" parameter to be `fromJSON` with appropriate type we want to use passed as input
This will make it easier to reason on which job is using which type of runner and it will make it easier in the future to make it more flexible when we add ASF self-hosted runners and possibly our own K8S runners, or when we would want to change labels for public runners or self-hosted runners.
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!--
Thank you for contributing! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
In case of an existing issue, reference it using one of the following:
closes: #ISSUE
related: #ISSUE
How to write a good git commit message:
http://chris.beams.io/posts/git-commit/
-->
<!-- Please keep an empty line above the dashes. -->
---
**^ Add meaningful description above**
Read the **[Pull Request Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)** for more information.
In case of fundamental code changes, an Airflow Improvement Proposal ([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals)) is needed.
In case of a new dependency, check compliance with the [ASF 3rd Party License Policy](https://www.apache.org/legal/resolved.html#category-x).
In case of backwards incompatible changes please leave a note in a newsfragment file, named `{pr_number}.significant.rst` or `{issue_number}.significant.rst`, in [newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #38601:
URL: https://github.com/apache/airflow/pull/38601#discussion_r1545656973
##########
.github/workflows/additional-ci-image-checks.yml:
##########
@@ -93,7 +96,7 @@ jobs:
packages: write
secrets: inherit
with:
- # Runs on Public runners
+ runs-on-as-string: ${{ inputs.public-runs-on-as-string }}
Review Comment:
yeah. It was another (a bit) of inconsistency. I just thought that in case of those two workflows (pushing cache and building images) we always know which runner we want to use, and I wanted to pass the right one). Those workflows could be executed with `public` or `self-hosted` depending on the platform (AMD/ ARM). I just wanted to avoid pushing both as parameters and making the choice in the final workflow, but I think yeah, this is the right approach - so I pushed a change with this ternary down to the "leaf" workflows - as this will make run-as parameters even more explicit and consistent.
```
${{ inputs.platform == 'linux/amd' && fromJSON(inputs.runs-on-as-json-public) ||
fromJSON(inputs.runs-on-as-json-self-hosted) }}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on code in PR #38601:
URL: https://github.com/apache/airflow/pull/38601#discussion_r1545612839
##########
.github/workflows/push-image-cache.yml:
##########
@@ -134,7 +133,7 @@ jobs:
push-prod-image-cache:
name: "Push PROD ${{ inputs.cache-type }}:${{ matrix.python }} image cache"
- runs-on: ${{ fromJSON(inputs.runs-on) }}
+ runs-on: ${{ fromJSON(inputs.runs-on-as-string) }}
Review Comment:
```suggestion
runs-on: ${{ fromJSON(inputs.public-runs-on-as-string) }}
```
Based on the previous [comment](https://github.com/apache/airflow/pull/38601#discussion_r1545612621) if we decide to accept the previous comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38601:
URL: https://github.com/apache/airflow/pull/38601#issuecomment-2028780900
I think I figured it .... 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯 🤯
```
# NOTE!!!!! This has to be put in one line for runs-on to recognize the "fromJSON" properly !!!!
# adding space before (with >) apparently turns the `runs-on` processed line into a string "Array"
# instead of an array of strings.
# yamllint disable-line rule:line-length
runs-on: ${{ (inputs.platform == 'linux/amd64') && fromJSON(inputs.runs-on-as-json-public) || fromJSON(inputs.runs-on-as-json-self-hosted) }}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38601:
URL: https://github.com/apache/airflow/pull/38601#issuecomment-2027810175
Green :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38601:
URL: https://github.com/apache/airflow/pull/38601#issuecomment-2027245024
This one also looks good-to-go with much easier way to manage what runners are used (and I am going to have some follow-ups once this is better organized).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on code in PR #38601:
URL: https://github.com/apache/airflow/pull/38601#discussion_r1545631644
##########
.github/workflows/push-image-cache.yml:
##########
@@ -20,10 +20,9 @@ name: Push image cache
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
- runs-on:
- description: "The array of labels (in json form) determining type of the runner to use for the build."
- required: false
- default: "[\"ubuntu-22.04\"]"
+ runs-on-as-string:
Review Comment:
Based on the previous [comment](https://github.com/apache/airflow/pull/38601#discussion_r1545612621) if we decide to accept the previous comment.
##########
.github/workflows/push-image-cache.yml:
##########
@@ -76,7 +75,7 @@ on: # yamllint disable-line rule:truthy
jobs:
push-ci-image-cache:
name: "Push CI ${{ inputs.cache-type }}:${{ matrix.python }} image cache "
- runs-on: ${{ fromJSON(inputs.runs-on) }}
+ runs-on: ${{ fromJSON(inputs.runs-on-as-string) }}
Review Comment:
```suggestion
runs-on: ${{ fromJSON(inputs.public-runs-on-as-string) }}
```
Based on the previous [comment](https://github.com/apache/airflow/pull/38601#discussion_r1545612621) if we decide to accept the previous comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on code in PR #38601:
URL: https://github.com/apache/airflow/pull/38601#discussion_r1545612812
##########
.github/workflows/push-image-cache.yml:
##########
@@ -76,7 +75,7 @@ on: # yamllint disable-line rule:truthy
jobs:
push-ci-image-cache:
name: "Push CI ${{ inputs.cache-type }}:${{ matrix.python }} image cache "
- runs-on: ${{ fromJSON(inputs.runs-on) }}
+ runs-on: ${{ fromJSON(inputs.runs-on-as-string) }}
Review Comment:
```suggestion
runs-on: ${{ fromJSON(inputs.public-runs-on-as-string) }}
```
Based on the previous comment if we decide to accept the previous comment.
##########
.github/workflows/push-image-cache.yml:
##########
@@ -134,7 +133,7 @@ jobs:
push-prod-image-cache:
name: "Push PROD ${{ inputs.cache-type }}:${{ matrix.python }} image cache"
- runs-on: ${{ fromJSON(inputs.runs-on) }}
+ runs-on: ${{ fromJSON(inputs.runs-on-as-string) }}
Review Comment:
```suggestion
runs-on: ${{ fromJSON(inputs.public-runs-on-as-string) }}
```
Based on the previous comment if we decide to accept the previous comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38601:
URL: https://github.com/apache/airflow/pull/38601#issuecomment-2027862357
All good - tested all cases: regular builds, public runner builds, maintainer build from PR in apache repo, canary build - this one is ready to merge I think. Looking forward to reviews :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #38601:
URL: https://github.com/apache/airflow/pull/38601#discussion_r1545681685
##########
.github/workflows/additional-ci-image-checks.yml:
##########
@@ -93,7 +96,7 @@ jobs:
packages: write
secrets: inherit
with:
- # Runs on Public runners
+ runs-on-as-string: ${{ inputs.public-runs-on-as-string }}
Review Comment:
Still have not figured out if it works or not and how :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on code in PR #38601:
URL: https://github.com/apache/airflow/pull/38601#discussion_r1545657439
##########
.github/workflows/additional-ci-image-checks.yml:
##########
@@ -93,7 +96,7 @@ jobs:
packages: write
secrets: inherit
with:
- # Runs on Public runners
+ runs-on-as-string: ${{ inputs.public-runs-on-as-string }}
Review Comment:
Should be much more consistent now @pankajkoti @hussein-awala
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk merged PR #38601:
URL: https://github.com/apache/airflow/pull/38601
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38601:
URL: https://github.com/apache/airflow/pull/38601#issuecomment-2027813850
Running it with `use public runners` to check if everything is fine for a `regular` run - also running it as `canary` build in #38630
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38601:
URL: https://github.com/apache/airflow/pull/38601#issuecomment-2028721875
@hussein-awala :
> I don't think the as-string suffix makes it clearer here, personally, I prefer to keep the name pattern <type>-runs-on or <type>-runs-on-as-json as we can use the string without any issue in most of the cases, but here we want to load an array from the string.
Yep. good point. I also reverted the sequenece and we have now:
```
runs-on-as-json-default: ${{ steps.selective-checks.outputs.runs-on-as-json-default }}
runs-on-as-json-self-hosted: ${{ steps.selective-checks.outputs.runs-on-as-json-self-hosted }}
runs-on-as-json-public: ${{ steps.selective-checks.outputs.runs-on-as-json-public }}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "pankajkoti (via GitHub)" <gi...@apache.org>.
pankajkoti commented on code in PR #38601:
URL: https://github.com/apache/airflow/pull/38601#discussion_r1545612839
##########
.github/workflows/push-image-cache.yml:
##########
@@ -134,7 +133,7 @@ jobs:
push-prod-image-cache:
name: "Push PROD ${{ inputs.cache-type }}:${{ matrix.python }} image cache"
- runs-on: ${{ fromJSON(inputs.runs-on) }}
+ runs-on: ${{ fromJSON(inputs.runs-on-as-string) }}
Review Comment:
```suggestion
runs-on: ${{ fromJSON(inputs.public-runs-on-as-string) }}
```
##########
.github/workflows/push-image-cache.yml:
##########
@@ -76,7 +75,7 @@ on: # yamllint disable-line rule:truthy
jobs:
push-ci-image-cache:
name: "Push CI ${{ inputs.cache-type }}:${{ matrix.python }} image cache "
- runs-on: ${{ fromJSON(inputs.runs-on) }}
+ runs-on: ${{ fromJSON(inputs.runs-on-as-string) }}
Review Comment:
```suggestion
runs-on: ${{ fromJSON(inputs.public-runs-on-as-string) }}
```
##########
.github/workflows/additional-ci-image-checks.yml:
##########
@@ -93,7 +96,7 @@ jobs:
packages: write
secrets: inherit
with:
- # Runs on Public runners
+ runs-on-as-string: ${{ inputs.public-runs-on-as-string }}
Review Comment:
```suggestion
public-runs-on-as-string: ${{ inputs.public-runs-on-as-string }}
```
Just wondering if this would make it more consistent(seems this is the only place without the public/default prefix) and explicit.
##########
.github/workflows/push-image-cache.yml:
##########
@@ -20,10 +20,9 @@ name: Push image cache
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
- runs-on:
- description: "The array of labels (in json form) determining type of the runner to use for the build."
- required: false
- default: "[\"ubuntu-22.04\"]"
+ runs-on-as-string:
Review Comment:
```suggestion
public-runs-on-as-string:
```
##########
.github/workflows/push-image-cache.yml:
##########
@@ -20,10 +20,9 @@ name: Push image cache
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
- runs-on:
- description: "The array of labels (in json form) determining type of the runner to use for the build."
- required: false
- default: "[\"ubuntu-22.04\"]"
+ runs-on-as-string:
Review Comment:
Based on the previous comment if we decide to accept the previous comment.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] Use explicit and easier to use runs-on approach for CI workflows [airflow]
Posted by "potiuk (via GitHub)" <gi...@apache.org>.
potiuk commented on PR #38601:
URL: https://github.com/apache/airflow/pull/38601#issuecomment-2028786806
Also I standardized `fromJSON` everywhere - in an attempt to see what is causing the problem if I put `run-as` in two lines of yaml rather than one 🤯
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org