Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
d26aa7e
docs: add CLAUDE.md configuration file for Claude Code
yanmxa Oct 30, 2025
53eec9b
commit skill
yanmxa Oct 31, 2025
d4ac7dd
feat: enhance globalhub-release skill with container validation and c…
yanmxa Oct 31, 2025
94fdb37
fix: quote shell variables to resolve SonarCloud warnings
yanmxa Oct 31, 2025
c96a897
shell
yanmxa Nov 3, 2025
5c861c7
update
yanmxa Nov 3, 2025
4e8e970
fix global hub
yanmxa Nov 3, 2025
01fdfa2
fix claude 01
yanmxa Nov 3, 2025
62bc571
update bundle
yanmxa Nov 4, 2025
8a488e6
update bundle
yanmxa Nov 4, 2025
c28f64c
update catalog
yanmxa Nov 4, 2025
711f668
update obs and postgres
yanmxa Nov 4, 2025
3dfc766
Fix shellcheck issues in cut-release scripts
yanmxa Nov 4, 2025
c520eec
refactor: replace single brackets with double brackets in shell scripts
yanmxa Nov 4, 2025
eb76f48
refactor: complete shell script quality improvements
yanmxa Nov 4, 2025
d56b605
fix: remove duplicate stderr redirection (>&2 >&2 -> >&2)
yanmxa Nov 4, 2025
c4f50bf
Fix SonarCloud issues in cut-release scripts
yanmxa Nov 5, 2025
990367c
Remove unused constants from 01-multicluster-global-hub.sh
yanmxa Nov 5, 2025
b858385
Define constants for repeated target_branch patterns
yanmxa Nov 5, 2025
e30efa3
refactor: rename CUT_MODE to CREATE_BRANCHES for better clarity
yanmxa Nov 6, 2025
bc624fb
correct prow
yanmxa Nov 11, 2025
fa3943f
feat: add comprehensive PR status tracking for all release scripts
yanmxa Nov 11, 2025
5cf0c46
fix: correct tekton pipeline version replacements in catalog script
yanmxa Nov 11, 2025
633e999
fix: enable automatic PR updates and fix version replacements
yanmxa Nov 11, 2025
9a0e86a
feat: add Containerfile.catalog management in catalog script
yanmxa Nov 11, 2025
8507589
fix: correctly update both FROM instructions in Containerfile.catalog
yanmxa Nov 11, 2025
bf34a8f
fix: do not update builder stage OCP version in Containerfile.catalog
yanmxa Nov 11, 2025
12cef1d
feat: add catalog-template-current.json update logic
yanmxa Nov 11, 2025
2cc3f03
release update
yanmxa Nov 13, 2025
1bb762d
refactor: optimize script 01 for release workflow
yanmxa Nov 13, 2025
4b333d9
update
yanmxa Nov 13, 2025
ee3c013
feat: add GitHub workflow bundle branch update in script 01
yanmxa Nov 13, 2025
2dd1bf0
feat: update ACM version in CSV documentation URL
yanmxa Nov 13, 2025
93fea89
feat: update CSV maturity and renovate.json baseBranches in script 01
yanmxa Nov 13, 2025
0591cad
feat: update all Containerfile.catalog files with new bundle reference
yanmxa Nov 17, 2025
a5058f4
docs: add concise release update checklist to README
yanmxa Nov 17, 2025
a08eef4
refactor: rename skill from cut-release to new-release
yanmxa Nov 17, 2025
2f0513d
improve: optimize release scripts to avoid unnecessary changes
yanmxa Nov 18, 2025
78c1e8d
improve: only show PR review info when actual PRs are created
yanmxa Nov 18, 2025
9b60223
fix: improve PR URL extraction to avoid wrong repo PRs
yanmxa Nov 18, 2025
84de4e4
fix: skip PR creation when branch is identical to upstream/main
yanmxa Nov 18, 2025
3e847ec
fix: correctly preserve createdAt timestamp in bundle CSV
yanmxa Nov 18, 2025
e8467fc
fix: always create PR branch from latest upstream/main
yanmxa Nov 18, 2025
fde3d45
fix: prevent bundle PR when content is already correct
yanmxa Nov 18, 2025
2be85a6
fix: copy bundle AS-IS without any modifications
yanmxa Nov 18, 2025
3df9b78
fix: use exact title match for PR search in bundle script
yanmxa Nov 18, 2025
fac66c8
fix: always use main branch as bundle source
yanmxa Nov 18, 2025
37c10dc
fix: fetch bundle from upstream/main instead of origin/main
yanmxa Nov 18, 2025
5a4a2cb
fix: ignore createdAt timestamp-only changes in bundle
yanmxa Nov 18, 2025
6fbd2d1
fix: correct grep pattern for createdAt detection
yanmxa Nov 18, 2025
a1c3b53
refactor: improve code quality and performance in release scripts
yanmxa Nov 19, 2025
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
580 changes: 580 additions & 0 deletions .claude/skills/new-release/README.md

Large diffs are not rendered by default.

429 changes: 429 additions & 0 deletions .claude/skills/new-release/SKILL.md

Large diffs are not rendered by default.

1,190 changes: 1,190 additions & 0 deletions .claude/skills/new-release/scripts/01-multicluster-global-hub.sh

Large diffs are not rendered by default.

582 changes: 582 additions & 0 deletions .claude/skills/new-release/scripts/02-openshift-release.sh

Large diffs are not rendered by default.

830 changes: 830 additions & 0 deletions .claude/skills/new-release/scripts/03-bundle.sh

Large diffs are not rendered by default.

1,108 changes: 1,108 additions & 0 deletions .claude/skills/new-release/scripts/04-catalog.sh

Large diffs are not rendered by default.

448 changes: 448 additions & 0 deletions .claude/skills/new-release/scripts/05-grafana.sh

Large diffs are not rendered by default.

450 changes: 450 additions & 0 deletions .claude/skills/new-release/scripts/06-postgres-exporter.sh

Large diffs are not rendered by default.

518 changes: 518 additions & 0 deletions .claude/skills/new-release/scripts/cut-release.sh

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ test/setup/report
kubeconfig

__pycache__
output
CLAUDE.md
.claude
output
242 changes: 242 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@

# CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

## Overview

Multicluster Global Hub is a Kubernetes operator-based system for managing ACM/OCM at very high scale. The repository contains three main components:

- **operator**: Deploys and manages the Global Hub infrastructure
- **manager**: Runs on the global hub cluster to sync data to/from PostgreSQL and Kafka
- **agent**: Runs on managed hub clusters to sync data between global hub and managed hubs

Shared code lives in `pkg/`.

## Architecture

### Component Responsibilities

**Operator** (`operator/`):

- Deploys manager (global hub cluster) and agent (managed hub clusters)
- Manages CRD lifecycle and custom resources
- API definitions in `operator/api/`

**Manager** (`manager/`):

- `pkg/spec/`: Syncs resources FROM database TO managed hubs via Kafka
- `specdb/`: Database operations for spec resources
- `controllers/`: Watches and persists resources to database
- `syncers/`: Retrieves from database and sends via transport
- `pkg/status/`: Syncs resource status FROM managed hubs TO database
- `conflator/`: Merges bundles from transport before database insertion
- `dispatcher/`: Routes bundles between transport, conflator, and database
- `handlers/`: Persists transferred bundles to database
- `pkg/controllers/`: Common controllers (migration, backup)
- `pkg/processes/`: Periodic jobs (policy compliance cronjob, managed hub management)
- `pkg/restapis/`: REST APIs for managed clusters, policies, subscriptions
- `pkg/webhook/`: Webhooks for global resources

**Agent** (`agent/`):

- `pkg/spec/`: Applies resources FROM global hub TO managed hub cluster
- `rbac/`: Role-based access control
- `syncers/`: Syncs resources and signals from manager
- `workers/`: Backend goroutines executing spec syncer tasks
- `pkg/status/`: Reports resource status FROM managed hub TO manager via Kafka/Inventory API
- `filter/`: Deduplicates events
- `generic/`: Templates for status syncers
- `controller/`: Specifies resource types to sync
- `handler/`: Updates bundles for watched resources
- `emitter/`: Sends bundles via transport (CloudEvents)
- `multi-event syncer`: Template for multiple events per object (policy syncer)
- `multi-object syncer`: Template for one event per multiple objects (managedhub info syncer)
- `syncers/`: Specific resource syncers using generic templates
- `pkg/controllers/inventory/`: Controllers reporting via Inventory API

**Shared** (`pkg/`):

- `transport/`: Kafka integration (Sarama and Confluent)
- `database/`: PostgreSQL operations (GORM and pgx)
- `bundle/`: Data bundling and compression
- `constants/`, `enum/`, `utils/`: Common utilities

## Build and Development Commands

### Building Images

```bash

# Build and push all component images
make vendor
make build-operator-image push-operator-image IMG=<registry>/multicluster-global-hub-operator:<tag>
make build-manager-image push-manager-image IMG=<registry>/multicluster-global-hub-manager:<tag>
make build-agent-image push-agent-image IMG=<registry>/multicluster-global-hub-agent:<tag>

# Individual component builds
cd operator && make docker-build docker-push IMG=<registry>/multicluster-global-hub-operator:<tag>
cd manager && make
cd agent && make
```

### Deploying

```bash

# Deploy operator to cluster
make deploy-operator # or: cd operator && make deploy IMG=<registry>/...:tag

# Install Global Hub instance
kubectl apply -k operator/config/samples/

# Undeploy
make undeploy-operator # or: cd operator && make undeploy
```

### Code Quality

```bash

# Format code (standard Go formatting)
make fmt

# Strict formatting (gci + gofumpt)
make strict-fmt

# Update dependencies
make tidy
make vendor
```

### Testing

**Unit Tests:**

```bash

# Run all unit tests (requires setup-envtest)
make unit-tests

# Run component-specific unit tests
make unit-tests-operator
make unit-tests-manager
make unit-tests-agent
make unit-tests-pkg
```

**Integration Tests:**

```bash

make integration-test # All integration tests
make integration-test/operator
make integration-test/manager
make integration-test/agent
```

**E2E Tests:**

```bash

# Setup E2E environment (creates KinD clusters)
make e2e-setup

# Run specific E2E test suites
make e2e-test-cluster
make e2e-test-local-agent
make e2e-test-localpolicy
make e2e-test-grafana

# Run all E2E tests
make e2e-test-all

# Cleanup E2E environment
make e2e-cleanup

# E2E test with verbose output
make e2e-test-localpolicy VERBOSE=9
```

**Running Single Tests:**

To run a single test file or function:

```bash
# Unit test - single package
cd operator && KUBEBUILDER_ASSETS="$(setup-envtest use --use-env -p path)" go test -v ./pkg/path/to/package -run TestFunctionName

# Integration test - single test
KUBEBUILDER_ASSETS="$(setup-envtest use --use-env -p path)" go test -v ./test/integration/operator/... -run TestSpecificFunction
```

### Operator-Specific Commands

When modifying operator API definitions:


```bash
cd operator
make generate # Generate code (DeepCopy, etc.)
make manifests # Generate CRDs, RBAC, etc.
make bundle # Generate operator bundle
```

### Logs

Fetch logs from E2E test environment:


```bash
make e2e-log/operator
make e2e-log/manager
make e2e-log/grafana
make e2e-log/agent
```

## Code Formatting Rules

The `make fmt` target enforces import dependency rules:

- `pkg/` must NOT import from `agent/`, `operator/`, or `manager/`
- `operator/` must NOT import from `agent/` or `manager/`
- `agent/` must NOT import from `manager/` or `operator/` (except `operator/api`)
- `manager/` must NOT import from `agent/` or `operator/` (except `operator/api`)

This maintains clean separation between components. Only shared code should live in `pkg/`.

## Testing Guidelines

- Integration tests use envtest and require KUBEBUILDER_ASSETS

- E2E tests create real KinD clusters (configured via MH_NUM, MC_NUM environment variables)
- Test scripts are in `test/script/`
- E2E test configuration is stored in a temporary `CONFIG_DIR`
- When debugging test failures, run tests individually with verbose flags (`-v` for go test, `VERBOSE=9` for E2E scripts)

## Key Dependencies

- **Kubernetes**: v0.33.x (client-go, api, apimachinery)

- **Controller Runtime**: v0.21.x
- **Kafka**: IBM Sarama v1.45.x, Confluent Kafka v2.12.x
- **Database**: GORM v1.30.x, pgx v5.7.x
- **CloudEvents**: v2.16.x
- **ACM/OCM**: Multiple stolostron and open-cluster-management.io dependencies
- **Go Version**: 1.24.4

## Environment Variables

E2E testing:


- `MH_NUM`: Number of managed hub clusters (default: 2)
- `MC_NUM`: Number of managed clusters (default: 1)
- `GH_NAMESPACE`: Global hub namespace (default: multicluster-global-hub)
- `VERBOSE`: Log verbosity level for E2E tests (default: 5)

Build:

- `REGISTRY`: Container registry (default: quay.io/stolostron)
- `IMAGE_TAG`: Image tag (default: latest)
- `GO_TEST`: Go test command override