Skip to content

Commit

Permalink
Merge pull request #3288 from cliveseldon/3282_tempo_envs
Browse files Browse the repository at this point in the history
Allow MLServer envs to be overriden
  • Loading branch information
axsaucedo authored Jun 14, 2021
2 parents fcc5b21 + 9f0042a commit 93fb5ca
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 9 additions & 2 deletions operator/controllers/mlserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package controllers
import (
"errors"
"fmt"
"github.com/seldonio/seldon-core/operator/utils"
"strconv"

machinelearningv1 "github.com/seldonio/seldon-core/operator/apis/machinelearning.seldon.io/v1"
Expand Down Expand Up @@ -41,8 +42,14 @@ func mergeMLServerContainer(existing *v1.Container, mlServer *v1.Container) *v1.
existing.Env = []v1.EnvVar{}
}

// TODO: Allow overriding some of the env vars
existing.Env = append(existing.Env, mlServer.Env...)
for _, envVar := range existing.Env {
if utils.HasEnvVar(mlServer.Env, envVar.Name) {
mlServer.Env = utils.SetEnvVar(mlServer.Env, envVar)
} else {
mlServer.Env = append(mlServer.Env, envVar)
}
}
existing.Env = mlServer.Env

if existing.ReadinessProbe == nil {
existing.ReadinessProbe = mlServer.ReadinessProbe
Expand Down
3 changes: 3 additions & 0 deletions operator/controllers/mlserver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ var _ = Describe("MLServer helpers", func() {
Describe("mergeMLServerContainer", func() {
var existing *v1.Container
var mlServer *v1.Container
customEnvValue := "{\"custom\":1}"

BeforeEach(func() {
existing = &v1.Container{
Env: []v1.EnvVar{
{Name: "FOO", Value: "BAR"},
{Name: MLServerTempoRuntimeEnv, Value: customEnvValue},
},
}

Expand All @@ -49,6 +51,7 @@ var _ = Describe("MLServer helpers", func() {

Expect(merged).ToNot(BeNil())
Expect(merged.Env).To(ContainElement(v1.EnvVar{Name: "FOO", Value: "BAR"}))
Expect(merged.Env).To(ContainElement(v1.EnvVar{Name: MLServerTempoRuntimeEnv, Value: customEnvValue}))
Expect(merged.Env).To(ContainElements(mlServer.Env))
Expect(merged.Image).To(Equal(mlServer.Image))
})
Expand Down

0 comments on commit 93fb5ca

Please sign in to comment.