Skip to content

Commit c05f24f

Browse files
authored
refactor(api): extract VariantAutoscalingConfigSpec for higher-level controller integration (#830)
Signed-off-by: Vivek Karunai Kiri Ragavan <vkarunai@redhat.com>
1 parent 5da8d1b commit c05f24f

4 files changed

Lines changed: 37 additions & 9 deletions

File tree

api/v1alpha1/variantautoscaling_types.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ import (
55
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
66
)
77

8+
// VariantAutoscalingConfigSpec holds the optional tuning fields for a VariantAutoscaling.
9+
// It is extracted as a standalone embeddable type so that higher-level controllers
10+
// (e.g. KServe) can inline it without duplicating field definitions.
11+
type VariantAutoscalingConfigSpec struct {
12+
// VariantCost specifies the cost per replica for this variant (used in saturation analysis).
13+
// +kubebuilder:validation:Optional
14+
// +kubebuilder:validation:Pattern=`^\d+(\.\d+)?$`
15+
// +kubebuilder:default="10.0"
16+
VariantCost string `json:"variantCost,omitempty"`
17+
}
18+
819
// VariantAutoscalingSpec defines the desired state for autoscaling a model variant.
920
type VariantAutoscalingSpec struct {
1021
// ScaleTargetRef references the scalable resource to manage.
@@ -17,11 +28,8 @@ type VariantAutoscalingSpec struct {
1728
// +kubebuilder:validation:Required
1829
ModelID string `json:"modelID"`
1930

20-
// VariantCost specifies the cost per replica for this variant (used in saturation analysis).
21-
// +kubebuilder:validation:Optional
22-
// +kubebuilder:validation:Pattern=`^\d+(\.\d+)?$`
23-
// +kubebuilder:default="10.0"
24-
VariantCost string `json:"variantCost,omitempty"`
31+
// VariantAutoscalingConfigSpec holds optional tuning fields that integrators can embed.
32+
VariantAutoscalingConfigSpec `json:",inline"`
2533
}
2634

2735
// VariantAutoscalingStatus represents the current status of autoscaling for a variant,

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/e2e/fixtures/va_builder.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,10 @@ func buildVariantAutoscaling(namespace, name, deploymentName, modelID, accelerat
111111
Kind: "Deployment",
112112
Name: deploymentName,
113113
},
114-
ModelID: modelID,
115-
VariantCost: fmt.Sprintf("%.1f", cost),
114+
ModelID: modelID,
115+
VariantAutoscalingConfigSpec: variantautoscalingv1alpha1.VariantAutoscalingConfigSpec{
116+
VariantCost: fmt.Sprintf("%.1f", cost),
117+
},
116118
},
117119
}
118120
}

test/utils/e2eutils.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -881,8 +881,10 @@ func CreateVariantAutoscalingResource(namespace, resourceName, scaleTargetRefNam
881881
Kind: "Deployment",
882882
Name: scaleTargetRefName,
883883
},
884-
ModelID: modelId,
885-
VariantCost: fmt.Sprintf("%.1f", variantCost),
884+
ModelID: modelId,
885+
VariantAutoscalingConfigSpec: v1alpha1.VariantAutoscalingConfigSpec{
886+
VariantCost: fmt.Sprintf("%.1f", variantCost),
887+
},
886888
},
887889
}
888890
}

0 commit comments

Comments
 (0)