Skip to content

Commit

Permalink
fix: Operator envVar positioning & tls.SecretRef.Name (feast-dev#4806)
Browse files Browse the repository at this point in the history
* fix envVar positioning

Signed-off-by: Tommy Hughes <[email protected]>

* tls.SecretRef.Name

Signed-off-by: Tommy Hughes <[email protected]>

---------

Signed-off-by: Tommy Hughes <[email protected]>
  • Loading branch information
tchughesiv authored and dharmisha committed Jan 15, 2025
1 parent c254703 commit 298059f
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,14 @@ import (
. "github.com/onsi/gomega"
"gopkg.in/yaml.v3"
corev1 "k8s.io/api/core/v1"
<<<<<<< HEAD
<<<<<<< HEAD
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
=======
>>>>>>> 863a82cb7 (feat: Added feast Go operator db stores support (#4771))
=======
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
>>>>>>> 33db9cabb (fix: Operator envVar positioning & tls.SecretRef.Name (#4806))

feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
)
Expand Down
6 changes: 6 additions & 0 deletions infra/feast-operator/internal/controller/services/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -1270,9 +1270,12 @@ func (feast *FeastServices) deleteOwnedFeastObj(obj client.Object) error {
func applyOptionalContainerConfigs(container *corev1.Container, optionalConfigs feastdevv1alpha1.OptionalConfigs) {
if optionalConfigs.Env != nil {
container.Env = envOverride(container.Env, *optionalConfigs.Env)
<<<<<<< HEAD
}
if optionalConfigs.EnvFrom != nil {
container.EnvFrom = *optionalConfigs.EnvFrom
=======
>>>>>>> 33db9cabb (fix: Operator envVar positioning & tls.SecretRef.Name (#4806))
}
if optionalConfigs.ImagePullPolicy != nil {
container.ImagePullPolicy = *optionalConfigs.ImagePullPolicy
Expand All @@ -1282,6 +1285,7 @@ func applyOptionalContainerConfigs(container *corev1.Container, optionalConfigs
}
}

<<<<<<< HEAD
func (feast *FeastServices) mountPvcConfigs(podSpec *corev1.PodSpec) {
for _, feastType := range feastServerTypes {
if pvcConfig, hasPvcConfig := hasPvcConfig(feast.Handler.FeatureStore, feastType); hasPvcConfig {
Expand Down Expand Up @@ -1380,6 +1384,8 @@ func getProbeHandler(feastType FeastServiceType, tls *feastdevv1alpha1.TlsConfig
}
}

=======
>>>>>>> 33db9cabb (fix: Operator envVar positioning & tls.SecretRef.Name (#4806))
func mountPvcConfig(podSpec *corev1.PodSpec, pvcConfig *feastdevv1alpha1.PvcConfig, deployName string) {
if podSpec != nil && pvcConfig != nil {
container := &podSpec.Containers[0]
Expand Down
25 changes: 21 additions & 4 deletions infra/feast-operator/internal/controller/services/tls.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func (feast *FeastServices) setTlsDefaults() error {

func (feast *FeastServices) setOpenshiftTls() error {
appliedServices := feast.Handler.FeatureStore.Status.Applied.Services
<<<<<<< HEAD
<<<<<<< HEAD
if feast.offlineOpenshiftTls() {
appliedServices.OfflineStore.TLS = &feastdevv1alpha1.TlsConfigs{
Expand All @@ -71,20 +72,36 @@ func (feast *FeastServices) setOpenshiftTls() error {
tlsConfigs := &feastdevv1alpha1.TlsConfigs{
SecretRef: &corev1.LocalObjectReference{},
}
=======
>>>>>>> 33db9cabb (fix: Operator envVar positioning & tls.SecretRef.Name (#4806))
if feast.offlineOpenshiftTls() {
appliedServices.OfflineStore.TLS = &feastdevv1alpha1.OfflineTlsConfigs{
TlsConfigs: *tlsConfigs,
TlsConfigs: feastdevv1alpha1.TlsConfigs{
SecretRef: &corev1.LocalObjectReference{
Name: feast.initFeastSvc(OfflineFeastType).Name + tlsNameSuffix,
},
},
}
appliedServices.OfflineStore.TLS.TlsConfigs.SecretRef.Name = feast.initFeastSvc(OfflineFeastType).Name + tlsNameSuffix
}
if feast.onlineOpenshiftTls() {
appliedServices.OnlineStore.TLS = tlsConfigs
appliedServices.OnlineStore.TLS.SecretRef.Name = feast.initFeastSvc(OnlineFeastType).Name + tlsNameSuffix
appliedServices.OnlineStore.TLS = &feastdevv1alpha1.TlsConfigs{
SecretRef: &corev1.LocalObjectReference{
Name: feast.initFeastSvc(OnlineFeastType).Name + tlsNameSuffix,
},
}
}
if feast.localRegistryOpenshiftTls() {
<<<<<<< HEAD
appliedServices.Registry.Local.TLS = tlsConfigs
appliedServices.Registry.Local.TLS.SecretRef.Name = feast.initFeastSvc(RegistryFeastType).Name + tlsNameSuffix
>>>>>>> 668d47b8e (feat: Add TLS support to the Operator (#4796))
=======
appliedServices.Registry.Local.TLS = &feastdevv1alpha1.TlsConfigs{
SecretRef: &corev1.LocalObjectReference{
Name: feast.initFeastSvc(RegistryFeastType).Name + tlsNameSuffix,
},
}
>>>>>>> 33db9cabb (fix: Operator envVar positioning & tls.SecretRef.Name (#4806))
} else if remote, err := feast.remoteRegistryOpenshiftTls(); remote {
// if the remote registry reference is using openshift's service serving certificates, we can use the injected service CA bundle configMap
if appliedServices.Registry.Remote.TLS == nil {
Expand Down
9 changes: 9 additions & 0 deletions infra/feast-operator/internal/controller/services/tls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ var _ = Describe("TLS Config", func() {
tls = feast.getTlsConfigs(OfflineFeastType)
Expect(tls).NotTo(BeNil())
Expect(tls.IsTLS()).To(BeTrue())
<<<<<<< HEAD
<<<<<<< HEAD
Expect(tls.SecretRef).NotTo(BeNil())
Expect(tls.SecretRef.Name).To(Equal("feast-test-offline-tls"))
Expand All @@ -144,11 +145,19 @@ var _ = Describe("TLS Config", func() {
Expect(tls.IsTLS()).To(BeTrue())

=======
=======
Expect(tls.SecretRef).NotTo(BeNil())
Expect(tls.SecretRef.Name).To(Equal("feast-test-offline-tls"))
>>>>>>> 33db9cabb (fix: Operator envVar positioning & tls.SecretRef.Name (#4806))
tls = feast.getTlsConfigs(OnlineFeastType)
Expect(tls).NotTo(BeNil())
Expect(tls.IsTLS()).To(BeTrue())
Expect(tls.SecretRef).NotTo(BeNil())
Expect(tls.SecretRef.Name).To(Equal("feast-test-online-tls"))
tls = feast.getTlsConfigs(RegistryFeastType)
Expect(tls).NotTo(BeNil())
Expect(tls.SecretRef).NotTo(BeNil())
Expect(tls.SecretRef.Name).To(Equal("feast-test-registry-tls"))
Expect(tls.SecretKeyNames).To(Equal(secretKeyNames))
Expect(tls.IsTLS()).To(BeTrue())

Expand Down
23 changes: 23 additions & 0 deletions infra/feast-operator/internal/controller/services/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -724,3 +724,26 @@ func SetIsOpenShift(cfg *rest.Config) {
func missingOidcSecretProperty(property OidcPropertyType) error {
return fmt.Errorf(OidcMissingSecretError, property)
}

// getEnvVar returns the position of the EnvVar found by name
func getEnvVar(envName string, env []corev1.EnvVar) int {
for pos, v := range env {
if v.Name == envName {
return pos
}
}
return -1
}

// envOverride replaces or appends the provided EnvVar to the collection
func envOverride(dst, src []corev1.EnvVar) []corev1.EnvVar {
for _, cre := range src {
pos := getEnvVar(cre.Name, dst)
if pos != -1 {
dst[pos] = cre
} else {
dst = append(dst, cre)
}
}
return dst
}

0 comments on commit 298059f

Please sign in to comment.