Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions api/v1beta1/gcpmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta1

import (
"cloud.google.com/go/compute/apiv1/computepb"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
Expand Down Expand Up @@ -386,6 +387,10 @@ type GCPMachineSpec struct {
// attached to the instance.
// +optional
GuestAccelerators []Accelerator `json:"guestAccelerators,omitempty"`

// ReservationAffinity indicates the reservation that this instance has affinity for.
// +optional
ReservationAffinity *computepb.ReservationAffinity `json:"reservationAffinity,omitempty"`
}

// Accelerator is a specification of the type and number of accelerator
Expand Down
12 changes: 12 additions & 0 deletions cloud/scope/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,18 @@
instance.Scheduling.OnHostMaintenance = "TERMINATE"
}

if m.GCPMachine.Spec.ReservationAffinity != nil {
instance.ReservationAffinity = &compute.ReservationAffinity{
ConsumeReservationType: string(m.GCPMachine.Spec.ReservationAffinity.GetConsumeReservationType()),

Check failure on line 509 in cloud/scope/machine.go

View workflow job for this annotation

GitHub Actions / lint

unnecessary conversion (unconvert)
Comment thread
salasberryfin marked this conversation as resolved.
}
if m.GCPMachine.Spec.ReservationAffinity.Key != nil {
instance.ReservationAffinity.Key = m.GCPMachine.Spec.ReservationAffinity.GetKey()
}
if len(m.GCPMachine.Spec.ReservationAffinity.Values) > 0 {

Check failure on line 514 in cloud/scope/machine.go

View workflow job for this annotation

GitHub Actions / lint

avoid direct access to proto field m.GCPMachine.Spec.ReservationAffinity.Values, use m.GCPMachine.Spec.ReservationAffinity.GetValues() instead (protogetter)
instance.ReservationAffinity.Values = m.GCPMachine.Spec.ReservationAffinity.GetValues()
}
Comment thread
salasberryfin marked this conversation as resolved.
}

return instance
}

Expand Down
Loading