Skip to content

Commit 581e63f

Browse files
committed
add concise design document for ADR
1 parent 4ad0664 commit 581e63f

2 files changed

Lines changed: 193 additions & 16 deletions

File tree

hive_removal_design.md

Lines changed: 63 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,10 @@ kubernetescli, err := kubernetes.NewForConfig(restConfig)
106106

107107
**AKS Cluster Connection:**
108108
- Uses existing `getAksShardKubeconfig()` function
109-
- Connects to `aro-aks-cluster-{shard:03d}` (same clusters where Hive runs)
109+
- **Connects to the same AKS clusters where Hive currently runs** (`aro-aks-cluster-{shard:03d}`)
110110
- Retrieves admin credentials via `ListClusterAdminCredentials()`
111111
- Caches credentials in liveconfig with RWMutex
112+
- **No new infrastructure required** - reuses existing AKS clusters and client setup from Hive
112113

113114
### 4. Monitoring and Error Handling
114115

@@ -137,6 +138,9 @@ Adapt `pkg/hive/failure/handler.go` patterns to parse installer logs and map to
137138

138139
Return structured CloudError for user-facing error messages.
139140

141+
**Log Parsing Migration:**
142+
The RP already parses install logs from Hive's output via regex matching. This logic needs to be reimplemented directly in `pkg/aksinstall` to parse logs from the provision pod instead of from Hive's nested output. Since we'll be reading installer logs directly (not through Hive's wrapper), this change will **simplify the parsing logic** - no need to extract installer output from Hive's formatting, just read the pod logs directly.
143+
140144
**Cleanup Strategy:**
141145
- **On success:** Delete pod, delete all secrets, delete namespace
142146
- **On failure:** Delete pod, delete secrets, **keep namespace** for 24h debugging
@@ -179,11 +183,19 @@ func (m *manager) runAKSInstaller(ctx context.Context) error {
179183
**Modify `bootstrap()` method** (around line 440-470):
180184
- **Remove:** `hiveCreateNamespace`, `runHiveInstaller`, `hiveClusterInstallationComplete` steps
181185
- **Remove:** `hiveEnsureResources`, `hiveClusterDeploymentReady` steps (adoption flow)
182-
- **Replace with:** Direct call to `runAKSInstaller` with same pattern as `runPodmanInstaller`
186+
- **Replace with:** Environment-based routing to enable gradual rollout
183187

184-
**Before:**
188+
**Implementation with Environment Toggle:**
185189
```go
186-
if m.installViaHive {
190+
// Check environment variable to enable AKS installer mode
191+
// This allows testing in local dev, INT, and canary before full rollout
192+
if m.env.DeploymentMode() == deployment.Development || m.env.FeatureIsSet(env.FeatureUseAKSInstaller) {
193+
s = append(s,
194+
steps.Action(m.runAKSInstaller),
195+
steps.Action(m.generateKubeconfigs),
196+
)
197+
} else if m.installViaHive {
198+
// Legacy Hive path (to be removed after validation)
187199
s = append(s,
188200
steps.Action(m.hiveCreateNamespace),
189201
steps.Action(m.runHiveInstaller),
@@ -193,14 +205,13 @@ if m.installViaHive {
193205
}
194206
```
195207

196-
**After:**
197-
```go
198-
// All cluster installations now use AKS direct
199-
s = append(s,
200-
steps.Action(m.runAKSInstaller),
201-
steps.Action(m.generateKubeconfigs),
202-
)
203-
```
208+
**Feature Flag:**
209+
- Add `FeatureUseAKSInstaller` to `pkg/env/env.go`
210+
- Enable in local development mode by default
211+
- Enable in INT/canary via environment variable for testing
212+
- Once validated, remove Hive path and feature flag entirely
213+
214+
This approach allows safe testing in controlled environments before full rollout.
204215

205216
### 6. Complete Hive Removal
206217

@@ -315,6 +326,34 @@ m.emitGauge("aksinstall.pod.phase", 1, map[string]string{"phase": podPhase})
315326

316327
This ensures we have equal or better observability compared to Hive monitoring, but during installation rather than as periodic monitoring.
317328

329+
### 9. Alerting and Incident Automation
330+
331+
**Alerting Updates:**
332+
Our existing Hive alerting monitors pods in the AKS clusters where Hive runs. Since the new installer pods will run in the **same AKS clusters**, the alerting infrastructure requires minimal changes:
333+
- **Alert queries need updated namespace filters**: Change from monitoring Hive-managed namespaces to monitoring `aro-*` namespaces
334+
- **Alert names may need updates**: Rename from "Hive installer failure" to "ARO installer failure" for clarity
335+
- No infrastructure changes required - already monitoring non-Hive namespaced pods in these AKS clusters
336+
337+
**Incident Automation Updates:**
338+
The automation between alert firing and incident creation currently assumes:
339+
- Installer logs are nested within Hive's output format
340+
- Specific Hive metadata is available in logs
341+
- ClusterDeployment status fields exist
342+
343+
**Changes Required:**
344+
1. **Log query simplification**: Queries become simpler since installer output is direct (not nested in Hive formatting)
345+
2. **Remove Hive-specific fields**: Stop querying ClusterDeployment status, Hive conditions, etc.
346+
3. **Update log parsing**: Read pod logs directly from `aro-{docID}` namespaces instead of from Hive controller logs
347+
4. **Preserve correlation data**: Ensure pod labels/annotations include request IDs, client principal, subscription ID for incident routing
348+
349+
**Example Query Change:**
350+
```
351+
Before: kubectl logs -n hive hive-clustersync-0 | grep "cluster-{uuid}" | extract installer output
352+
After: kubectl logs -n aro-{uuid} installer-{uuid} | direct installer output
353+
```
354+
355+
The automation becomes **simpler and more reliable** since we eliminate the indirection through Hive's log aggregation.
356+
318357
## Critical Files
319358

320359
### Files to Create:
@@ -327,14 +366,17 @@ This ensures we have equal or better observability compared to Hive monitoring,
327366
7. `pkg/aksinstall/metrics.go` - Metrics helper methods (emitGauge, emitFloat)
328367

329368
### Files to Modify:
330-
7. `pkg/cluster/install.go` - Add `runAKSInstaller()`, modify `bootstrap()` to remove Hive paths
369+
7. `pkg/cluster/install.go` - Add `runAKSInstaller()`, modify `bootstrap()` to add environment-based routing
331370
8. `pkg/cluster/cluster.go` - Remove `hiveClusterManager` field, add `liveConfig` if not present
332371
9. `pkg/backend/openshiftcluster.go` - Remove Hive client creation
333372
10. `pkg/monitor/monitor.go` - Remove Hive monitor builder
334373
11. `pkg/frontend/frontend.go` - Remove SyncSet admin API routes and hiveSyncSetManager field
335374
12. `pkg/util/liveconfig/hive.go` - Remove Hive feature flags, optionally rename `HiveRestConfig`
336-
13. `go.mod` - Remove Hive dependencies
337-
14. `pkg/api/go.mod` - Remove Hive dependencies if present
375+
13. `pkg/env/env.go` - Add `FeatureUseAKSInstaller` feature flag
376+
14. `go.mod` - Remove Hive dependencies (after full rollout)
377+
15. `pkg/api/go.mod` - Remove Hive dependencies if present (after full rollout)
378+
16. **Alerting configurations** - Update namespace filters from Hive namespaces to `aro-*` namespaces
379+
17. **Incident automation queries** - Simplify log extraction to read directly from installer pods
338380

339381
### Files to Delete:
340382
15. `pkg/hive/*.go` - All files in hive package
@@ -408,7 +450,12 @@ After implementation, verify the changes work correctly:
408450

409451
**Risk 3: Direct Replacement (No Gradual Rollout)**
410452
- Impact: All new clusters immediately use new code path, higher risk if bugs exist
411-
- Mitigation: Thorough testing in dev/int, fast rollback capability, comprehensive error handling
453+
- Mitigation: **Environment-based feature flag** (`FeatureUseAKSInstaller`) enables gradual rollout:
454+
- Enabled in local development by default for testing
455+
- Enabled in INT environment for integration testing
456+
- Enabled in canary/production regions for controlled rollout
457+
- Fast rollback by disabling feature flag if issues arise
458+
- Thorough testing at each stage before broader rollout
412459

413460
## Out of Scope
414461

hive_removal_design_concise.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# Hive Removal - Implementation Overview
2+
3+
## Current State
4+
5+
Today, ARO-RP uses Hive (an external OpenShift controller) as an intermediary to manage cluster installations:
6+
- ARO-RP creates a `ClusterDeployment` custom resource in AKS
7+
- Hive watches this resource and creates/manages the installer pod
8+
- ARO-RP polls Hive for installation status
9+
10+
## Proposed Solution
11+
12+
Rather than Hive, ARO-RP itself will create and manage OpenShift installer pods directly in AKS. We already have a working implementation for local development (`pkg/containerinstall`) that runs the installer in podman. This proposal adapts that same pattern to use Kubernetes clients for production AKS clusters.
13+
14+
## Implementation Overview
15+
16+
### 1. New ARO-RP Package: `pkg/aksinstall`
17+
18+
We will create installer pods directly in AKS using the Kubernetes API using the same `ContainerInstaller` interface as the existing podman-based installer. There will be shared logic between this new package and the existing `pkg/containerinstall`, but with different clients. Re-use of the existing `pkg/containerinstall` package with environment-specific configuration is also possible, if preferred.
19+
20+
**Installation flow** (same steps used today in Hive):
21+
```
22+
1. Create namespace (aro-{clusterID})
23+
2. Create secrets (cluster config, credentials, manifests)
24+
3. Create installer pod
25+
4. Monitor pod until completion (60min timeout)
26+
5. Cleanup (delete pod/secrets, keep namespace on failure for debugging)
27+
```
28+
29+
### 2. Infrastructure Reuse
30+
31+
- We will re-use the same AKS clusters where Hive currently runs (`aro-aks-cluster-{shard}`) as well as AKS client code from `pkg/util/liveconfig/hive.go`
32+
- We will continue the same namespace pattern, same credential retrieval, and same admin access
33+
34+
At first, the installer pods will be neighbors to the current Hive pods, then Hive will be removed.
35+
36+
### 3. Pod Specification
37+
38+
There are no changes required here. The installer pod runs the standard OpenShift installer with mounted configuration. It uses an OpenShift installer image from version catalog and runs `openshift-install create manifests && openshift-install create cluster`.
39+
40+
**Installer Pod Contents**:
41+
- Azure credentials and cluster config from Kubernetes secrets
42+
- Custom manifests (workload identity, disabled samples)
43+
- Temporary volumes for installer working directories
44+
45+
**Installer Pod Labels** for identification and monitoring:
46+
- `aro-cluster-id: {uuid}`
47+
- `aro-installer: true`
48+
49+
### 4. Operability and Observability
50+
51+
There will be a small amount of work required to transfer over our exiting Hive observability to the new ARO-RP flow:
52+
53+
**Pod monitoring** (`pkg/aksinstall/pod.go`):
54+
- Implement `podFinished()` using pattern from `pkg/containerinstall/install.go:170-186` (containerFinished)
55+
- Replace podman API (`containers.Inspect`) with K8s API (`pods.Get().Status.Phase`)
56+
- On failure, replace `getContainerLogs()` with `kubernetescli.CoreV1().Pods().GetLogs()`
57+
- Keep 60-minute timeout from existing implementation
58+
59+
**Error parsing / regex changes** (`pkg/aksinstall/failure.go`):
60+
- Copy regex patterns and error mapping from `pkg/hive/failure/handler.go`
61+
- Remove Hive log unwrapping logic (installer output is direct, not nested in Hive's JSON)
62+
- Keep CloudError type mappings: `AzureRequestDisallowedByPolicy`, `AzureZonalAllocationFailed`, etc.
63+
64+
**New Metrics Required** (`pkg/aksinstall/install.go`):
65+
- Add metrics emission similar to Hive's current metrics but with `aksinstall.*` prefix
66+
- Installation lifecycle: `started`, `succeeded`, `failed`, `duration`, `failed.reason`
67+
68+
**Alerting and IcM automation changes**:
69+
- Update namespace filters: `namespace=~"hive.*"``namespace=~"aro-.*"`
70+
- Rename alert titles for clarity
71+
- Simplify log queries: remove Hive controller log parsing, read pod logs directly
72+
- Remove ClusterDeployment CRD queries
73+
- Update correlation data source: pod labels instead of ClusterDeployment annotations
74+
75+
### 5. Rollout Strategy
76+
77+
**Environment-based rollout using RP_FEATURES / RP-Config**:
78+
79+
The changes can be fully rolled out before we go live using RP-Config / RP features. We will keep Hive intact during the rollout in case there are issues. We can easily disable the RP feature flag to revert to Hive path if issues arise.
80+
81+
```go
82+
if m.env.DeploymentMode() == development || m.env.FeatureIsSet(FeatureUseAKSInstaller) {
83+
// New path: direct AKS installer
84+
s = append(s,
85+
steps.Action(m.runAKSInstaller),
86+
steps.Action(m.generateKubeconfigs),
87+
)
88+
} else if m.installViaHive {
89+
// Legacy path (to be removed after validation)
90+
s = append(s, hive installation steps...)
91+
}
92+
```
93+
94+
**Phase 1: Development and Testing**
95+
- Implement `pkg/aksinstall` package
96+
- Enable feature flag in local development
97+
- Validate successful installations in dev environment
98+
99+
**Phase 2: Staging Environment**
100+
- Enable feature flag in STG
101+
- Run integration tests (successful install, workload identity clusters, error handling)
102+
- Validate metrics and alerting
103+
104+
**Phase 3: Canary Rollout**
105+
- Enable in canary region(s)
106+
- Monitor installation success rate
107+
- Validate incident automation with real failures
108+
109+
**Phase 4: Production and Cleanup**
110+
- Enable in all production regions
111+
- Monitor for issues
112+
- Once stable, proceed to Hive cleanup
113+
114+
### 6. Hive Cleanup Scope
115+
116+
- Remove `pkg/hive/` integration code
117+
- Remove `pkg/monitor/hive/` monitoring (redundant)
118+
- Remove Admin APIs for Hive SyncSets (unused read-only endpoints)
119+
- Cluster manager: Remove `hiveClusterManager` field and wrapper methods
120+
- Backend: Remove Hive client creation
121+
- Monitor: Remove Hive monitor from monitoring chain
122+
- Frontend: Remove SyncSet admin API routes
123+
- Remove Hive imports from all files
124+
- Remove Hive dependencies from `go.mod` (both modules)
125+
- Remove Hive-related environment variables
126+
127+
**Why complete removal is safe**:
128+
- Hive monitoring is redundant - ARO already monitors cluster health directly
129+
- SyncSet functionality is unused - ARO has read-only APIs but never creates SyncSets
130+
- No ongoing cluster management - Hive just maintains status that duplicates existing monitoring

0 commit comments

Comments
 (0)