Skip to content

Commit 7ee2fdf

Browse files
authored
step-registry/sandboxed-containers-operator: Make create-prowjob-commands.sh to run jobs (#69967)
* step-registry/sandboxed-containers-operator: create validate_and_set_defaults() in create-prowjob-commands.sh - Extract parameter validation and default setting logic into validate_and_set_defaults() function - Maintain all existing validation rules and error handling Assisted-by: Cursor Signed-off-by: Wainer dos Santos Moschetta <[email protected]> * step-registry/sandboxed-containers-operator: Add create command to create-prowjob-commands.sh - Refactor script to support command-based interface - Add 'create' command to generate prowjob configurations - Move existing functionality into command_create() function - Add proper command validation and usage help - Maintain all existing functionality with improved structure Assisted-by: Cursor Signed-off-by: Wainer dos Santos Moschetta <[email protected]> * step-registry/sandboxed-containers-operator: Add run command to create-prowjob-commands.sh - Add 'run' command as placeholder for future prowjob execution - Update usage help to include run command - Add command_run() function with unimplemented message - Maintain backward compatibility with create command Assisted-by: Cursor Signed-off-by: Wainer dos Santos Moschetta <[email protected]> * step-registry/sandboxed-containers-operator: Remove "documentation" from generated prowjob The documentation section in the generated prowjob is not valid for the ci-operator, resulting on job run via API to fail. Signed-off-by: Wainer dos Santos Moschetta <[email protected]> --------- Signed-off-by: Wainer dos Santos Moschetta <[email protected]>
1 parent 056ad12 commit 7ee2fdf

File tree

2 files changed

+535
-234
lines changed

2 files changed

+535
-234
lines changed

ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/README.md

Lines changed: 78 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,25 @@ This directory contains a robust script to generate OpenShift CI prowjob configu
66

77
The `sandboxed-containers-operator-create-prowjob-commands.sh` script creates prowjob configuration files for the sandboxed containers operator CI pipeline. It supports both Pre-GA (development) and GA (production) release types with intelligent catalog source management and comprehensive parameter validation.
88

9+
## Commands
10+
11+
The script supports the following commands:
12+
13+
- `create` - Create prowjob configuration files
14+
- `run` - Run prowjobs from YAML configuration
15+
16+
### Command Usage
17+
18+
```bash
19+
# Show help
20+
./sandboxed-containers-operator-create-prowjob-commands.sh
21+
```
22+
923
## Files
1024

1125
- `sandboxed-containers-operator-create-prowjob-commands.sh` - Main script to generate prowjob configurations
1226
- The output file is created in the current directory and named `openshift-sandboxed-containers-operator-devel__downstream-${PROW_RUN_TYPE}${OCP_VERSION}.yaml`
13-
- `PROW_RUN_TYPE` is based on ``TEST_RELEASE_TYPE. It is `candidate` for `Pre-GA` and `release` otherwise
27+
- `PROW_RUN_TYPE` is based on `TEST_RELEASE_TYPE`. It is `candidate` for `Pre-GA` and `release` otherwise
1428
- If the output file exists, it will be moved to a `.backup` file
1529

1630
## Key Features
@@ -31,10 +45,16 @@ The script uses environment variables exclusively for configuration:
3145

3246
```bash
3347
# Generate configuration with defaults
34-
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh
48+
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh create
3549

3650
# Generate configuration with custom OCP version
37-
OCP_VERSION=4.17 ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh
51+
OCP_VERSION=4.17 ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh create
52+
53+
# Run jobs from generated YAML file
54+
PROW_API_TOKEN=your_token_here ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh run openshift-sandboxed-containers-operator-devel__downstream-candidate419.yaml
55+
56+
# Run specific job
57+
PROW_API_TOKEN=your_token_here ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh run openshift-sandboxed-containers-operator-devel__downstream-candidate419.yaml azure-ipi-kata
3858
```
3959

4060
### Environment Variables
@@ -75,7 +95,7 @@ OCP_VERSION=4.17 ci-operator/step-registry/sandboxed-containers-operator/create-
7595
TEST_RELEASE_TYPE=Pre-GA \
7696
PROW_RUN_TYPE=candidate \
7797
OCP_VERSION=4.18 \
78-
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh
98+
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh create
7999
```
80100

81101
#### GA Production Testing
@@ -84,7 +104,7 @@ ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed
84104
TEST_RELEASE_TYPE=GA \
85105
PROW_RUN_TYPE=release \
86106
OCP_VERSION=4.19 \
87-
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh
107+
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh create
88108
```
89109

90110
#### Custom Regions and Timeouts
@@ -94,19 +114,19 @@ AWS_REGION_OVERRIDE=us-west-2 \
94114
CUSTOM_AZURE_REGION=westus2 \
95115
SLEEP_DURATION=2h \
96116
TEST_TIMEOUT=120 \
97-
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh
117+
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh create
98118
```
99119

100120
#### Kata RPM Testing
101121
```bash
102122
# Test without Kata RPM installation
103123
INSTALL_KATA_RPM=false \
104-
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh
124+
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh create
105125

106126
# Test with specific Kata RPM version
107127
INSTALL_KATA_RPM=true \
108128
KATA_RPM_VERSION=3.18.0-3.rhaos4.20.el9 \
109-
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh
129+
ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed-containers-operator-create-prowjob-commands.sh create
110130
```
111131

112132
## Catalog Tag Discovery
@@ -123,6 +143,34 @@ ci-operator/step-registry/sandboxed-containers-operator/create-prowjob/sandboxed
123143
- **Method**: Quay API with pagination (max 50 pages)
124144
- **Special Case**: OCP 4.16 uses `trustee-fbc/` subfolder
125145

146+
## Run Command
147+
148+
The `run` command allows you to trigger ProwJobs from a generated YAML configuration file. This command requires a valid Prow API token.
149+
150+
### Run Command Usage
151+
152+
```bash
153+
# Run all jobs from a YAML file
154+
./sandboxed-containers-operator-create-prowjob-commands.sh run /path/to/job_yaml.yaml
155+
156+
# Run specific jobs from a YAML file
157+
./sandboxed-containers-operator-create-prowjob-commands.sh run /path/to/job_yaml.yaml azure-ipi-kata aws-ipi-peerpods
158+
```
159+
160+
### Run Command Features
161+
162+
- **Job Name Generation**: Automatically constructs job names using the pattern `periodic-ci-{org}-{repo}-{branch}-{variant}-{job_suffix}`
163+
- **Metadata Extraction**: Extracts organization, repository, branch, and variant from the YAML file's `zz_generated_metadata` section
164+
- **API Integration**: Uses the Prow/Gangway API to trigger jobs
165+
- **Job Status Monitoring**: Provides job IDs and status information
166+
- **Flexible Job Selection**: Can run all jobs or specific jobs by name
167+
168+
### Run Command Environment Variables
169+
170+
| Variable | Required | Description |
171+
|----------|----------|-------------|
172+
| `PROW_API_TOKEN` | Yes | Prow API authentication token |
173+
126174
## Generated Test Matrix
127175

128176
The script generates configuration for 5 test scenarios:
@@ -206,3 +254,25 @@ yq eval '.' openshift-sandboxed-containers-operator-devel__downstream-candidate4
206254
- **Required**: `curl`, `jq`, `awk`, `sort`, `head`
207255
- **Optional**: `yq` (for YAML syntax validation)
208256
- **Network**: Access to `quay.io` API endpoints
257+
258+
## Prow API Token
259+
260+
To trigger ProwJobs via the REST API, you need an authentication token. Each SSO user is entitled to obtain a personal authentication token.
261+
262+
### Obtaining a Token
263+
264+
Tokens can be retrieved through the UI of the app.ci cluster at [OpenShift Console](https://console-openshift-console.apps.ci.l2s4.p1.openshiftapps.com). Alternatively, if the app.ci cluster context is already configured, you may execute:
265+
266+
```bash
267+
oc whoami -t
268+
```
269+
270+
### Using the Token
271+
272+
Once you have obtained a token, set it as an environment variable:
273+
274+
```bash
275+
export PROW_API_TOKEN=your_token_here
276+
```
277+
278+
For complete information about triggering ProwJobs via REST, including permanent tokens for automation, see the [OpenShift CI documentation](https://docs.ci.openshift.org/docs/how-tos/triggering-prowjobs-via-rest/#obtaining-an-authentication-token).

0 commit comments

Comments
 (0)