-
Notifications
You must be signed in to change notification settings - Fork 4.2k
cluster-api: node template in scale-from-0-nodes scenario with DRA #7804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -20,18 +20,21 @@ import ( | |||
"context" | ||||
"fmt" | ||||
"path" | ||||
"strconv" | ||||
"strings" | ||||
"time" | ||||
|
||||
"github.com/pkg/errors" | ||||
apiv1 "k8s.io/api/core/v1" | ||||
corev1 "k8s.io/api/core/v1" | ||||
resourceapi "k8s.io/api/resource/v1beta1" | ||||
"k8s.io/apimachinery/pkg/api/resource" | ||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" | ||||
"k8s.io/apimachinery/pkg/runtime/schema" | ||||
"k8s.io/apimachinery/pkg/util/validation" | ||||
klog "k8s.io/klog/v2" | ||||
"k8s.io/utils/ptr" | ||||
) | ||||
|
||||
type unstructuredScalableResource struct { | ||||
|
@@ -297,6 +300,46 @@ func (r unstructuredScalableResource) InstanceCapacity() (map[corev1.ResourceNam | |||
return capacity, nil | ||||
} | ||||
|
||||
func (r unstructuredScalableResource) InstanceResourceSlices(nodeName string) ([]*resourceapi.ResourceSlice, error) { | ||||
driver := r.InstanceDRADriver() | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should be able to return immediately if the
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is more efficient. If modifying so, is the condition in "if" behind it autoscaler/cluster-autoscaler/cloudprovider/clusterapi/clusterapi_unstructured.go Line 311 in 3fbacf0
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ttsuuubasa i don't think the check for |
||||
gpuCount, err := r.InstanceGPUCapacityAnnotation() | ||||
if err != nil { | ||||
return nil, err | ||||
} | ||||
|
||||
var result []*resourceapi.ResourceSlice | ||||
if driver != "" && !gpuCount.IsZero() { | ||||
resourceslice := &resourceapi.ResourceSlice{ | ||||
ObjectMeta: metav1.ObjectMeta{ | ||||
Name: nodeName + "-" + driver, | ||||
}, | ||||
Spec: resourceapi.ResourceSliceSpec{ | ||||
Driver: driver, | ||||
NodeName: nodeName, | ||||
Pool: resourceapi.ResourcePool{ | ||||
Name: nodeName, | ||||
}, | ||||
}, | ||||
} | ||||
for i := 0; i < int(gpuCount.Value()); i++ { | ||||
device := resourceapi.Device{ | ||||
Name: "gpu-" + strconv.Itoa(i), | ||||
Basic: &resourceapi.BasicDevice{ | ||||
Attributes: map[resourceapi.QualifiedName]resourceapi.DeviceAttribute{ | ||||
"type": { | ||||
StringValue: ptr.To(GpuDeviceType), | ||||
}, | ||||
}, | ||||
}, | ||||
} | ||||
resourceslice.Spec.Devices = append(resourceslice.Spec.Devices, device) | ||||
} | ||||
result = append(result, resourceslice) | ||||
return result, nil | ||||
} | ||||
return nil, nil | ||||
} | ||||
|
||||
func (r unstructuredScalableResource) InstanceEphemeralDiskCapacityAnnotation() (resource.Quantity, error) { | ||||
return parseEphemeralDiskCapacity(r.unstructured.GetAnnotations()) | ||||
} | ||||
|
@@ -321,6 +364,10 @@ func (r unstructuredScalableResource) InstanceMaxPodsCapacityAnnotation() (resou | |||
return parseMaxPodsCapacity(r.unstructured.GetAnnotations()) | ||||
} | ||||
|
||||
func (r unstructuredScalableResource) InstanceDRADriver() string { | ||||
return parseDRADriver(r.unstructured.GetAnnotations()) | ||||
} | ||||
|
||||
func (r unstructuredScalableResource) readInfrastructureReferenceResource() (*unstructured.Unstructured, error) { | ||||
infraref, found, err := unstructured.NestedStringMap(r.unstructured.Object, "spec", "template", "spec", "infrastructureRef") | ||||
if !found || err != nil { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's put this behind a comment to make it clear that you can't include both annotations, you have to do either one or the other (that's my understanding, at least). Something like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's nice idea. I agree that.