Skip to content

Conversation

de1987
Copy link

@de1987 de1987 commented Sep 19, 2025

  • add ProvisioningModel to enable gcp spot instances

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Sep 19, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Sep 19, 2025

@de1987: This pull request references OCPCLOUD-3173 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 story to target the "4.21.0" version, but no target version was set.

In response to this:

  • add ProvisioningModel to enable gcp spot instances

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.

Copy link
Contributor

openshift-ci bot commented Sep 19, 2025

Hello @de1987! Some important instructions when contributing to openshift/api:
API design plays an important part in the user experience of OpenShift and as such API PRs are subject to a high level of scrutiny to ensure they follow our best practices. If you haven't already done so, please review the OpenShift API Conventions and ensure that your proposed changes are compliant. Following these conventions will help expedite the api review process for your PR.

@openshift-ci openshift-ci bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Sep 19, 2025
@openshift-ci openshift-ci bot requested review from JoelSpeed and mandre September 19, 2025 15:22
Copy link
Contributor

openshift-ci bot commented Sep 19, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign deads2k for approval. For more information see the Code Review Process.

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

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

@de1987 de1987 force-pushed the enable-gcp-spot-instances branch from dbb7be9 to 1afaa6e Compare September 19, 2025 15:42
@JoelSpeed
Copy link
Contributor

I'm currently working on getting Claude code to help with API review, this is the current review it has given


❌ Documentation Issues Found

The PR adds a new ProvisioningModel field to enable GCP spot instances, but there are several documentation requirements that need to be addressed:

+177: Missing field documentation
Current (problematic) code:

  ProvisioningModel GCPProvisioningModelType `json:"provisioningModel,omitempty"`

Suggested change:

 - ProvisioningModel GCPProvisioningModelType `json:"provisioningModel,omitempty"`
  + // provisioningModel is an optional field that determines the provisioning model for the GCP machine instance.
  + // Valid values are "Spot".
  + // When set to Spot, the instance runs as a Google Cloud Spot instance which provides significant cost savings but may be preempted by Google Cloud Platform when resources are needed elsewhere.
  + // When omitted, the machine will be provisioned as a standard on-demand instance.
  + // This field cannot be used together with the preemptible field.
  + // +optional
  + // +kubebuilder:validation:Enum=Spot
  + ProvisioningModel GCPProvisioningModelType `json:"provisioningModel,omitempty"`

Explanation: The field lacks documentation explaining its purpose, valid values, optional behavior, and relationship to other fields. All kubebuilder validation markers must be documented in the field comment.

  +Missing: Type definition documentation
  Current (problematic) code:
  const (
      // GCPSpotInstance To enable the GCP instances as spot type.
      GCPSpotInstance GCPProvisioningModelType = "Spot"
  )

Suggested change:

  + // GCPProvisioningModelType is a type representing acceptable values for ProvisioningModel field in GCPMachineProviderSpec
  + type GCPProvisioningModelType string
  + 
  + const (
  +     // GCPSpotInstance enables the GCP instances as spot instances which provide significant cost savings but may be preempted by Google Cloud Platform when resources are needed elsewhere.
  +     GCPSpotInstance GCPProvisioningModelType = "Spot"
  + )

Explanation: Missing type definition and improved constant documentation following the pattern used by other types in the file.

📋 Review Summary

Issues found:

  1. Missing field documentation for ProvisioningModel
  2. Missing validation rule documentation (+kubebuilder:validation:Enum=Spot)
  3. Missing optional field behavior explanation
  4. Missing type definition
  5. Insufficient constant documentation

Required Actions:

  1. Add comprehensive field documentation explaining purpose, valid values, and behavior when omitted
  2. Document the validation enum constraint in the field comment
  3. Explain relationship with existing preemptible field
  4. Add proper type definition with documentation
  5. Improve constant documentation

The API changes fail the documentation requirements. All kubebuilder validation markers and optional field behaviors must be explicitly documented in field comments per OpenShift API standards.


I agree, the documentation can be improved, and we must explain both what valid values are, what they mean, and what happens when the field is omitted, so the suggestions here are good IMO.

It picked out that you are missing the Enum marker, so lets make sure that's added.

You don't need length restrictions when you have an enum marker, so those can be removed.

@de1987
Copy link
Author

de1987 commented Sep 19, 2025

/test verify

@de1987 de1987 force-pushed the enable-gcp-spot-instances branch from f822170 to 3ff05bf Compare September 19, 2025 17:58
Copy link
Contributor

@JoelSpeed JoelSpeed left a comment

Choose a reason for hiding this comment

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

Do you have a PR to machine-api-operator to show the implementation of the validation of this API?

@de1987 de1987 force-pushed the enable-gcp-spot-instances branch from 3ff05bf to 7b31e8e Compare September 22, 2025 16:05
@de1987 de1987 requested a review from JoelSpeed September 22, 2025 16:06
@de1987
Copy link
Author

de1987 commented Sep 22, 2025

Do you have a PR to machine-api-operator to show the implementation of the validation of this API?

I don't have it yet, I was hoping to merge this PR first.
The draft changes are done but not pushed, I was hoping to avoid errors with the API field since those don't exist yet.

@JoelSpeed
Copy link
Contributor

We should vendor the API as a WIP in Machine API operator and implement the validations before we merge the API really, this is what we've done in the past at least for new MAPI APIs

@de1987
Copy link
Author

de1987 commented Sep 22, 2025

We should vendor the API as a WIP in Machine API operator and implement the validations before we merge the API really, this is what we've done in the past at least for new MAPI APIs

we will tackle it and have the PRs open to validate the feature.

Copy link
Contributor

openshift-ci bot commented Sep 22, 2025

@de1987: all tests passed!

Full PR test history. Your PR dashboard.

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 kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants