Skip to content

Feature/upgrade fabrica#7

Merged
alexlovelltroy merged 28 commits intomainfrom
feature/upgrade-fabrica
Apr 15, 2026
Merged

Feature/upgrade fabrica#7
alexlovelltroy merged 28 commits intomainfrom
feature/upgrade-fabrica

Conversation

@alexlovelltroy
Copy link
Copy Markdown
Member

Description

This pull request migrates the project’s resource definitions to a new structure under apis/boot.openchami.io/v1, updates the code generation and validation pipeline, and deprecates the old pkg/resources tree. It introduces new Fabrica configuration files, updates documentation and Makefile workflows, and refactors generated handlers and client code to use the new API types. The most important changes are grouped below.

Resource API migration and deprecation:

  • Introduced new resource type definitions for BMC, BootConfiguration, and Node in apis/boot.openchami.io/v1/, replacing the old pkg/resources structure. These types now use a flat Fabrica-compatible schema with explicit APIVersion, Kind, and Metadata fields, and implement custom validation logic.
  • Deprecated the pkg/resources/* tree for resource definitions; all new code should use the new apis/boot.openchami.io/v1/ location.

Fabrica 0.4.0 integration and configuration:

  • Added .fabrica.yaml and apis.yaml to define the project’s Fabrica code generation settings and resource groups, enabling strict validation, file-based storage, and generation of handlers, storage, client, and OpenAPI artifacts.

  • Updated documentation (README.md) to describe the new Fabrica source inputs and regeneration workflow.
    Build and code quality enforcement:

  • Updated the Makefile to reflect the new binary name, and added a check-no-pkg-resources-imports target to prevent new code from importing deprecated pkg/resources modules.

Generated handlers and client refactoring:

  • Refactored generated handler code (e.g., cmd/server/bmc_handlers_generated.go) to use the new v1 API types, update metadata handling, and improve validation layering. Also updated comments to reflect new versioning and codegen practices.
  • Updated generated client code to reference the new API types in documentation and code examples.

Checklist

  • My code follows the style guidelines of this project
  • I have added/updated comments where needed
  • I have added tests that prove my fix is effective or my feature works
  • I have run make test (or equivalent) locally and all tests pass
  • DCO Sign-off: All commits are signed off (git commit -s) with my real name and email
  • REUSE Compliance:
    • Each new/modified source file has SPDX copyright and license headers
    • Any non-commentable files include a <filename>.license sidecar
    • All referenced licenses are present in the LICENSES/ directory

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation update

For more info, see Contributing Guidelines.

@alexlovelltroy alexlovelltroy force-pushed the feature/upgrade-fabrica branch from 8222c00 to 0d5b655 Compare April 2, 2026 22:13
@alexlovelltroy
Copy link
Copy Markdown
Member Author

I didn't try to incorporate the new tokensmith middleware yet.

Copy link
Copy Markdown

@synackd synackd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial code review. Still need to build and run it. Unit tests pass.

Comment thread pkg/resources/bootconfiguration/bootconfiguration.go
Comment thread cmd/server/bmc_handlers_generated.go Outdated
Comment thread pkg/client/models_generated.go
Comment thread pkg/clients/hsm/integration.go Outdated
Comment thread Makefile Outdated
Comment thread README.md Outdated
@synackd
Copy link
Copy Markdown

synackd commented Apr 2, 2026

I am running into an error with make docker-build because the binary is not found:

$ make docker-build
docker build -t boot-service:latest .
STEP 1/8: FROM gcr.io/distroless/static-debian12:nonroot
Trying to pull gcr.io/distroless/static-debian12:nonroot...
Getting image source signatures
Copying blob 7c12895b777b done   | 
Copying blob 526604835308 done   | 
Copying blob ef49c20a7b35 done   | 
Copying blob 990a9c434e5e done   | 
Copying blob 2780920e5dbf done   | 
Copying blob bf7a4185f015 done   | 
Copying blob 3214acf345c0 done   | 
Copying blob 52630fc75a18 done   | 
Copying blob dd64bf2dd177 done   | 
Copying blob b839dfae01f6 done   | 
Copying blob dcaa5a89b0cc done   | 
Copying blob 069d1e267530 done   | 
Copying config 3a59ed7ba5 done   | 
Writing manifest to image destination
STEP 2/8: WORKDIR /app
--> 26cfc71b3d2c
STEP 3/8: COPY boot-service /usr/local/bin/boot-service
Error: building at STEP "COPY boot-service /usr/local/bin/boot-service": checking on sources under "/opt/shared/boot-service": copier: stat: "/boot-service": no such file or directory
make: *** [Makefile:58: docker-build] Error 125

A couple of suggestions:

  1. Generalize container build target (e.g. container-build/container-run), allowing other runtimes other than Docker (e.g. Podman) for builds, as well as specifying tags, etc. (See [1] [2] [3] [4])
  2. Either combine the Dockerfiles or have the container build target use the standalone one.
    • If we want to separate the Goreleaser Dockerfile from the multi-stage build Dockerfile, we should have the container build Make target use the latter. Else if we consolidate the Dockerfiles, we should have the build Make target put the binaries in the repo root and name them (as Goreleaser does, e.g. boot-service and boot-service-client) so the single Dockerfile will find them (we'll also need to make sure the container build target lists the binaries as prerequisites)
    • CoreSMD uses a consolidated Dockerfile. See [4] [5]

Comment thread go.mod Outdated
Comment thread go.mod Outdated
@synackd
Copy link
Copy Markdown

synackd commented Apr 3, 2026

Getting the following error trying to add a boot config:

$ ./bin/client bootconfiguration create --server https://demo.openchami.cluster:8443/boot-service --spec '{
        "hosts": ["host1"],
        "kernel": "http://s3.openchami.cluster/kernels/vmlinuz1",
        "initrd": "http://s3.openchami.cluster/initrds/initramfs1.img",
        "params": "console=tty0,115200n8 console=ttyS0,115200n8",
        "priority": 42
      }'
Error: failed to create BootConfiguration: API error (500): failed to generate UID: resource kind 'BootConfiguration' is not registered - call RegisterResourcePrefix() first
Usage:

@alexlovelltroy
Copy link
Copy Markdown
Member Author

I am running into an error with make docker-build because the binary is not found:

STEP 3/8: COPY boot-service /usr/local/bin/boot-service
Error: building at STEP "COPY boot-service /usr/local/bin/boot-service": checking on sources under "/opt/shared/boot-service": copier: stat: "/boot-service": no such file or directory

I wonder if we're better off just removing this make target and Dockerfile.standalone in favor of a completely different process for making local docker containers for testing. As you mention in your comment, addressing all of the possible ways this might be used outside the release process is challenging. Let's save that for outside the context of the PR though.

I have created #8 to further discuss what to do so it doesn't get lost.

@alexlovelltroy
Copy link
Copy Markdown
Member Author

Getting the following error trying to add a boot config:

$ ./bin/client bootconfiguration create --server https://demo.openchami.cluster:8443/boot-service --spec '{
        "hosts": ["host1"],
        "kernel": "http://s3.openchami.cluster/kernels/vmlinuz1",
        "initrd": "http://s3.openchami.cluster/initrds/initramfs1.img",
        "params": "console=tty0,115200n8 console=ttyS0,115200n8",
        "priority": 42
      }'
Error: failed to create BootConfiguration: API error (500): failed to generate UID: resource kind 'BootConfiguration' is not registered - call RegisterResourcePrefix() first
Usage:

I believe this will be fixed with the updated changes to the PR in main.go

LastUpdated string `json:"lastUpdated,omitempty"`
AppliedTo []string `json:"appliedTo,omitempty"`
Error string `json:"error,omitempty"`
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add these back too?

import (
"fmt"

v1 "github.com/openchami/boot-service/apis/boot.openchami.io/v1"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the v1 prefix is deleted above, probably should delete it here as well.

@synackd
Copy link
Copy Markdown

synackd commented Apr 4, 2026

Interestingly, it complains that the kernel field is missing despite being present:

$ ./bin/client bootconfiguration create --server https://redondo.usrc.newmexicoconsortium.org:8443/boot-service --spec '{
        "hosts": ["host1"],
        "kernel": "http://s3.openchami.cluster/kernels/vmlinuz1",
        "initrd": "http://s3.openchami.cluster/initrds/initramfs1.img",
        "params": "console=tty0,115200n8 console=ttyS0,115200n8",
        "priority": 42
      }'
Error: failed to create BootConfiguration: API error (400): validation failed: kernel field is required

@synackd
Copy link
Copy Markdown

synackd commented Apr 4, 2026

I am running into an error with make docker-build because the binary is not found:

STEP 3/8: COPY boot-service /usr/local/bin/boot-service
Error: building at STEP "COPY boot-service /usr/local/bin/boot-service": checking on sources under "/opt/shared/boot-service": copier: stat: "/boot-service": no such file or directory

I wonder if we're better off just removing this make target and Dockerfile.standalone in favor of a completely different process for making local docker containers for testing. As you mention in your comment, addressing all of the possible ways this might be used outside the release process is challenging. Let's save that for outside the context of the PR though.

I have created #8 to further discuss what to do so it doesn't get lost.

Sounds good!

@alexlovelltroy
Copy link
Copy Markdown
Member Author

I've added the features from #3 to this PR to simplify the merge train

… versions

Step status: The assistant executed only Step 2 of the approved OpenCHAMI migration plan for `boot-service`: update module definitions and Fabrica generation source inputs, without regeneratin…

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Step status: The assistant was instructed to execute only Step 3 of the approved `boot-service` Fabrica migration plan: **regenerate artifacts and normalize generated outputs**, while preservi…

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
… behavior

Step status: The conversation covered **Step 4** of the approved migration plan for `repos/boot-service`: **repair integration points while preserving legacy compatibility** after Step 3 had n…

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Step status: The conversation executed **Step 5/7** of the approved OpenCHAMI migration plan for `repos/boot-service`: **“Reconcile tests and add targeted compatibility coverage.”** The goal w…

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Step status: The conversation executed **Step 6/7** of the approved OpenCHAMI migration plan for `repos/boot-service`: **“Run CI-equivalent validation from a clean state.”** The assistant was…

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Step status: The conversation executed **Step 7/7** of the approved OpenCHAMI migration plan for `repos/boot-service`: **“Update documentation and prepare final migration summary.”** The assis…

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
- Updated generated models to use new `fabrica` metadata and API definitions.
- Refactored requests for BMC, BootConfiguration, and Node to align with new API structure.
- Removed legacy resource definitions for BMC, BootConfiguration, and Node.
- Updated integration services to utilize new API models and methods.
- Adjusted boot script generation and handling to accommodate new resource structures.
- Enhanced legacy handler compatibility with updated BootConfiguration and Node models.
- Cleaned up documentation and migration plans to reflect changes in resource management.

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
- Added a new `test-integration` target in the Makefile to run integration tests with a configurable timeout.
- Updated test commands to include a timeout for unit tests.
- Enhanced the `TestBootLogicWithExistingData` integration test to automatically start and stop a local boot-service instance.
- Introduced helper functions for starting the test server and seeding integration data.
- Updated generated files to reflect the new versioning and timestamps.
- Added a new `register_generated.go` file to register resources with the generator.
- Improved comments and documentation for clarity.

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
… update README for clarity

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
- Introduced `authz_classifier.go` for customizable request classification.
- Added `authz_classifier_generated.go` for default classifier implementation.
- Updated `main.go` to include new TokenSmith configuration options.
- Enhanced HSM client to support service token management with TokenSmith.
- Implemented `ServiceTokenManager` for handling token exchanges and auto-refresh.
- Updated configuration examples and documentation for new TokenSmith features.
- Added tests for HSM client and service token manager functionalities.

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
- Updated `boot_script_demo.go` to accept an optional profile argument for boot script generation.
- Introduced `profile-requests.sh` to demonstrate various boot script requests with different profiles.
- Added `profiles.yaml` containing example boot configurations for different profiles.
- Modified `GenerateBootScript` method in `BootScriptController` to handle profile selection.
- Implemented logic to fall back to the default profile if the requested profile is not found.
- Added unit tests for profile selection and fallback behavior in `controller_profile_test.go`.
- Updated integration tests to validate profile handling in `integration_existing_test.go`.
- Enhanced legacy handler to support profile query parameter in boot script requests.
- Created tests for legacy handler to ensure correct profile handling in `handlers_test.go`.

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
…enarios

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
alexlovelltroy and others added 4 commits April 9, 2026 13:58
…onfigurations

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
…e token manager integration

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
…eware

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: David Allen <davidallendj@gmail.com>
Signed-off-by: David Allen <davidallendj@gmail.com>
@davidallendj davidallendj force-pushed the feature/upgrade-fabrica branch from 59fee84 to beabcc5 Compare April 9, 2026 19:58
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
…g example

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
…te attest action

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
…kward compatibility for scopes

Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
Signed-off-by: Alex Lovell-Troy <alovelltroy@lanl.gov>
@alexlovelltroy alexlovelltroy merged commit 972a740 into main Apr 15, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants