Skip to content

Commit 2e94162

Browse files
committed
Wait for db and dispatcher to be operational
In the integration test we can see that dispatcher and underlying db is not ready at the time when tests are executed. This commit adds a wait steps to wait for db and dispatcher. It also adds an local dev environment guide with how to setup a environment using dispatcher. The commit also increase a default capacity to 5 PRs instead of 3. Signed-off-by: Ales Raszka <[email protected]>
1 parent d025114 commit 2e94162

File tree

4 files changed

+72
-3
lines changed

4 files changed

+72
-3
lines changed

ansible/inventory/group_vars/operator-pipeline.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ operator_pipeline_gpg_passphrase_path: ../../vaults/{{ env }}/operator-pipeline-
4343
# SSH key for the operator pipeline bot to access git repositories
4444
operator_pipeline_bot_ssh_key_path: ../../vaults/common/github-bot-ssh
4545

46-
operator_pipeline_webhook_dispatcher_url: "https://webhook-dispatcher-{{ oc_namespace }}.{{ operator_pipeline_base_url }}/api/v1/webhooks/github-pipeline"
46+
operator_pipeline_webhook_dispatcher_base_url: "https://webhook-dispatcher-{{ oc_namespace }}.{{ operator_pipeline_base_url }}"
47+
operator_pipeline_webhook_dispatcher_url: "{{ operator_pipeline_webhook_dispatcher_base_url }}/api/v1/webhooks/github-pipeline"
4748
operator_pipeline_webhook_secret: ../../vaults/common/github-webhook-secret-preprod.txt
4849

4950
kerberos_keytab_isv: ../../vaults/common/nonprod-operatorpipelines.keytab
@@ -74,8 +75,8 @@ operator_pipeline_dispatcher_release_pipeline_events:
7475
- labeled
7576
- closed
7677

77-
operator_pipeline_dispatcher_hosted_capacity: 3
78-
operator_pipeline_dispatcher_release_capacity: 3
78+
operator_pipeline_dispatcher_hosted_capacity: 5
79+
operator_pipeline_dispatcher_release_capacity: 5
7980

8081
operator_pipeline_callback_url: "https://operator-pipeline-{{ oc_namespace }}.{{ operator_pipeline_base_url}}"
8182
operator_pipeline_community_pipeline_callback_url: "https://community-operator-pipeline-{{ oc_namespace }}.{{ operator_pipeline_base_url }}"

ansible/roles/operator-pipeline/tasks/webhook-dispatcher.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@
3131
- ../templates/openshift/webhook_dispatcher/postgres-db-stateful-set.yml
3232
- ../templates/openshift/webhook_dispatcher/postgres-db-service.yml
3333

34+
- name: Wait for postgres database to be ready
35+
kubernetes.core.k8s_info:
36+
kind: StatefulSet
37+
namespace: "{{ oc_namespace }}"
38+
name: "{{ operator_pipeline_webhook_dispatcher_name }}-postgres-db"
39+
register: postgres_db_info
40+
until: >
41+
postgres_db_info.resources[0].status.readyReplicas is defined and
42+
postgres_db_info.resources[0].status.readyReplicas > 0
43+
retries: 20
44+
delay: 3
45+
3446
- name: Create a webhook dispatcher service account
3547
ansible.builtin.import_tasks: tasks/webhook-dispatcher-sa.yml
3648

@@ -61,3 +73,13 @@
6173
- "../templates/openshift/webhook_dispatcher/webhook-dispatcher-deployment.yml"
6274
- "../templates/openshift/webhook_dispatcher/webhook-dispatcher-service.yml"
6375
- "../templates/openshift/webhook_dispatcher/webhook-dispatcher-route.yml"
76+
77+
- name: Wait for webhook dispatcher route to be available
78+
ansible.builtin.uri:
79+
url: "{{ operator_pipeline_webhook_dispatcher_base_url }}/api/v1/status/db"
80+
method: GET
81+
status_code: 200
82+
register: webhook_dispatcher_status
83+
until: webhook_dispatcher_status.status == 200
84+
retries: 20
85+
delay: 3

docs/local-dev-environment.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Local development environment
2+
3+
This document provides instructiion on how to set up an environment for "local"
4+
development of the Operator Pipelines project.
5+
6+
The word "local" in this context means that developer will use existing stage
7+
operator pipelines cluster and use a custom namespace for development.
8+
9+
## Setup & Deployment
10+
11+
A operator pipelines interact with Github repositories (certified, marketplace and
12+
community). It is highly recomended to `fork` the upstream repository and only work
13+
on your fork.
14+
15+
1. Fork the upstream repository:
16+
1. [Certified Operators](https://github.com/redhat-openshift-ecosystem/certified-operators-preprod/)
17+
2. [Community Operators](https://github.com/redhat-openshift-ecosystem/community-operators-pipeline-preprod)
18+
2. Set environment variables referencing your fork:
19+
1. Create `.env` file in the root of the repository.
20+
2. Add the following variables to the `.env` file:
21+
1. `GITHUB_USER` - your GitHub username
22+
3. Sign in to the OpenShift cluster using `oc` CLI:
23+
```bash
24+
oc login --web --server=https://api.pipelines-stage.0ce8.p1.openshiftapps.com:6443
25+
```
26+
4. Use a `Makefile` to build and deploy your namespace:
27+
1. `make deploy-playground`
28+
2. This will create a new namespace `$(USER)-playground` and deploy the operator pipelines
29+
to it.
30+
5. Add a Github webhook to your forked repositories:
31+
1. Go to your forked repository settings.
32+
2. Add a new webhook with the following settings:
33+
- **Payload URL**: `https://webhook-dispatcher-$(USER)-playground.operator-pipeline-stage.apps.pipelines-stage.0ce8.p1.openshiftapps.com/api/v1/webhooks/github-pipeline`
34+
- **Content type**: `application/json`
35+
- **Secret**: Use the value from `ansible/vaults/common/github-webhook-secret-preprod.txt`.
36+
- **Which events would you like to trigger this webhook?**: Select "Let me select individual events" and check "Pull requests and Labels".
37+
- **Active**: Ensure the webhook is active.
38+
39+
## Trigger a pipeline event
40+
Once the environment is set up, you can submit a new pull request to your forked repository.
41+
When opening your PR you need to target the branch `$USER` (the same as your local user).
42+
This will trigger the webhook and start the operator pipelines and process the pull request.
43+
44+
After a moment you should see the pipeline running in the OpenShift console and also see
45+
firts interaction in the PR comments and labels being added to the PR.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ nav:
2525
- "Admin guide": "pipeline-admin-guide.md"
2626
- "Catalog image browser": "catalog_image_browser.md"
2727
- "FBC catalog promotion": "fbc-catalog-promotion.md"
28+
- "Local development environment": "local-dev-environment.md"
2829
theme:
2930
name: material
3031
features:

0 commit comments

Comments
 (0)