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
7 changes: 4 additions & 3 deletions cmd/thv-operator/api/v1alpha1/embeddingserver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package v1alpha1

import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
)
Expand Down Expand Up @@ -60,7 +61,7 @@ type EmbeddingServerSpec struct {
// +kubebuilder:validation:Enum=Always;Never;IfNotPresent
// +kubebuilder:default="IfNotPresent"
// +optional
ImagePullPolicy string `json:"imagePullPolicy,omitempty"`
ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"`

// Port is the port to expose the embedding service on
// +kubebuilder:validation:Minimum=1
Expand Down Expand Up @@ -269,11 +270,11 @@ func (e *EmbeddingServer) IsModelCacheEnabled() bool {
}

// GetImagePullPolicy returns the image pull policy for the EmbeddingServer
func (e *EmbeddingServer) GetImagePullPolicy() string {
func (e *EmbeddingServer) GetImagePullPolicy() corev1.PullPolicy {
if e.Spec.ImagePullPolicy != "" {
return e.Spec.ImagePullPolicy
}
return "IfNotPresent"
return corev1.PullIfNotPresent
}

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ func (r *EmbeddingServerReconciler) buildEmbeddingContainer(embedding *mcpv1alph
Image: embedding.Spec.Image,
Args: args,
Env: envVars,
ImagePullPolicy: corev1.PullPolicy(embedding.GetImagePullPolicy()),
ImagePullPolicy: embedding.GetImagePullPolicy(),
Ports: []corev1.ContainerPort{
{
Name: "http",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,28 +147,28 @@ func TestEmbeddingServer_GetImagePullPolicy(t *testing.T) {

tests := []struct {
name string
imagePullPolicy string
expected string
imagePullPolicy corev1.PullPolicy
expected corev1.PullPolicy
}{
{
name: "default pull policy",
imagePullPolicy: "",
expected: "IfNotPresent",
expected: corev1.PullIfNotPresent,
},
{
name: "Never pull policy",
imagePullPolicy: "Never",
expected: "Never",
imagePullPolicy: corev1.PullNever,
expected: corev1.PullNever,
},
{
name: "Always pull policy",
imagePullPolicy: "Always",
expected: "Always",
imagePullPolicy: corev1.PullAlways,
expected: corev1.PullAlways,
},
{
name: "IfNotPresent pull policy",
imagePullPolicy: "IfNotPresent",
expected: "IfNotPresent",
imagePullPolicy: corev1.PullIfNotPresent,
expected: corev1.PullIfNotPresent,
},
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ var _ = Describe("EmbeddingServer Controller Integration Tests", func() {
Spec: mcpv1alpha1.EmbeddingServerSpec{
Model: "sentence-transformers/all-MiniLM-L6-v2",
Image: "ghcr.io/huggingface/text-embeddings-inference:latest",
ImagePullPolicy: "Always",
ImagePullPolicy: corev1.PullAlways,
},
},
},
Expand Down Expand Up @@ -631,7 +631,7 @@ var _ = Describe("EmbeddingServer Controller Integration Tests", func() {
Spec: mcpv1alpha1.EmbeddingServerSpec{
Model: "sentence-transformers/all-MiniLM-L6-v2",
Image: "ghcr.io/huggingface/text-embeddings-inference:latest",
ImagePullPolicy: "Never",
ImagePullPolicy: corev1.PullNever,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,14 +373,14 @@ var _ = Describe("EmbeddingServer Controller Update Tests", func() {
Spec: mcpv1alpha1.EmbeddingServerSpec{
Model: "sentence-transformers/all-MiniLM-L6-v2",
Image: "ghcr.io/huggingface/text-embeddings-inference:latest",
ImagePullPolicy: "IfNotPresent",
ImagePullPolicy: corev1.PullIfNotPresent,
},
},
Updates: []UpdateStep{
{
Name: "Should update StatefulSet when ImagePullPolicy changes",
ApplyUpdate: func(es *mcpv1alpha1.EmbeddingServer) {
es.Spec.ImagePullPolicy = "Always"
es.Spec.ImagePullPolicy = corev1.PullAlways
},
ExpectedStatefulSet: &appsv1.StatefulSet{
Spec: appsv1.StatefulSetSpec{
Expand Down
Loading