Skip to content

OSAC-3829: add GPU flags to CLI create instancetype command - #230

Merged
omer-vishlitzky merged 1 commit into
osac-project:mainfrom
Tzif-Morgen:feat/OSAC-3829-gpu-cli-flags
Aug 11, 2026
Merged

omer-vishlitzky merged 1 commit into
osac-project:mainfrom
Tzif-Morgen:feat/OSAC-3829-gpu-cli-flags

Conversation

@Tzif-Morgen

@Tzif-Morgen Tzif-Morgen commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

OSAC-3829: add GPU flags to CLI create instancetype command

Jira: OSAC-3829
Story type: [DEV]

Summary

Adds --gpu-pci-device-selector, --gpu-resource-name, and --gpu-count flags to the osac create instancetype CLI command, enabling Cloud Provider Admins to create GPU-enabled InstanceTypes directly from the CLI. All three GPU flags are required together (all-or-nothing via cobra's MarkFlagsRequiredTogether), and client-side validation ensures gpu-count is greater than zero.

Changes

  • Added three GPU fields to runnerContext and registered corresponding cobra flags
  • Added MarkFlagsRequiredTogether for all-or-nothing GPU flag validation
  • Added client-side gpu-count > 0 validation matching existing cores/memory-gib pattern
  • Wired GPU fields into InstanceTypeSpec_builder via GpuSpec_builder (conditional — only when GPU flags are provided)
  • Added GPU example to longHelp and flag help text constants
  • Added 3 unit tests for GPU flag registration (Ginkgo, matching existing pattern)

Testing

  • Unit tests: 3 new flag registration tests for --gpu-pci-device-selector, --gpu-resource-name, --gpu-count (8/8 pass)
  • Manual: Verified on dev cluster — created GPU instance type via CLI, confirmed GPU fields persisted via get instancetypes -o json
  • Coverage: Cmd() at 100%; run() at 0% (pre-existing — requires live gRPC server)

Acceptance Criteria

  • AC-1: osac create instancetype accepts --gpu-pci-device-selector, --gpu-resource-name, and --gpu-count flags
  • AC-2: When all three GPU flags are provided, the created InstanceType includes a populated gpu spec
  • AC-3: When no GPU flags are provided, behavior is unchanged (backward compatible)
  • AC-4: Partial GPU flags produce a clear validation error
  • AC-5: osac create instancetype --help documents the new GPU flags

Related PRs

Summary by CodeRabbit

  • New Features
    • Added GPU configuration options when creating instance types.
    • Supports specifying the GPU PCI device selector, resource name, and count.
    • Requires all GPU options together and validates that the GPU count is positive.
    • Updated command help with GPU flag descriptions and an example.

@openshift-ci-robot

openshift-ci-robot commented Aug 10, 2026 •

Copy link
Copy Markdown

@Tzif-Morgen: This pull request references OSAC-3829 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set.

Details

In response to this:

OSAC-3829: add GPU flags to CLI create instancetype command

Jira: OSAC-3829
Story type: [DEV]

Summary

Adds --gpu-pci-device-selector, --gpu-resource-name, and --gpu-count flags to the osac create instancetype CLI command, enabling Cloud Provider Admins to create GPU-enabled InstanceTypes directly from the CLI. All three GPU flags are required together (all-or-nothing via cobra's MarkFlagsRequiredTogether), and client-side validation ensures gpu-count is greater than zero.

Changes

  • Added three GPU fields to runnerContext and registered corresponding cobra flags
  • Added MarkFlagsRequiredTogether for all-or-nothing GPU flag validation
  • Added client-side gpu-count > 0 validation matching existing cores/memory-gib pattern
  • Wired GPU fields into InstanceTypeSpec_builder via GpuSpec_builder (conditional — only when GPU flags are provided)
  • Added GPU example to longHelp and flag help text constants
  • Added 3 unit tests for GPU flag registration (Ginkgo, matching existing pattern)

Testing

  • Unit tests: 3 new flag registration tests for --gpu-pci-device-selector, --gpu-resource-name, --gpu-count (8/8 pass)
  • Manual: Verified on dev cluster — created GPU instance type via CLI, confirmed GPU fields persisted via get instancetypes -o json
  • Coverage: Cmd() at 100%; run() at 0% (pre-existing — requires live gRPC server)

Acceptance Criteria

  • AC-1: osac create instancetype accepts --gpu-pci-device-selector, --gpu-resource-name, and --gpu-count flags
  • AC-2: When all three GPU flags are provided, the created InstanceType includes a populated gpu spec
  • AC-3: When no GPU flags are provided, behavior is unchanged (backward compatible)
  • AC-4: Partial GPU flags produce a clear validation error
  • AC-5: osac create instancetype --help documents the new GPU flags

Related PRs

  • E2E tests: osac-project/osac-test-infra — OSAC-3837 (PR to follow)

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@coderabbitai

coderabbitai Bot commented Aug 10, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 08087343-1dd8-469d-8a0b-38eebd5fc121

📥 Commits

Reviewing files that changed from the base of the PR and between f15e199 and e146fa3.

📒 Files selected for processing (1)
  • fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd.go
🚧 Files skipped from review as they are similar to previous changes (1)
  • fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd.go

Walkthrough

The instance type creation command now accepts GPU PCI selector, resource name, and count flags. It requires the flags together, validates a positive count, and adds GPU configuration to the instance type specification.

Changes

GPU instance type creation

Layer / File(s) Summary
GPU flag contract and command help
fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd.go, fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd_test.go
The command registers the three GPU flags, requires them together, documents GPU usage, and tests the flag names and help text.
GPU specification assembly and validation
fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd.go
The command adds GpuSpec when GPU options are provided and rejects non-positive GPU counts.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: rccrdpccl, sk-ilya

🚥 Pre-merge checks | ✅ 11
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely identifies the addition of GPU flags to the CLI create instancetype command.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
No-Hardcoded-Secrets ✅ Passed The two changed Go files contain only GPU flag names, validation text, and PCI/resource examples; scans found no keys, tokens, passwords, private keys, credential URLs, or long encoded blobs.
No-Weak-Crypto ✅ Passed The commit changes only CLI flag/spec wiring and registration tests; added code contains no weak crypto algorithms, crypto APIs, custom crypto, or secret comparisons.
No-Injection-Vectors ✅ Passed The changed Go files only parse GPU flags and place values in protobuf builders; scans found no SQL concatenation, shell execution, eval/exec, unsafe YAML, pickle, or HTML sinks.
Container-Privileges ✅ Passed HEAD changes only two Go CLI files; the commit diff contains no privilege markers and no YAML, YML, or JSON manifests.
No-Sensitive-Data-In-Logs ✅ Passed The new GPU selector, resource name, and count are validated and sent to the API but never logged; success output contains only the instance type ID.
Ai-Attribution ✅ Passed Target commit e146fa3 includes Assisted-by: Claude Code <noreply@anthropic.com> and no AI Co-Authored-By trailer.
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd_test.go (1)

64-89: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover the new behavior, not only flag registration.

These tests verify that each flag exists and that one help string contains a keyword. They do not prove that partial GPU flag groups are rejected, zero or negative counts fail, empty values are handled, or valid flags populate GpuSpec.

Add focused command tests for these cases. The supplied fulfillment-service/internal/servers/private_instance_types_server_test.go test verifies downstream GpuSpec construction, but it does not exercise this CLI builder and validation path.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd_test.go`
around lines 64 - 89, Extend the create command tests beyond registration to
exercise the GPU flag validation and construction path in Cmd. Add focused cases
covering partial GPU flag groups, zero and negative gpu-count values, empty GPU
flag values, and a valid combination that verifies GpuSpec is populated
correctly; use the command’s existing execution/build symbols and preserve the
downstream server test’s scope.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd.go`:
- Around line 137-140: Move the gpuCount validation for non-empty
gpuPCIDeviceSelector into the command’s parameter-validation block before
cfg.Connect is invoked. Preserve the existing error for gpuCount <= 0 and remove
the later duplicate check so invalid input is rejected before any gRPC
connection or authentication setup.
- Around line 216-218: Update the gpuCountFlagHelp text for the gpu-count flag
to explicitly state that the number of GPU devices must be greater than zero,
matching the validation that rejects gpu-count <= 0.
- Around line 137-146: Update the GPU validation in the create instancetype
command to use flag presence rather than only gpuPCIDeviceSelector’s value when
deciding whether GPU configuration was supplied. Before building
specBuilder.Gpu, reject an empty gpuPCIDeviceSelector, empty gpuResourceName, or
non-positive gpuCount; preserve the no-GPU path when none of the GPU flags are
present.

---

Nitpick comments:
In
`@fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd_test.go`:
- Around line 64-89: Extend the create command tests beyond registration to
exercise the GPU flag validation and construction path in Cmd. Add focused cases
covering partial GPU flag groups, zero and negative gpu-count values, empty GPU
flag values, and a valid combination that verifies GpuSpec is populated
correctly; use the command’s existing execution/build symbols and preserve the
downstream server test’s scope.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: osac-project/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6cac9b29-b9ce-4af7-9cae-f45dadd983e1

📥 Commits

Reviewing files that changed from the base of the PR and between 12ac434 and f15e199.

📒 Files selected for processing (2)
  • fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd.go
  • fulfillment-service/internal/cmd/cli/create/instancetype/create_instancetype_cmd_test.go

Add --gpu-pci-device-selector, --gpu-resource-name, and --gpu-count
flags to `osac create instancetype`. Uses cobra MarkFlagsRequiredTogether
for all-or-nothing validation. When all three flags are provided, the
created InstanceType includes a populated GpuSpec.

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: Tzif <tmorgens@redhat.com>

@ygalblum ygalblum left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/approve
/lgtm

@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Tzif-Morgen, ygalblum

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@omer-vishlitzky
omer-vishlitzky merged commit 94b6626 into osac-project:main Aug 11, 2026
65 of 67 checks passed

This branch was previously deployed

1 inactive deployment
e2e-test — e146fa35 Deployed Aug 10, 2026 by Tzif-Morgen via e2e-bmaas-full-install / e2e #1041
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants