Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions roles/ocp4_workload_field_content/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ This role uses a **fire-and-forget** approach:

1. Creates the ArgoCD Application pointing to your repository
2. Verifies the Application was accepted by the cluster (~1 minute max)
3. Exits immediately — does **not** wait for sync or health status
3. Checks that ArgoCD can read and render the repository (~30 seconds max). An error gives a warning in user info. The provision does not fail.
4. Exits — does **not** wait for sync or health status

**Why fire-and-forget?**

Expand All @@ -27,8 +28,8 @@ This role uses a **fire-and-forget** approach:
| Invalid repo URL format | ✅ Yes | Playbook fails |
| ArgoCD not installed | ✅ Yes | Playbook fails |
| Malformed Application YAML | ✅ Yes | Playbook fails |
| Repository doesn't exist | ❌ No | Developer checks ArgoCD |
| Helm chart syntax errors | ❌ No | Developer checks ArgoCD |
| Repository doesn't exist | ⚠️ Warning in user info | Developer checks ArgoCD |
| Helm chart syntax errors | ⚠️ Warning in user info | Developer checks ArgoCD |
| Pods failing to start | ❌ No | Developer checks OpenShift |

## Hybrid Deployment Model
Expand Down
6 changes: 6 additions & 0 deletions roles/ocp4_workload_field_content/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ ocp4_workload_field_content_litemaas_model: "llama-scout-17b"
# This role uses a "fire and forget" approach:
# - Creates the ArgoCD Application
# - Verifies it was accepted by the cluster (~1 min max)
# - Checks that ArgoCD can read and render the repository (~30 sec max).
# An error gives a warning in user info and does not fail the provision.
# - Does NOT wait for sync or health status
#
# Developers are responsible for monitoring their deployment in ArgoCD/OpenShift.

# Retries/delay (seconds) for the repository check
ocp4_workload_field_content_repo_check_retries: 6
ocp4_workload_field_content_repo_check_delay: 5
56 changes: 56 additions & 0 deletions roles/ocp4_workload_field_content/tasks/workload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,20 @@
# ===================================================================
# Deploy via ArgoCD
# ===================================================================
# The GitOps operator creates the default AppProject some seconds after
# the ArgoCD instance. An Application created before that gets an
# InvalidSpecError, which the repository check below reports as a warning.
- name: Wait for the default ArgoCD AppProject
kubernetes.core.k8s_info:
api_version: argoproj.io/v1alpha1
kind: AppProject
name: default
namespace: "{{ ocp4_workload_field_content_namespace }}"
register: r_field_content_appproject
retries: 30
delay: 10
until: r_field_content_appproject.resources | length > 0

- name: Create field content ArgoCD application
kubernetes.core.k8s:
state: present
Expand All @@ -123,3 +137,45 @@
until:
- argocd_field_content.resources | length > 0
failed_when: argocd_field_content.resources | length == 0

- name: Save field content repository details to user data
agnosticd.core.agnosticd_user_info:
data:
field_content_gitops_repo_url: "{{ ocp4_workload_field_content_gitops_repo_url }}"
field_content_gitops_repo_revision: "{{ ocp4_workload_field_content_gitops_repo_revision }}"
field_content_argocd_app_namespace: "{{ ocp4_workload_field_content_namespace }}"

# ===================================================================
# Quick check that ArgoCD can read and render the repository.
# Does not wait for sync or health. Errors are reported as a warning
# in user info and do not fail the provision.
# ===================================================================
- name: Check that ArgoCD can read the field content repository
kubernetes.core.k8s_info:
api_version: argoproj.io/v1alpha1
kind: Application
name: field-content
namespace: "{{ ocp4_workload_field_content_namespace }}"
register: r_field_content_app
retries: "{{ ocp4_workload_field_content_repo_check_retries | int }}"
delay: "{{ ocp4_workload_field_content_repo_check_delay | int }}"
until: >-
(r_field_content_app.resources[0].status.conditions | default([])
| selectattr('type', 'in', _ocp4_workload_field_content_repo_error_types) | list | length > 0)
or
(r_field_content_app.resources[0].status.sync.status | default('Unknown')
in ['Synced', 'OutOfSync'])
failed_when: false

- name: Report ArgoCD repository error
vars:
_repo_errors: >-
{{ r_field_content_app.resources[0].status.conditions | default([])
| selectattr('type', 'in', _ocp4_workload_field_content_repo_error_types) | list }}
when: _repo_errors | length > 0
agnosticd.core.agnosticd_user_info:
msg: >-
WARNING: ArgoCD cannot deploy the field content repository
{{ ocp4_workload_field_content_gitops_repo_url }}
({{ ocp4_workload_field_content_gitops_repo_revision }}):
{{ _repo_errors | map(attribute='message') | join('; ') | truncate(1000) }}
6 changes: 6 additions & 0 deletions roles/ocp4_workload_field_content/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
---
_ocp4_workload_gitops_bootstrap_deployer_values: ""

# ArgoCD Application condition types that mean the repository cannot be
# read or rendered
_ocp4_workload_field_content_repo_error_types:
- ComparisonError
- InvalidSpecError
Loading