Skip to content
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

API compliance fix and build fixes #114

Merged
merged 3 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion api/v1alpha1/inferencemodel_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ type InferenceModelSpec struct {
// Reference to the inference pool, the pool must exist in the same namespace.
//
// +kubebuilder:validation:Required
PoolRef *PoolObjectReference `json:"poolRef,omitempty"`
PoolRef PoolObjectReference `json:"poolRef"`
}

// PoolObjectReference identifies an API object within the namespace of the
Expand Down
6 changes: 1 addition & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ spec:
type: object
targetPortNumber:
description: |-
TargetPort is the port number that the model servers within the pool expect
TargetPortNumber is the port number that the model servers within the pool expect
to recieve traffic from.
This maps to the TargetPort in: https://pkg.go.dev/k8s.io/api/core/v1#ServicePort
format: int32
Expand Down
4 changes: 2 additions & 2 deletions pkg/ext-proc/backend/datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (s *K8sDatastore) FetchModelData(modelName string) (returnModel *v1alpha1.I
}

func RandomWeightedDraw(model *v1alpha1.InferenceModel, seed int64) string {
weights := 0
var weights int32

source := rand.NewSource(rand.Int63())
if seed > 0 {
Expand All @@ -87,7 +87,7 @@ func RandomWeightedDraw(model *v1alpha1.InferenceModel, seed int64) string {
weights += model.Weight
}
klog.V(3).Infof("Weights for Model(%v) total to: %v", model.Name, weights)
randomVal := r.Intn(weights)
randomVal := r.Int31n(weights)
for _, model := range model.Spec.TargetModels {
if randomVal < model.Weight {
return model.Name
Expand Down
2 changes: 1 addition & 1 deletion pkg/ext-proc/backend/endpointslice_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *EndpointSliceReconciler) updateDatastore(slice *discoveryv1.EndpointSli
for _, endpoint := range slice.Endpoints {
klog.V(4).Infof("Zone: %v \n endpoint: %+v \n", c.Zone, endpoint)
if c.validPod(endpoint) {
pod := Pod{Name: *&endpoint.TargetRef.Name, Address: endpoint.Addresses[0] + ":" + fmt.Sprint(inferencePool.Spec.TargetPort)}
pod := Pod{Name: *&endpoint.TargetRef.Name, Address: endpoint.Addresses[0] + ":" + fmt.Sprint(inferencePool.Spec.TargetPortNumber)}
podMap[pod] = true
c.Datastore.pods.Store(pod, true)
}
Expand Down
6 changes: 3 additions & 3 deletions pkg/ext-proc/backend/endpointslice_reconcilier_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
pods: populateMap(basePod1, basePod2),
inferencePool: &v1alpha1.InferencePool{
Spec: v1alpha1.InferencePoolSpec{
TargetPort: int32(8000),
TargetPortNumber: int32(8000),
},
},
},
Expand Down Expand Up @@ -74,7 +74,7 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
pods: populateMap(basePod1, basePod2),
inferencePool: &v1alpha1.InferencePool{
Spec: v1alpha1.InferencePoolSpec{
TargetPort: int32(8000),
TargetPortNumber: int32(8000),
},
},
},
Expand Down Expand Up @@ -120,7 +120,7 @@ func TestUpdateDatastore_EndpointSliceReconciler(t *testing.T) {
pods: populateMap(basePod1, basePod2),
inferencePool: &v1alpha1.InferencePool{
Spec: v1alpha1.InferencePoolSpec{
TargetPort: int32(8000),
TargetPortNumber: int32(8000),
},
},
},
Expand Down
16 changes: 8 additions & 8 deletions pkg/ext-proc/backend/inferencemodel_reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var (
service1 = &v1alpha1.InferenceModel{
Spec: v1alpha1.InferenceModelSpec{
ModelName: "fake model1",
PoolRef: &v1alpha1.PoolObjectReference{Name: "test-pool"},
PoolRef: v1alpha1.PoolObjectReference{Name: "test-pool"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-service",
Expand All @@ -21,7 +21,7 @@ var (
service1Modified = &v1alpha1.InferenceModel{
Spec: v1alpha1.InferenceModelSpec{
ModelName: "fake model1",
PoolRef: &v1alpha1.PoolObjectReference{Name: "test-poolio"},
PoolRef: v1alpha1.PoolObjectReference{Name: "test-poolio"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-service",
Expand All @@ -30,7 +30,7 @@ var (
service2 = &v1alpha1.InferenceModel{
Spec: v1alpha1.InferenceModelSpec{
ModelName: "fake model",
PoolRef: &v1alpha1.PoolObjectReference{Name: "test-pool"},
PoolRef: v1alpha1.PoolObjectReference{Name: "test-pool"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-service-2",
Expand All @@ -50,7 +50,7 @@ func TestUpdateDatastore_InferenceModelReconciler(t *testing.T) {
datastore: &K8sDatastore{
inferencePool: &v1alpha1.InferencePool{
Spec: v1alpha1.InferencePoolSpec{
Selector: map[v1alpha1.LabelString]v1alpha1.LabelString{"app": "vllm"},
Selector: map[v1alpha1.LabelKey]v1alpha1.LabelValue{"app": "vllm"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-pool",
Expand All @@ -67,7 +67,7 @@ func TestUpdateDatastore_InferenceModelReconciler(t *testing.T) {
datastore: &K8sDatastore{
inferencePool: &v1alpha1.InferencePool{
Spec: v1alpha1.InferencePoolSpec{
Selector: map[v1alpha1.LabelString]v1alpha1.LabelString{"app": "vllm"},
Selector: map[v1alpha1.LabelKey]v1alpha1.LabelValue{"app": "vllm"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-pool",
Expand All @@ -84,7 +84,7 @@ func TestUpdateDatastore_InferenceModelReconciler(t *testing.T) {
datastore: &K8sDatastore{
inferencePool: &v1alpha1.InferencePool{
Spec: v1alpha1.InferencePoolSpec{
Selector: map[v1alpha1.LabelString]v1alpha1.LabelString{"app": "vllm"},
Selector: map[v1alpha1.LabelKey]v1alpha1.LabelValue{"app": "vllm"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-pool",
Expand All @@ -96,7 +96,7 @@ func TestUpdateDatastore_InferenceModelReconciler(t *testing.T) {
incomingService: &v1alpha1.InferenceModel{
Spec: v1alpha1.InferenceModelSpec{
ModelName: "fake model",
PoolRef: &v1alpha1.PoolObjectReference{Name: "test-poolio"},
PoolRef: v1alpha1.PoolObjectReference{Name: "test-poolio"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "unrelated-service",
Expand All @@ -109,7 +109,7 @@ func TestUpdateDatastore_InferenceModelReconciler(t *testing.T) {
datastore: &K8sDatastore{
inferencePool: &v1alpha1.InferencePool{
Spec: v1alpha1.InferencePoolSpec{
Selector: map[v1alpha1.LabelString]v1alpha1.LabelString{"app": "vllm"},
Selector: map[v1alpha1.LabelKey]v1alpha1.LabelValue{"app": "vllm"},
},
ObjectMeta: metav1.ObjectMeta{
Name: "test-pool",
Expand Down