NO-JIRA: Added reservation affinity support for GCP Machine Spec - WIP
Context
Currently, OCP's machine API doesn't support the reservation affinity feature of GCP's instances, thus making reservation use more complicated on OCP in comparison to GCP. This feature is critical for clients with heavy workloads that have already reserved instances for continuous use. (e.g. AI training workloads).
This PR lays the groundwork to support GCP reservation in openshift's machine API.
Pipeline controller notification
This repo is configured to use the pipeline controller. Second-stage tests will be triggered either automatically or after lgtm label is added, depending on the repository configuration. The pipeline controller will automatically detect which contexts are required and will utilize /test Prow commands to trigger the second stage.
For optional jobs, comment /test ? to see a list of all defined jobs. To trigger manually all jobs from second stage use /pipeline required command.
This repository is configured in: LGTM mode
@MenD32: This pull request explicitly references no jira issue.
In response to this:
Context
Currently, OCP's machine API doesn't support the reservation affinity feature of GCP's instances, thus making reservation use more complicated on OCP in comparison to GCP. This feature is critical for clients with heavy workloads that have already reserved instances for continuous use. (e.g. AI training workloads).
This PR lays the groundwork to support GCP reservation in openshift's machine API.
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.
Hello @MenD32! 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.
Walkthrough
Adds a new GCPReservationAffinity type and an optional ReservationAffinity field to GCPMachineProviderSpec, and updates generated deepcopy, Swagger, and OpenAPI code to include and handle the new type.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
GCP reservation affinity types & spec field machine/v1beta1/types_gcpprovider.go |
Adds GCPReservationAffinity struct with fields ConsumeReservationType, Key, and Values (JSON tags and kubebuilder enum/validation), and adds ReservationAffinity *GCPReservationAffinity to GCPMachineProviderSpec. |
DeepCopy implementations machine/v1beta1/zz_generated.deepcopy.go |
Adds DeepCopyInto and DeepCopy for GCPReservationAffinity; updates GCPMachineProviderSpec.DeepCopyInto to deep-copy optional ReservationAffinity. |
Swagger doc updates machine/v1beta1/zz_generated.swagger_doc_generated.go |
Adds swagger doc entry for reservationAffinity in GCPMachineProviderSpec and adds GCPReservationAffinity SwaggerDoc mapping. |
OpenAPI schema updates openapi/generated_openapi/zz_generated.openapi.go |
Adds OpenAPI schema function for GCPReservationAffinity, wires reservationAffinity property into GCPMachineProviderSpec schema, and registers the new type in GetOpenAPIDefinitions. |
Estimated code review effort
🎯 3 (Moderate) | ⏱️ ~20 minutes
- Review focus:
- Ensure DeepCopy handles pointer, slice, and pointer-to-string fields correctly.
- Verify OpenAPI schema property requirements and types (required vs optional for consumeReservationType).
- Confirm Swagger docs match struct field names and descriptions.
- Check JSON tags and kubebuilder validation annotation consistency.
✨ Finishing touches
- [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
[!WARNING] There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.
🔧 golangci-lint (2.5.0)
Error: build linters: unable to load custom analyzer "kubeapilinter": tools/_output/bin/kube-api-linter.so, plugin: not implemented The command is terminated due to an error: build linters: unable to load custom analyzer "kubeapilinter": tools/_output/bin/kube-api-linter.so, plugin: not implemented
Comment @coderabbitai help to get the list of available commands and usage tips.
[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 everettraven for approval. For more information see the Code Review Process.
The full list of commands accepted by this bot can be found here.
Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment
Is this feature supported in the upstream cluster-api-provider-gcp?
Is this feature supported in the upstream cluster-api-provider-gcp?
In order for it to be supported, it must be first integrated into the API (adding that feature to the reconciler is my next PR)
@MenD32 To clarify, I meant is the feature supported in https://github.com/kubernetes-sigs/cluster-api-provider-gcp/, which has no dependency on this API that you have raised a PR for
@MenD32 To clarify, I meant is the feature supported in https://github.com/kubernetes-sigs/cluster-api-provider-gcp/, which has no dependency on this API that you have raised a PR for
Ah, thought you were talking about https://github.com/openshift/machine-api-provider-gcp.
Its not supported there (in CAPG) currently.
Its not supported there (in CAPG) currently.
It must be supported in CAPG before we will allow a merge downstream. Please work with the Cluster Infrastructure team (#forum-ocp-cloud) who will be able to help you with upstream reviews
CC @sub-mod @damdo
@MenD32: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:
| Test name | Commit | Details | Required | Rerun command |
|---|---|---|---|---|
| ci/prow/verify | d0a831c4bdd2dc5c3d1982e9b65457e90b9956c2 | link | true | /test verify |
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.
@MenD32 yes the proper flow is to open a PR against CAPG first and then come back to MAPG/OCP once that has been agreed upon. Please also tag me and @JoelSpeed once you open the upstream CAPG PR, thanks!
@MenD32 yes the proper flow is to open a PR against CAPG first and then come back to MAPG/OCP once that has been agreed upon. Please also tag me and @JoelSpeed once you open the upstream CAPG PR, thanks!
Alright, is it ok if I keep this PR as a draft instead of closing it?
Mark this as WIP and then remove the WIP title once you're ready for it to be worked again
Please reach out for an API review upstream as well