Skip to content

Commit c9bc234

Browse files
committed
Fix adapter task configs for v0.2.1 compatibility and OCI platform
- Fix CEL expressions: replace invalid bare has() calls with optional field access syntax (status.?conditions.orValue) for v0.2.1 adapter - Quote template expressions in nodepool manifest to prevent YAML parser from interpreting them as flow mappings - Switch services from Route to NodePort for Ignition and OAuth since OKE clusters have no OpenShift router - Change status report POST actions from PUT to POST to match API - Fix OCI helmfile adapter config paths to point to oci/ directory - Pin env.oci chart and image versions to v0.2.1
1 parent b161d79 commit c9bc234

6 files changed

Lines changed: 203 additions & 26 deletions

File tree

env.oci

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ ADAPTER_REPOSITORY ?= openshift-hyperfleet/hyperfleet-adapter
1111

1212
# Helm Charts
1313
CHART_ORG ?= openshift-hyperfleet
14-
API_CHART_REF ?= v0.3.0
15-
SENTINEL_CHART_REF ?= v0.3.0
16-
ADAPTER_CHART_REF ?= v0.3.0
14+
API_CHART_REF ?= v0.2.1
15+
SENTINEL_CHART_REF ?= v0.2.1
16+
ADAPTER_CHART_REF ?= v0.2.1
1717

1818
# Image Tags
19-
API_IMAGE_TAG ?= v0.3.0
20-
SENTINEL_IMAGE_TAG ?= v0.3.0
21-
ADAPTER_IMAGE_TAG ?= v0.3.0
19+
API_IMAGE_TAG ?= v0.2.1
20+
SENTINEL_IMAGE_TAG ?= v0.2.1
21+
ADAPTER_IMAGE_TAG ?= v0.2.1
2222
IMAGE_PULL_POLICY ?= Always
2323

2424
# Kubernetes Namespaces

helm/adapter-hypershift-nodepool/adapter-task-config.yaml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,8 @@ preconditions:
6565
field: "spec"
6666
- name: "nodepoolNotReady"
6767
expression: |
68-
!has(status) || !has(status.conditions)
69-
? true
70-
: (status.conditions.filter(c, c.type == "Ready").size() > 0
71-
? status.conditions.filter(c, c.type == "Ready")[0].status != "True"
72-
: true)
68+
!(status.?conditions.orValue([]).filter(c, c.type == "Ready").size() > 0
69+
&& status.?conditions.orValue([]).filter(c, c.type == "Ready")[0].status == "True")
7370
7471
# Fetch parent cluster details (need the cluster name for clusterName ref)
7572
- name: "clusterDetails"
@@ -126,7 +123,7 @@ resources:
126123
hyperfleet.io/nodepool-name: "{{ .nodepoolName }}"
127124
spec:
128125
clusterName: "{{ .clusterName }}"
129-
replicas: {{ index .nodepoolSpec "replicas" | default 2 }}
126+
replicas: '{{ index .nodepoolSpec "replicas" | default 2 }}'
130127
management:
131128
autoRepair: true
132129
upgradeType: Replace
@@ -135,11 +132,11 @@ resources:
135132
oci:
136133
instanceShape: '{{ index .nodepoolSpec "instanceShape" | default .ociShape }}'
137134
instanceShapeConfig:
138-
ocpus: {{ index .nodepoolSpec "ocpus" | default .ociOcpus }}
139-
memoryInGBs: {{ index .nodepoolSpec "memoryInGBs" | default .ociMemoryGBs }}
135+
ocpus: '{{ index .nodepoolSpec "ocpus" | default .ociOcpus }}'
136+
memoryInGBs: '{{ index .nodepoolSpec "memoryInGBs" | default .ociMemoryGBs }}'
140137
availabilityDomain: '{{ index .nodepoolSpec "availabilityDomain" | default .ociAD }}'
141138
subnetId: '{{ index .nodepoolSpec "subnetId" | default .ociSubnetId }}'
142-
bootVolumeSize: {{ index .nodepoolSpec "bootVolumeSize" | default .ociBootVolumeGB }}
139+
bootVolumeSize: '{{ index .nodepoolSpec "bootVolumeSize" | default .ociBootVolumeGB }}'
143140
release:
144141
image: '{{ index .nodepoolSpec "releaseImage" | default "quay.io/openshift-release-dev/ocp-release:4.20.2-x86_64" }}'
145142
discovery:
@@ -206,7 +203,7 @@ post:
206203
post_actions:
207204
- name: "reportNodepoolStatus"
208205
api_call:
209-
method: "PUT"
206+
method: "POST"
210207
url: "/clusters/{{ .clusterId }}/nodepools/{{ .nodepoolId }}/statuses"
211208
headers:
212209
- name: "Content-Type"

helm/adapter-hypershift/adapter-task-config.yaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ params:
3636
source: "env.CPO_IMAGE"
3737
type: "string"
3838

39+
- name: "nodeAddress"
40+
source: "env.NODE_ADDRESS"
41+
type: "string"
42+
3943

4044
# Preconditions: check cluster details from API
4145
preconditions:
@@ -53,11 +57,8 @@ preconditions:
5357
field: "generation"
5458
- name: "clusterNotReady"
5559
expression: |
56-
!has(status) || !has(status.conditions)
57-
? true
58-
: (status.conditions.filter(c, c.type == "Ready").size() > 0
59-
? status.conditions.filter(c, c.type == "Ready")[0].status != "True"
60-
: true)
60+
!(status.?conditions.orValue([]).filter(c, c.type == "Ready").size() > 0
61+
&& status.?conditions.orValue([]).filter(c, c.type == "Ready")[0].status == "True")
6162
6263
- name: "validationCheck"
6364
expression: |
@@ -117,10 +118,14 @@ resources:
117118
services:
118119
- service: Ignition
119120
servicePublishingStrategy:
120-
type: Route
121+
type: NodePort
122+
nodePort:
123+
address: "{{ .nodeAddress }}"
121124
- service: OAuthServer
122125
servicePublishingStrategy:
123-
type: Route
126+
type: NodePort
127+
nodePort:
128+
address: "{{ .nodeAddress }}"
124129
- service: APIServer
125130
servicePublishingStrategy:
126131
type: LoadBalancer
@@ -195,7 +200,7 @@ post:
195200
post_actions:
196201
- name: "reportClusterStatus"
197202
api_call:
198-
method: "PUT"
203+
method: "POST"
199204
url: "/clusters/{{ .clusterId }}/statuses"
200205
headers:
201206
- name: "Content-Type"
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Example HyperFleet Adapter deployment configuration
2+
adapter:
3+
name: adapter1
4+
version: "0.2.0"
5+
6+
# Log the full merged configuration after load (default: false)
7+
debug_config: true
8+
log:
9+
level: debug
10+
11+
clients:
12+
hyperfleet_api:
13+
base_url: http://hyperfleet-api:8000
14+
version: v1
15+
timeout: 2s
16+
retry_attempts: 3
17+
retry_backoff: exponential
18+
19+
broker:
20+
# These values are overridden at deploy time via env vars from Helm values
21+
subscription_id: "placeholder"
22+
topic: "placeholder"
23+
24+
kubernetes:
25+
api_version: "v1"
26+
#kube_config_path: PATH_TO_KUBECONFIG # for local development
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# HyperFleet Adapter task configuration (v0.2.1 compatible)
2+
params:
3+
4+
- name: "clusterId"
5+
source: "event.id"
6+
type: "string"
7+
required: true
8+
9+
- name: "generation"
10+
source: "event.generation"
11+
type: "int"
12+
required: true
13+
14+
- name: "namespace"
15+
source: "env.NAMESPACE"
16+
type: "string"
17+
18+
# Preconditions with valid operators and CEL expressions
19+
preconditions:
20+
- name: "clusterStatus"
21+
api_call:
22+
method: "GET"
23+
url: "/clusters/{{ .clusterId }}"
24+
timeout: 10s
25+
retry_attempts: 3
26+
retry_backoff: "exponential"
27+
capture:
28+
- name: "clusterName"
29+
field: "name"
30+
- name: "generation"
31+
field: "generation"
32+
- name: "clusterNotReady"
33+
expression: |
34+
status.conditions.filter(c, c.type == "Ready").size() > 0
35+
? status.conditions.filter(c, c.type == "Ready")[0].status != "True"
36+
: true
37+
- name: "clusterReadyTTL"
38+
expression: |
39+
(timestamp(now()) - timestamp(
40+
status.conditions.filter(c, c.type == "Ready").size() > 0
41+
? status.conditions.filter(c, c.type == "Ready")[0].last_transition_time
42+
: now()
43+
)).getSeconds() > 300
44+
45+
- name: "validationCheck"
46+
# Precondition passes if cluster is NOT Ready OR if cluster is Ready and stable for >300 seconds since last transition (enables self-healing)
47+
expression: |
48+
clusterNotReady || clusterReadyTTL
49+
50+
# Resources with valid K8s manifests
51+
resources:
52+
- name: "resource0"
53+
transport:
54+
client: "kubernetes"
55+
manifest:
56+
apiVersion: v1
57+
kind: ConfigMap
58+
data:
59+
cluster_id: "{{ .clusterId }}"
60+
cluster_name: "{{ .clusterName }}"
61+
metadata:
62+
name: "{{ .clusterId | lower }}-adapter1-configmap"
63+
namespace: "{{ .namespace }}"
64+
labels:
65+
app.kubernetes.io/component: adapter
66+
app.kubernetes.io/instance: adapter1
67+
app.kubernetes.io/name: hyperfleet-adapter
68+
app.kubernetes.io/version: 1.0.0
69+
app.kubernetes.io/transport: kubernetes
70+
hyperfleet.io/cluster-id: "{{ .clusterId }}"
71+
hyperfleet.io/cluster-name: "{{ .clusterName }}"
72+
annotations:
73+
hyperfleet.io/generation: "{{ .generation }}"
74+
discovery:
75+
namespace: "{{ .namespace }}"
76+
by_selectors:
77+
label_selector:
78+
hyperfleet.io/cluster-id: "{{ .clusterId }}"
79+
hyperfleet.io/cluster-name: "{{ .clusterName }}"
80+
81+
# Post-processing with valid CEL expressions
82+
post:
83+
payloads:
84+
- name: "statusPayload"
85+
build:
86+
adapter: "{{ .adapter.name }}"
87+
conditions:
88+
# Applied: ConfigMap successfully created in the target namespace
89+
- type: "Applied"
90+
status:
91+
expression: |
92+
resources.?resource0.?metadata.?creationTimestamp.hasValue() ? "True" : "False"
93+
reason:
94+
expression: |
95+
resources.?resource0.?metadata.?creationTimestamp.hasValue() ? "ConfigMapCreated" : "ConfigMapNotCreated"
96+
message:
97+
expression: |
98+
resources.?resource0.?metadata.?creationTimestamp.hasValue()
99+
? "ConfigMap created in namespace " + resources.resource0.metadata.namespace
100+
: "ConfigMap has not been created yet"
101+
# Available: ConfigMap data keys are populated and accessible
102+
- type: "Available"
103+
status:
104+
expression: |
105+
resources.?resource0.?data.?cluster_id.hasValue() ? "True" : "False"
106+
reason:
107+
expression: |
108+
resources.?resource0.?data.?cluster_id.hasValue()
109+
? "ConfigMapDataPopulated"
110+
: "ConfigMapDataMissing"
111+
message:
112+
expression: |
113+
resources.?resource0.?data.?cluster_id.hasValue()
114+
? "ConfigMap data keys are populated and accessible"
115+
: "ConfigMap data keys are not yet populated"
116+
# Health: Adapter execution status (runtime)
117+
- type: "Health"
118+
status:
119+
expression: |
120+
adapter.?executionStatus.orValue("") == "success" ? "True" : (adapter.?executionStatus.orValue("") == "failed" ? "False" : "Unknown")
121+
reason:
122+
expression: |
123+
adapter.?errorReason.orValue("") != "" ? adapter.?errorReason.orValue("") : "Healthy"
124+
message:
125+
expression: |
126+
adapter.?errorMessage.orValue("") != "" ? adapter.?errorMessage.orValue("") : "All adapter operations completed successfully"
127+
# Event generation ID metadata field needs to use expression to avoid interpolation issues
128+
observed_generation:
129+
expression: "generation"
130+
observed_time: "{{ now | date \"2006-01-02T15:04:05Z07:00\" }}"
131+
# Optional data field for adapter-specific metrics extracted from resources
132+
data:
133+
namespace:
134+
name:
135+
expression: |
136+
resources.?resource0.?metadata.?name.orValue("")
137+
creationTimestamp:
138+
expression: |
139+
resources.?resource0.?metadata.?creationTimestamp.orValue("")
140+
141+
post_actions:
142+
- name: "reportClusterStatus"
143+
api_call:
144+
method: "PUT"
145+
url: "/clusters/{{ .clusterId }}/statuses"
146+
headers:
147+
- name: "Content-Type"
148+
value: "application/json"
149+
body: "{{ .statusPayload }}"

helmfile/environments/oci/adapter-configs.yaml.gotmpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ adapters:
2121
routingKey: "#"
2222
setFiles:
2323
- name: adapterConfig.yaml
24-
file: configs/base/adapters/adapter1/adapter-config.yaml
24+
file: configs/oci/adapters/adapter1/adapter-config.yaml
2525
- name: adapterTaskConfig.yaml
26-
file: configs/base/adapters/adapter1/adapter-task-config.yaml
26+
file: configs/oci/adapters/adapter1/adapter-task-config.yaml

0 commit comments

Comments
 (0)