Skip to content

Commit 3a65e32

Browse files
Merge pull request #13 from OpenCHAMI/feature/upgrade-fabrica-4-4
Feature/upgrade fabrica 4.5
2 parents e31cf76 + 10a0a0c commit 3a65e32

25 files changed

Lines changed: 1155 additions & 1838 deletions

.github/copilot-instructions.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,17 @@ GOPROXY=direct go build -o bin/boot-service ./cmd/server
5959
make build
6060
```
6161

62-
**Note**: `go.mod` has `replace github.com/openchami/fabrica => ../fabrica` for local development.
63-
6462
### Running
6563

6664
```bash
6765
# Copy and edit config first
6866
cp config.example.yaml config.yaml
6967

7068
# Run with config file
71-
./bin/boot-service serve
69+
./bin/server serve
7270

7371
# Override with flags
74-
./bin/boot-service serve --port 8082 --enable-auth --hsm-url http://localhost:27779
72+
./bin/server serve --port 8082 --enable-auth --hsm-url http://localhost:27779
7573
```
7674

7775
### Testing
@@ -148,7 +146,7 @@ Three templates exist: `DefaultIPXETemplate`, `MinimalIPXETemplate`, `ErrorIPXET
148146

149147
### TokenSmith Integration
150148

151-
Authentication is **optional** and controlled via config. Three modes:
149+
The repository contains a reusable `pkg/auth` package with three common modes:
152150

153151
```go
154152
// Development - auth disabled
@@ -163,6 +161,11 @@ config.JWKSURL = "https://auth.openchami.org/.well-known/jwks.json"
163161
config.RequiredScopes = []string{"boot:read"}
164162
```
165163

164+
**Important current runtime note**: the standalone server in `cmd/server/main.go`
165+
does not currently attach `pkg/auth.CreateMiddleware(...)` to its route tree.
166+
`enable_auth` currently affects startup validation and TokenSmith-backed HSM
167+
service-token exchange, not documented request-time route enforcement.
168+
166169
### Middleware Application
167170

168171
**IMPORTANT**: Apply middleware to router **before** registering routes:
@@ -200,35 +203,38 @@ Common scopes: `boot:read`, `boot:write`, `boot:admin`, `node:read`, `node:write
200203
# config.yaml structure
201204
port: 8080
202205
enable_auth: false
203-
enable_metrics: true
206+
enable_metrics: false
204207
enable_legacy_api: true
208+
# metrics_port is configured separately because it becomes active as soon as
209+
# metrics are enabled, even though metrics default to off.
210+
metrics_port: 9090
205211
hsm_url: "http://localhost:27779"
206-
207-
auth:
208-
enabled: false
209-
jwks_url: "https://auth.example.com/.well-known/jwks.json"
210-
required_scopes: ["boot:read"]
212+
tokensmith_url: "http://localhost:8080"
211213
```
212214
213-
Environment variables use prefix `BOOT_SERVICE_` (e.g., `BOOT_SERVICE_PORT=8082`).
215+
Environment variables use prefix `BOOT_SERVICE_` for standard server settings,
216+
plus `TOKENSMITH_*` for bootstrap-token exchange settings.
214217

215218
## External Service Integration
216219

217220
### HSM (Hardware State Manager)
218221

219222
**Auto-enabled** when `--hsm-url` flag is provided or `hsm_url` is set in config.
220223

221-
**Current Status**: HSM client is initialized and validates connectivity, but not yet fully integrated into the boot script generation pipeline.
224+
**Current Status**: HSM-backed node resolution is wired into the server through
225+
`FlexibleBootScriptController` in `cmd/server/server_extensions.go` when
226+
`hsm_url` is configured.
222227

223228
**Implementation**:
224229
- HSM client: `pkg/clients/hsm/client.go` - HTTP client for HSM v2 API with caching
225230
- Integration service: `pkg/clients/hsm/integration.go` - Wraps HSM client with node provider interface
226231
- Flexible controller: `pkg/controllers/bootscript/flexible_controller.go` - Supports pluggable node providers
227232

228-
**Integration Options** (see TODOs in `cmd/server/main.go`):
229-
1. **FlexibleBootScriptController**: Use `NewFlexibleBootScriptController` with HSM provider config
230-
2. **Controller-level**: Add NodeProvider parameter to BootScriptController
231-
3. **Storage-level**: Add HSM fallback in storage.GetNode() for transparent integration
233+
**Current Integration Path**:
234+
1. Build an HSM client in `cmd/server/main.go`
235+
2. Create `FlexibleBootScriptController` in `cmd/server/server_extensions.go`
236+
3. Register legacy routes with `NewLegacyHandlerWithController(...)`
237+
4. Start optional HSM background sync when enabled
232238

233239
**Node resolution with HSM** (when integrated):
234240
- XName lookups: Direct HSM component query (`/hsm/v2/State/Components/{xname}`)
@@ -237,7 +243,9 @@ Environment variables use prefix `BOOT_SERVICE_` (e.g., `BOOT_SERVICE_PORT=8082`
237243

238244
**Caching**: HSM responses are cached (default: 5 minutes) to reduce load on HSM service.
239245

240-
**Current Limitation**: Legacy BSS API handlers use standard BootScriptController which queries local storage only. To enable HSM for boot scripts, modify handlers to accept controller interface and pass FlexibleBootScriptController instance.
246+
**Current Limitation**: The legacy `/boot/v1/bootscript` HTTP route ignores the
247+
`profile` query parameter and always asks the controller to auto-resolve the
248+
best configuration across profiles.
241249

242250
### TokenSmith
243251

.github/workflows/codegen-check.yaml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,5 @@ jobs:
3131
with:
3232
go-version: stable
3333

34-
- name: Run code generation
35-
run: make generate
36-
3734
- name: Verify generated code is committed
38-
run: |
39-
if ! git diff --quiet; then
40-
echo "Generated files are out of sync. Run 'make generate' and commit the results."
41-
git --no-pager diff --stat
42-
exit 1
43-
fi
35+
run: make generate-check

.github/workflows/golangci-lint.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ on:
1212
jobs:
1313
lint:
1414
runs-on: ubuntu-latest
15-
15+
1616
steps:
1717
- name: Set up latest stable Go
1818
uses: actions/setup-go@v6.4.0

CHANGELOG.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
<!--
2+
SPDX-FileCopyrightText: 2026 OpenCHAMI Contributors
3+
4+
SPDX-License-Identifier: MIT
5+
-->
6+
7+
# Changelog
8+
9+
All notable changes to this project will be documented in this file.
10+
11+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
12+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
13+
14+
Changes remain under `Unreleased` until they ship in the next tagged release.
15+
16+
## [Unreleased]
17+
18+
### Added
19+
20+
- Added `GET /health` and a generated `client health` command for quick service checks.
21+
- Added OpenAPI publication endpoints at `GET /openapi.json` and `GET /docs`.
22+
- Added `PATCH` operations for `BMC`, `BootConfiguration`, and `Node` resources.
23+
- Added custom validation hooks for `BMC`, `BootConfiguration`, and `Node` handlers.
24+
25+
### Changed
26+
27+
- Regenerated server, client, storage, and OpenAPI surfaces against Fabrica `v0.4.5`.
28+
- Updated generated file headers to include Fabrica version metadata.
29+
- Updated the Docker release build to pass dynamic build arguments into image builds.
30+
- Tightened code generation drift checks around the current Fabrica workflow.
31+
- Documented the generated service endpoints added in this release, including `/health`, `/openapi.json`, and `/docs`.
32+
33+
## [0.1.4] - 2026-05-06
34+
35+
### Added
36+
37+
- Added HSM group membership lookups and response caching to improve node resolution.
38+
39+
### Changed
40+
41+
- Added missing configuration aliases used by HSM-related settings.
42+
43+
### Fixed
44+
45+
- Cleaned up HSM client handling and a small lint-related response body close issue.
46+
47+
## [0.1.3] - 2026-05-05
48+
49+
### Added
50+
51+
- Added the legacy boot script endpoint behind the `enable_legacy_api` feature flag.
52+
- Added explicit code generation drift checks via `make generate-check`.
53+
54+
### Changed
55+
56+
- Clarified boot profile behavior and validation in the docs.
57+
- Changed empty-profile boot script selection to auto-resolve the best matching configuration across profiles.
58+
- Updated the local Fabrica workflow in the Makefile and regenerated outputs for the newer generator.
59+
- Refactored server integration setup for clearer handler registration.
60+
61+
## [0.1.2] - 2026-04-26
62+
63+
### Fixed
64+
65+
- Added the missing OpenAPI API routes.
66+
67+
## [0.1.1] - 2026-04-15
68+
69+
### Changed
70+
71+
- Added Docker Buildx setup with a custom build image in the release pipeline.
72+
73+
## [0.1.0] - 2026-04-15
74+
75+
### Added
76+
77+
- Initial tagged release of the Fabrica-generated boot-service API.
78+
- File-backed `BMC`, `BootConfiguration`, and `Node` resource APIs.
79+
- Legacy BSS-compatible boot endpoints and generated Go client support.
80+
81+
[Unreleased]: https://github.com/OpenCHAMI/boot-service/compare/v0.1.4...HEAD
82+
[0.1.4]: https://github.com/OpenCHAMI/boot-service/compare/v0.1.3...v0.1.4
83+
[0.1.3]: https://github.com/OpenCHAMI/boot-service/compare/v0.1.2...v0.1.3
84+
[0.1.2]: https://github.com/OpenCHAMI/boot-service/compare/v0.1.1...v0.1.2
85+
[0.1.1]: https://github.com/OpenCHAMI/boot-service/compare/v0.1.0...v0.1.1

Makefile

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ TEST_TIMEOUT ?= 5m
1313
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
1414
COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
1515
DATE ?= $(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
16+
DOCKER_GO_VERSION ?= $(shell awk '/^go / {print $$2; exit}' go.mod)
17+
FABRICA_VERSION ?= $(shell awk '/github.com\/openchami\/fabrica[[:space:]]+v/ {print $$2; exit}' go.mod)
1618
LDFLAGS=-ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.date=$(DATE)"
17-
FABRICA_CMD ?= go run github.com/openchami/fabrica/cmd/fabrica@latest
19+
FABRICA_CMD ?= go run github.com/openchami/fabrica/cmd/fabrica@$(FABRICA_VERSION)
1820
FABRICA_SOURCE_ARG ?=
21+
FABRICA_FORCE_FLAG ?=
1922
FABRICA_ENV ?=
2023
LOCAL_FABRICA ?=
2124

2225
ifneq ($(strip $(LOCAL_FABRICA)),)
2326
FABRICA_CMD := $(LOCAL_FABRICA)/bin/fabrica
2427
FABRICA_SOURCE_ARG := --fabrica-source $(LOCAL_FABRICA)
28+
FABRICA_FORCE_FLAG := --force
2529
FABRICA_ENV := GOTOOLCHAIN=auto
2630
endif
2731

@@ -41,7 +45,7 @@ ifneq ($(strip $(LOCAL_FABRICA)),)
4145
exit 1; \
4246
fi
4347
endif
44-
$(FABRICA_ENV) $(FABRICA_CMD) generate $(FABRICA_SOURCE_ARG)
48+
$(FABRICA_ENV) $(FABRICA_CMD) generate $(FABRICA_SOURCE_ARG) $(FABRICA_FORCE_FLAG)
4549

4650
generate-check: ## Fail if generated files are out of sync (requires clean git tree)
4751
@if ! git diff --quiet || ! git diff --cached --quiet; then \
@@ -85,7 +89,12 @@ run: build ## Build and run the application
8589
./bin/$(BINARY_NAME)
8690

8791
docker-build: ## Build Docker image
88-
docker build -t $(BINARY_NAME):latest .
92+
docker build -f Dockerfile.standalone \
93+
--build-arg GO_VERSION=$(DOCKER_GO_VERSION) \
94+
--build-arg VERSION=$(VERSION) \
95+
--build-arg COMMIT=$(COMMIT) \
96+
--build-arg DATE=$(DATE) \
97+
-t $(BINARY_NAME):latest .
8998

9099
docker-run: docker-build ## Build and run Docker container
91100
docker run --rm $(BINARY_NAME):latest

0 commit comments

Comments
 (0)