Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

OSAC-1359: add create and describe instancetype CLI commands - #723

Merged
openshift-merge-bot[bot] merged 3 commits into
osac-project:mainfrom
ygalblum:feat/instancetype-cli
Jun 26, 2026
Merged

openshift-merge-bot[bot] merged 3 commits into
osac-project:mainfrom
ygalblum:feat/instancetype-cli

Conversation

@ygalblum

@ygalblum ygalblum commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add create instancetype CLI command with --name, --cores, --memory-gib, --description flags using the private API for admin-only creation
  • Add describe instancetype CLI command using the public API with lookup.Find, rendering base fields (name, cores, memory, state, description) and conditional deprecation data (replacement, deprecated at, obsolete at)
  • State display strips INSTANCE_TYPE_STATE_ prefix; timestamps formatted as RFC3339
  • Both commands registered in their parent command routers with Ginkgo test suites (5 + 6 specs)

Test plan

  • go build ./... passes
  • ginkgo run internal/cmd/cli/create/instancetype — 5 specs pass (flag registration)
  • ginkgo run internal/cmd/cli/describe/instancetype — 6 specs pass (rendering: base fields, state stripping, conditional deprecation, RFC3339 timestamps, description presence/absence)
  • ginkgo run -r internal — full unit test suite passes (no regressions)

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added create instancetype CLI command to create instance types with --name, --cores, --memory-gib, and --description.
    • Added describe instancetype CLI command to display instance type details by ID or name, including cores, memory, state, description, and conditional deprecation info with RFC3339 timestamps.
  • Tests
    • Added Ginkgo/Gomega coverage for create instancetype flag/usage behavior and describe instancetype output rendering (state formatting, description, and deprecation sections).

@openshift-ci-robot

openshift-ci-robot commented Jun 17, 2026 •

Copy link
Copy Markdown

@ygalblum: This pull request references OSAC-1359 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:

Summary

  • Add create instancetype CLI command with --name, --cores, --memory-gib, --description flags using the private API for admin-only creation
  • Add describe instancetype CLI command using the public API with lookup.Find, rendering base fields (name, cores, memory, state, description) and conditional deprecation data (replacement, deprecated at, obsolete at)
  • State display strips INSTANCE_TYPE_STATE_ prefix; timestamps formatted as RFC3339
  • Both commands registered in their parent command routers with Ginkgo test suites (5 + 6 specs)

Test plan

  • go build ./... passes
  • ginkgo run internal/cmd/cli/create/instancetype — 5 specs pass (flag registration)
  • ginkgo run internal/cmd/cli/describe/instancetype — 6 specs pass (rendering: base fields, state stripping, conditional deprecation, RFC3339 timestamps, description presence/absence)
  • ginkgo run -r internal — full unit test suite passes (no regressions)

🤖 Generated with Claude Code

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 Jun 17, 2026 •

Copy link
Copy Markdown

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: ASSERTIVE

Plan: Enterprise

Run ID: 5d029e11-69ce-4f53-bf37-7694ed574d20

📥 Commits

Reviewing files that changed from the base of the PR and between f7829cf and 8938717.

📒 Files selected for processing (1)
  • internal/cmd/cli/describe/instancetype/describe_instancetype_cmd.go

Walkthrough

Adds create instancetype and describe instancetype CLI subcommands. The new create command validates flags and calls the instance type gRPC create method. The new describe command resolves an instance type by ID or name and renders its fields and deprecation state.

Changes

Instance Type CLI Commands

Layer / File(s) Summary
create instancetype command and wiring
internal/cmd/cli/create/create_cmd.go, internal/cmd/cli/create/instancetype/create_instancetype_cmd.go, internal/cmd/cli/create/instancetype/create_instancetype_cmd_test.go, internal/cmd/cli/create/instancetype/create_instancetype_suite_test.go
Registers instancetype.Cmd() under create; defines the Cobra command with flags, input validation, gRPC create flow, and success output. Tests verify command metadata and flag usage text.
describe instancetype command and rendering
internal/cmd/cli/describe/describe_cmd.go, internal/cmd/cli/describe/instancetype/describe_instancetype_cmd.go, internal/cmd/cli/describe/instancetype/describe_instancetype_cmd_test.go, internal/cmd/cli/describe/instancetype/describe_instancetype_suite_test.go
Registers instancetype.Cmd() under describe; resolves an instance type with lookup.Find over List, then renders name, spec fields, state text, description, and deprecation details. Tests cover state formatting, conditional fields, and description handling.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • rgolangh
  • jhernand
  • akshaynadkarni
  • tzumainn

Poem

A type appears with cores in tow,
And describe makes its details show.
Flags align, then states unwind,
With deprecation bits all neatly lined.
The CLI blooms, concise and bright ✨

🚥 Pre-merge checks | ✅ 9 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Ai-Attribution ⚠️ Warning PR description says it was generated with Claude Code, but the commit message only has Signed-off-by; no Assisted-by/Generated-by trailer or AI Co-Authored-By tag. Add a Red Hat Assisted-by or Generated-by trailer to the relevant commit(s)/series footer, and avoid using Co-Authored-By for AI tooling.
✅ Passed checks (9 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding create and describe instancetype CLI commands.
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 No hardcoded secrets, embedded credentials, or suspicious api_key/secret/token/password literals were found in the touched CLI files or tests.
No-Weak-Crypto ✅ Passed Touched files only add/register CLI commands; searches found no MD5/SHA1/DES/RC4/3DES/Blowfish/ECB use or secret/token comparisons.
No-Injection-Vectors ✅ Passed No SQL/shell/eval/yaml-load/pickle/dangerous-innerHTML patterns were added; the new CLI code only validates args and calls gRPC clients.
Container-Privileges ✅ Passed Touched files are CLI Go code/tests only; repo scan found no privileged, hostPID/hostNetwork/hostIPC, SYS_ADMIN, or allowPrivilegeEscalation settings.
No-Sensitive-Data-In-Logs ✅ Passed No new sensitive logging found; added commands only print instance-type metadata, and the new code adds no logger calls that expose secrets or PII.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 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.

@ygalblum
ygalblum force-pushed the feat/instancetype-cli branch from 5747f6e to 7cb1432 Compare June 17, 2026 22:18
@ygalblum
ygalblum force-pushed the feat/instancetype-cli branch from 7cb1432 to e7f38a7 Compare June 22, 2026 17:58
ygalblum added 2 commits June 23, 2026 07:54
- Create instancetype command with --name, --cores, --memory-gib, --description flags
- Uses private API client (privatev1.NewInstanceTypesClient) for admin-only creation
- Sets both Id and Metadata.Name to name value (name-as-PK per Phase 1 D-01)
- Validates name non-empty, cores > 0, memory-gib > 0 before API call
- Registers subcommand in parent create_cmd.go via AddCommand
- Adds Ginkgo suite and flag registration tests (5 specs)

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
- Describe instancetype command using public API (publicv1.NewInstanceTypesClient)
- Resolves instance type via lookup.Find helper with empty FindOptions (no soft delete)
- Renders base fields: name, cores, memory (GiB), state, description
- Strips INSTANCE_TYPE_STATE_ prefix from state display (D-02)
- Conditional deprecation section: replacement, deprecated at, obsolete at (D-01)
- Timestamps formatted as RFC3339 (D-03)
- No --include-deleted flag (state-based lifecycle, not soft delete)
- Registers subcommand in parent describe_cmd.go via AddCommand
- Adds Ginkgo suite and 6 rendering tests covering all display scenarios

Assisted-by: Claude Code <noreply@anthropic.com>
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
@ygalblum
ygalblum force-pushed the feat/instancetype-cli branch from e7f38a7 to f7829cf Compare June 23, 2026 11:55
Comment on lines +116 to +134
}

// Conditional deprecation section (D-01):
if dep := spec.GetDeprecation(); dep != nil {
hasContent := dep.GetReplacement() != "" ||
dep.GetDeprecationTimestamp() != nil ||
dep.GetObsolescenceTimestamp() != nil
if hasContent {
if dep.GetReplacement() != "" {
fmt.Fprintf(writer, "Replacement:\t%s\n", dep.GetReplacement())
}
if ts := dep.GetDeprecationTimestamp(); ts != nil {
fmt.Fprintf(writer, "Deprecated At:\t%s\n", ts.AsTime().Format(time.RFC3339))
}
if ts := dep.GetObsolescenceTimestamp(); ts != nil {
fmt.Fprintf(writer, "Obsolete At:\t%s\n", ts.AsTime().Format(time.RFC3339))
}
}
}

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.

nit: The deprecation block accesses spec outside the if spec != nil guard above. Safe at runtime (protobuf getters handle nil receivers), but structurally confusing since everything else that depends on spec is inside the guard. Consider moving it in:

Suggested change
}
// Conditional deprecation section (D-01):
if dep := spec.GetDeprecation(); dep != nil {
hasContent := dep.GetReplacement() != "" ||
dep.GetDeprecationTimestamp() != nil ||
dep.GetObsolescenceTimestamp() != nil
if hasContent {
if dep.GetReplacement() != "" {
fmt.Fprintf(writer, "Replacement:\t%s\n", dep.GetReplacement())
}
if ts := dep.GetDeprecationTimestamp(); ts != nil {
fmt.Fprintf(writer, "Deprecated At:\t%s\n", ts.AsTime().Format(time.RFC3339))
}
if ts := dep.GetObsolescenceTimestamp(); ts != nil {
fmt.Fprintf(writer, "Obsolete At:\t%s\n", ts.AsTime().Format(time.RFC3339))
}
}
}
// Conditional deprecation section (D-01):
if dep := spec.GetDeprecation(); dep != nil {
hasContent := dep.GetReplacement() != "" ||
dep.GetDeprecationTimestamp() != nil ||
dep.GetObsolescenceTimestamp() != nil
if hasContent {
if dep.GetReplacement() != "" {
fmt.Fprintf(writer, "Replacement:\t%s\n", dep.GetReplacement())
}
if ts := dep.GetDeprecationTimestamp(); ts != nil {
fmt.Fprintf(writer, "Deprecated At:\t%s\n", ts.AsTime().Format(time.RFC3339))
}
if ts := dep.GetObsolescenceTimestamp(); ts != nil {
fmt.Fprintf(writer, "Obsolete At:\t%s\n", ts.AsTime().Format(time.RFC3339))
}
}
}
}

writer := tabwriter.NewWriter(w, 0, 0, 2, ' ', 0)

// Base fields (always shown):
fmt.Fprintf(writer, "Name:\t%s\n", it.GetMetadata().GetName())

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.

question: Other describe commands (cluster, computeinstance, securitygroup) show Id as the first field. This one shows Name instead. Since the server sets id = name for instance types, the values are the same, so this isn't wrong. Was this intentional, or should it match the other describe commands?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes it was intentional because we want users to use name instead of forcing them to look for the ID

@akshaynadkarni akshaynadkarni 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.

LGTM, just a couple of minor comments.

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
@openshift-ci openshift-ci Bot removed the lgtm label Jun 24, 2026

@akshaynadkarni akshaynadkarni 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.

LGTM

@openshift-ci openshift-ci Bot added the lgtm label Jun 24, 2026
@openshift-ci

openshift-ci Bot commented Jun 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: akshaynadkarni, 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:
  • OWNERS [akshaynadkarni,ygalblum]

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

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

🏗️ CI Triage: infra | Category: INFRA

Root cause: The OpenShift CI platform failed to import the latest release image stream tag due to a timeout/context deadline exceeded.

Explanation: The build log shows that the job failed during the initial graph execution phase before any E2E steps could run. Specifically, the step [release:latest] failed because it was unable to import the tag ci-op-bbz1x80n/release:latest within the requested timeout, resulting in a context deadline exceeded error. This is a known OpenShift CI platform/registry infrastructure issue and is completely unrelated to the PR's changes.

Evidence:

build-log.txt:

* could not run steps: step [release:latest] failed: unable to import latest release image: unable to import tag ci-op-bbz1x80n/release:latest at import (0): Timeout: request did not complete within requested timeout - context deadline exceeded

Suggestion: retrigger — known flake


Prow job | Build 2069886852952756224 | 🤖 triagent

For deeper investigation, use the /osac-debug-e2e skill with this build ID.

@ygalblum

Copy link
Copy Markdown
Contributor Author

/retest

@omer-vishlitzky

Copy link
Copy Markdown
Contributor

🏗️ CI Triage: infra | Category: BOOT

Root cause: The vmaas-helm cluster snapshot flavor contains an invalid osac-operator image reference (ghcr.io/osac-project/osac-operator:sha-08991cc) that does not exist in the GHCR registry

Causal chain:

  • Boot step pulls cluster snapshot from quay.io/rh-ee-ovishlit/cluster-flavors:vmaas-helm
  • The mutable vmaas-helm tag was updated between 20:37 and 22:46 on 2026-06-25
  • The new snapshot version contains osac-operator deployment configured to use image ghcr.io/osac-project/osac-operator:sha-08991cc
  • During Helm upgrade (refresh phase), the osac-operator deployment is updated to use this image tag
  • Kubernetes attempts to pull ghcr.io/osac-project/osac-operator:sha-08991cc from GHCR
  • GHCR returns 'manifest unknown' error because no manifest with tag sha-08991cc exists
  • osac-operator pod enters ImagePullBackOff state
  • Refresh script's parallel wait task for osac-operator times out because pod never becomes Ready
  • Boot step fails with 'parallel tasks failed: wait fulfillment: osac-operator: ImagePullBackOff'

Evidence:

osac-logs/deployments.txt:

osac-operator ... ghcr.io/osac-project/osac-operator:sha-08991cc (failing run)

pass/osac-logs/deployments.txt:

osac-operator ... ghcr.io/osac-project/osac-operator:sha-8220502 (passing run 2h earlier)

osac-logs/events.txt:

Failed to pull image ghcr.io/osac-project/osac-operator:sha-08991cc: reading manifest sha-08991cc in ghcr.io/osac-project/osac-operator: manifest unknown

step:osac-project-cluster-tool-boot:

ERROR: parallel tasks failed: wait fulfillment: osac-operator: osac-operator-68866ff5c6-k9xxh: ImagePullBackOff

step:osac-project-cluster-tool-boot:

Pulling from quay.io/rh-ee-ovishlit/cluster-flavors:vmaas-helm (both runs use same mutable tag)

Suggestion: Rebuild the vmaas-helm cluster snapshot with a valid osac-operator image reference. The snapshot build process should verify that all referenced image tags actually exist in their registries before publishing the snapshot. Alternatively, use immutable flavor tags (e.g., vmaas-helm-20260625-v3) instead of mutable tags to avoid mid-day snapshot changes breaking CI runs.


Prow job | Build 2070264122477383680 | 🤖 triagent | Cost: $1.0712

For deeper investigation, use the /osac-debug-e2e skill with this build ID.

@ygalblum

Copy link
Copy Markdown
Contributor Author

/retest

@openshift-merge-bot
openshift-merge-bot Bot merged commit 5f7f615 into osac-project:main Jun 26, 2026
14 checks passed
@ygalblum
ygalblum deleted the feat/instancetype-cli branch June 26, 2026 19:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants