Skip to content

Commit e344b31

Browse files
committed
rebase fixes
Signed-off-by: Tommy Hughes <tohughes@redhat.com>
1 parent 274eb6a commit e344b31

File tree

6 files changed

+81
-79
lines changed

6 files changed

+81
-79
lines changed

infra/feast-operator/internal/controller/featurestore_controller.go

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -108,40 +108,33 @@ func (r *FeatureStoreReconciler) deployFeast(ctx context.Context, cr *feastdevv1
108108
Reason: feastdevv1alpha1.ReadyReason,
109109
Message: feastdevv1alpha1.ReadyMessage,
110110
}
111-
112-
authz := authz.FeastAuthorization{
111+
feast := services.FeastServices{
113112
Handler: feasthandler.FeastHandler{
114113
Client: r.Client,
115114
Context: ctx,
116115
FeatureStore: cr,
117116
Scheme: r.Scheme,
118117
},
119118
}
120-
if err = authz.Deploy(); err != nil {
119+
authz := authz.FeastAuthorization{
120+
Handler: feast.Handler,
121+
}
122+
123+
// initial status defaults must be applied before feast deployment
124+
if err = feast.ApplyDefaults(); err != nil {
125+
result = ctrl.Result{Requeue: true, RequeueAfter: RequeueDelayError}
126+
} else if err = authz.Deploy(); err != nil {
127+
result = ctrl.Result{Requeue: true, RequeueAfter: RequeueDelayError}
128+
} else if err = feast.Deploy(); err != nil {
129+
result = ctrl.Result{Requeue: true, RequeueAfter: RequeueDelayError}
130+
}
131+
if err != nil {
121132
condition = metav1.Condition{
122133
Type: feastdevv1alpha1.ReadyType,
123134
Status: metav1.ConditionFalse,
124135
Reason: feastdevv1alpha1.FailedReason,
125136
Message: "Error: " + err.Error(),
126137
}
127-
result = ctrl.Result{Requeue: true, RequeueAfter: RequeueDelayError}
128-
} else {
129-
feast := services.FeastServices{
130-
Handler: feasthandler.FeastHandler{
131-
Client: r.Client,
132-
Context: ctx,
133-
FeatureStore: cr,
134-
Scheme: r.Scheme,
135-
}}
136-
if err = feast.Deploy(); err != nil {
137-
condition = metav1.Condition{
138-
Type: feastdevv1alpha1.ReadyType,
139-
Status: metav1.ConditionFalse,
140-
Reason: feastdevv1alpha1.FailedReason,
141-
Message: "Error: " + err.Error(),
142-
}
143-
result = ctrl.Result{Requeue: true, RequeueAfter: RequeueDelayError}
144-
}
145138
}
146139

147140
logger.Info(condition.Message)

infra/feast-operator/internal/controller/featurestore_controller_tls_test.go

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040

4141
"github.com/feast-dev/feast/infra/feast-operator/api/feastversion"
4242
feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
43+
"github.com/feast-dev/feast/infra/feast-operator/internal/controller/handler"
4344
"github.com/feast-dev/feast/infra/feast-operator/internal/controller/services"
4445
)
4546

@@ -114,10 +115,12 @@ var _ = Describe("FeatureStore Controller - Feast service TLS", func() {
114115
err = k8sClient.Get(ctx, typeNamespacedName, resource)
115116
Expect(err).NotTo(HaveOccurred())
116117
feast := services.FeastServices{
117-
Client: controllerReconciler.Client,
118-
Context: ctx,
119-
Scheme: controllerReconciler.Scheme,
120-
FeatureStore: resource,
118+
Handler: handler.FeastHandler{
119+
Client: controllerReconciler.Client,
120+
Context: ctx,
121+
Scheme: controllerReconciler.Scheme,
122+
FeatureStore: resource,
123+
},
121124
}
122125

123126
Expect(resource.Status).NotTo(BeNil())
@@ -209,10 +212,12 @@ var _ = Describe("FeatureStore Controller - Feast service TLS", func() {
209212
err = k8sClient.Get(ctx, typeNamespacedName, resource)
210213
Expect(err).NotTo(HaveOccurred())
211214
feast := services.FeastServices{
212-
Client: controllerReconciler.Client,
213-
Context: ctx,
214-
Scheme: controllerReconciler.Scheme,
215-
FeatureStore: resource,
215+
Handler: handler.FeastHandler{
216+
Client: controllerReconciler.Client,
217+
Context: ctx,
218+
Scheme: controllerReconciler.Scheme,
219+
FeatureStore: resource,
220+
},
216221
}
217222

218223
req, err := labels.NewRequirement(services.NameLabelKey, selection.Equals, []string{resource.Name})
@@ -264,6 +269,7 @@ var _ = Describe("FeatureStore Controller - Feast service TLS", func() {
264269
RegistryType: services.RegistryFileConfigType,
265270
Path: services.DefaultRegistryEphemeralPath,
266271
},
272+
AuthzConfig: noAuthzConfig(),
267273
}
268274
Expect(repoConfig).To(Equal(testConfig))
269275

@@ -301,7 +307,8 @@ var _ = Describe("FeatureStore Controller - Feast service TLS", func() {
301307
OfflineStore: services.OfflineStoreConfig{
302308
Type: services.OfflineFilePersistenceDaskConfigType,
303309
},
304-
Registry: regRemote,
310+
Registry: regRemote,
311+
AuthzConfig: noAuthzConfig(),
305312
}
306313
Expect(repoConfigOffline).To(Equal(offlineConfig))
307314

@@ -343,7 +350,8 @@ var _ = Describe("FeatureStore Controller - Feast service TLS", func() {
343350
Path: services.DefaultOnlineStoreEphemeralPath,
344351
Type: services.OnlineSqliteConfigType,
345352
},
346-
Registry: regRemote,
353+
Registry: regRemote,
354+
AuthzConfig: noAuthzConfig(),
347355
}
348356
Expect(repoConfigOnline).To(Equal(onlineConfig))
349357
Expect(deploy.Spec.Template.Spec.Containers[0].Env).To(HaveLen(1))
@@ -370,7 +378,8 @@ var _ = Describe("FeatureStore Controller - Feast service TLS", func() {
370378
Type: services.OnlineRemoteConfigType,
371379
Cert: services.GetTlsPath(services.OnlineFeastType) + "tls.crt",
372380
},
373-
Registry: regRemote,
381+
Registry: regRemote,
382+
AuthzConfig: noAuthzConfig(),
374383
}
375384
Expect(repoConfigClient).To(Equal(clientConfig))
376385

@@ -412,7 +421,7 @@ var _ = Describe("FeatureStore Controller - Feast service TLS", func() {
412421
resource = &feastdevv1alpha1.FeatureStore{}
413422
err = k8sClient.Get(ctx, typeNamespacedName, resource)
414423
Expect(err).NotTo(HaveOccurred())
415-
feast.FeatureStore = resource
424+
feast.Handler.FeatureStore = resource
416425

417426
// check registry
418427
deploy = &appsv1.Deployment{}

infra/feast-operator/internal/controller/services/client.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ func (feast *FeastServices) setClientConfigMap(cm *corev1.ConfigMap) error {
5757
}
5858

5959
func (feast *FeastServices) createCaConfigMap() error {
60-
logger := log.FromContext(feast.Context)
60+
logger := log.FromContext(feast.Handler.Context)
6161
cm := feast.initCaConfigMap()
62-
if op, err := controllerutil.CreateOrUpdate(feast.Context, feast.Client, cm, controllerutil.MutateFn(func() error {
62+
if op, err := controllerutil.CreateOrUpdate(feast.Handler.Context, feast.Handler.Client, cm, controllerutil.MutateFn(func() error {
6363
return feast.setCaConfigMap(cm)
6464
})); err != nil {
6565
return err
@@ -71,12 +71,12 @@ func (feast *FeastServices) createCaConfigMap() error {
7171

7272
func (feast *FeastServices) setCaConfigMap(cm *corev1.ConfigMap) error {
7373
cm.Labels = map[string]string{
74-
NameLabelKey: feast.FeatureStore.Name,
74+
NameLabelKey: feast.Handler.FeatureStore.Name,
7575
}
7676
cm.Annotations = map[string]string{
7777
"service.beta.openshift.io/inject-cabundle": "true",
7878
}
79-
return controllerutil.SetControllerReference(feast.FeatureStore, cm, feast.Scheme)
79+
return controllerutil.SetControllerReference(feast.Handler.FeatureStore, cm, feast.Handler.Scheme)
8080
}
8181

8282
func (feast *FeastServices) initCaConfigMap() *corev1.ConfigMap {

infra/feast-operator/internal/controller/services/services.go

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,20 @@ import (
3535
"sigs.k8s.io/controller-runtime/pkg/log"
3636
)
3737

38-
// Deploy the feast services
39-
func (feast *FeastServices) Deploy() error {
40-
// initial status defaults must be applied before feast deployment
41-
if err := feast.ApplyDefaults(); err != nil {
38+
// Apply defaults and set service hostnames in FeatureStore status
39+
func (feast *FeastServices) ApplyDefaults() error {
40+
ApplyDefaultsToStatus(feast.Handler.FeatureStore)
41+
if err := feast.setTlsDefaults(); err != nil {
42+
return err
43+
}
44+
if err := feast.setServiceHostnames(); err != nil {
4245
return err
4346
}
47+
return nil
48+
}
49+
50+
// Deploy the feast services
51+
func (feast *FeastServices) Deploy() error {
4452
openshiftTls, err := feast.checkOpenshiftTls()
4553
if err != nil {
4654
return err
@@ -212,17 +220,6 @@ func (feast *FeastServices) removeFeastServiceByType(feastType FeastServiceType)
212220
return nil
213221
}
214222

215-
func (feast *FeastServices) ApplyDefaults() error {
216-
ApplyDefaultsToStatus(feast.Handler.FeatureStore)
217-
if err := feast.setTlsDefaults(); err != nil {
218-
return err
219-
}
220-
if err := feast.setServiceHostnames(); err != nil {
221-
return err
222-
}
223-
return nil
224-
}
225-
226223
func (feast *FeastServices) createService(feastType FeastServiceType) error {
227224
logger := log.FromContext(feast.Handler.Context)
228225
svc := feast.initFeastSvc(feastType)

infra/feast-operator/internal/controller/services/tls.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func (feast *FeastServices) setTlsDefaults() error {
2727
if err := feast.setOpenshiftTls(); err != nil {
2828
return err
2929
}
30-
appliedServices := feast.FeatureStore.Status.Applied.Services
30+
appliedServices := feast.Handler.FeatureStore.Status.Applied.Services
3131
if feast.isOfflinStore() && appliedServices.OfflineStore.TLS != nil {
3232
tlsDefaults(&appliedServices.OfflineStore.TLS.TlsConfigs)
3333
}
@@ -41,7 +41,7 @@ func (feast *FeastServices) setTlsDefaults() error {
4141
}
4242

4343
func (feast *FeastServices) setOpenshiftTls() error {
44-
appliedServices := feast.FeatureStore.Status.Applied.Services
44+
appliedServices := feast.Handler.FeatureStore.Status.Applied.Services
4545
tlsConfigs := &feastdevv1alpha1.TlsConfigs{
4646
SecretRef: &corev1.LocalObjectReference{},
4747
}
@@ -94,7 +94,7 @@ func (feast *FeastServices) isOpenShiftTls(feastType FeastServiceType) (isOpenSh
9494
}
9595

9696
func (feast *FeastServices) getTlsConfigs(feastType FeastServiceType) (tls *feastdevv1alpha1.TlsConfigs) {
97-
appliedServices := feast.FeatureStore.Status.Applied.Services
97+
appliedServices := feast.Handler.FeatureStore.Status.Applied.Services
9898
switch feastType {
9999
case OfflineFeastType:
100100
if feast.isOfflinStore() && appliedServices.OfflineStore.TLS != nil {
@@ -115,23 +115,23 @@ func (feast *FeastServices) getTlsConfigs(feastType FeastServiceType) (tls *feas
115115
// True if running in an openshift cluster and Tls not configured in the service Spec
116116
func (feast *FeastServices) offlineOpenshiftTls() bool {
117117
return isOpenShift &&
118-
feast.isOfflinStore() && feast.FeatureStore.Spec.Services.OfflineStore.TLS == nil
118+
feast.isOfflinStore() && feast.Handler.FeatureStore.Spec.Services.OfflineStore.TLS == nil
119119
}
120120

121121
// True if running in an openshift cluster and Tls not configured in the service Spec
122122
func (feast *FeastServices) onlineOpenshiftTls() bool {
123123
return isOpenShift &&
124-
feast.isOnlinStore() && feast.FeatureStore.Spec.Services.OnlineStore.TLS == nil
124+
feast.isOnlinStore() && feast.Handler.FeatureStore.Spec.Services.OnlineStore.TLS == nil
125125
}
126126

127127
// True if running in an openshift cluster and Tls not configured in the service Spec
128128
func (feast *FeastServices) localRegistryOpenshiftTls() bool {
129129
return isOpenShift &&
130130
feast.isLocalRegistry() &&
131-
(feast.FeatureStore.Spec.Services == nil ||
132-
feast.FeatureStore.Spec.Services.Registry == nil ||
133-
feast.FeatureStore.Spec.Services.Registry.Local == nil ||
134-
feast.FeatureStore.Spec.Services.Registry.Local.TLS == nil)
131+
(feast.Handler.FeatureStore.Spec.Services == nil ||
132+
feast.Handler.FeatureStore.Spec.Services.Registry == nil ||
133+
feast.Handler.FeatureStore.Spec.Services.Registry.Local == nil ||
134+
feast.Handler.FeatureStore.Spec.Services.Registry.Local.TLS == nil)
135135
}
136136

137137
// True if running in an openshift cluster, and using a remote registry in the same cluster, with no remote Tls set in the service Spec
@@ -142,24 +142,24 @@ func (feast *FeastServices) remoteRegistryOpenshiftTls() (bool, error) {
142142
return false, err
143143
}
144144
return (remoteFeast != nil && remoteFeast.localRegistryOpenshiftTls() &&
145-
feast.FeatureStore.Spec.Services.Registry.Remote.TLS == nil),
145+
feast.Handler.FeatureStore.Spec.Services.Registry.Remote.TLS == nil),
146146
nil
147147
}
148148
return false, nil
149149
}
150150

151151
func (feast *FeastServices) offlineTls() bool {
152152
return feast.isOfflinStore() &&
153-
feast.FeatureStore.Status.Applied.Services.OfflineStore.TLS != nil &&
154-
(&feast.FeatureStore.Status.Applied.Services.OfflineStore.TLS.TlsConfigs).IsTLS()
153+
feast.Handler.FeatureStore.Status.Applied.Services.OfflineStore.TLS != nil &&
154+
(&feast.Handler.FeatureStore.Status.Applied.Services.OfflineStore.TLS.TlsConfigs).IsTLS()
155155
}
156156

157157
func (feast *FeastServices) localRegistryTls() bool {
158-
return localRegistryTls(feast.FeatureStore)
158+
return localRegistryTls(feast.Handler.FeatureStore)
159159
}
160160

161161
func (feast *FeastServices) remoteRegistryTls() bool {
162-
return remoteRegistryTls(feast.FeatureStore)
162+
return remoteRegistryTls(feast.Handler.FeatureStore)
163163
}
164164

165165
func (feast *FeastServices) mountRegistryClientTls(podSpec *corev1.PodSpec) {
@@ -168,7 +168,7 @@ func (feast *FeastServices) mountRegistryClientTls(podSpec *corev1.PodSpec) {
168168
feast.mountTlsConfig(RegistryFeastType, podSpec)
169169
} else if feast.remoteRegistryTls() {
170170
mountTlsRemoteRegistryConfig(RegistryFeastType, podSpec,
171-
feast.FeatureStore.Status.Applied.Services.Registry.Remote.TLS)
171+
feast.Handler.FeatureStore.Status.Applied.Services.Registry.Remote.TLS)
172172
}
173173
}
174174
}
@@ -233,7 +233,7 @@ func tlsDefaults(tls *feastdevv1alpha1.TlsConfigs) {
233233
}
234234

235235
func localRegistryTls(featureStore *feastdevv1alpha1.FeatureStore) bool {
236-
return isLocalRegistry(featureStore) && featureStore.Status.Applied.Services.Registry.Local.TLS.IsTLS()
236+
return IsLocalRegistry(featureStore) && featureStore.Status.Applied.Services.Registry.Local.TLS.IsTLS()
237237
}
238238

239239
func remoteRegistryTls(featureStore *feastdevv1alpha1.FeatureStore) bool {

infra/feast-operator/internal/controller/services/tls_test.go

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
. "github.com/onsi/gomega"
2222

2323
feastdevv1alpha1 "github.com/feast-dev/feast/infra/feast-operator/api/v1alpha1"
24+
"github.com/feast-dev/feast/infra/feast-operator/internal/controller/handler"
2425
corev1 "k8s.io/api/core/v1"
2526
"k8s.io/apimachinery/pkg/runtime"
2627
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
@@ -44,8 +45,10 @@ var _ = Describe("TLS Config", func() {
4445

4546
// registry service w/o tls
4647
feast := FeastServices{
47-
FeatureStore: minimalFeatureStore(),
48-
Scheme: scheme,
48+
Handler: handler.FeastHandler{
49+
FeatureStore: minimalFeatureStore(),
50+
Scheme: scheme,
51+
},
4952
}
5053
err := feast.ApplyDefaults()
5154
Expect(err).To(BeNil())
@@ -67,7 +70,7 @@ var _ = Describe("TLS Config", func() {
6770

6871
// registry service w/ openshift tls
6972
testSetIsOpenShift()
70-
feast.FeatureStore = minimalFeatureStore()
73+
feast.Handler.FeatureStore = minimalFeatureStore()
7174
err = feast.ApplyDefaults()
7275
Expect(err).To(BeNil())
7376

@@ -95,11 +98,11 @@ var _ = Describe("TLS Config", func() {
9598
Expect(openshiftTls).To(BeTrue())
9699

97100
// all services w/ openshift tls
98-
feast.FeatureStore = minimalFeatureStoreWithAllServices()
101+
feast.Handler.FeatureStore = minimalFeatureStoreWithAllServices()
99102
err = feast.ApplyDefaults()
100103
Expect(err).To(BeNil())
101104

102-
repoConfig := getClientRepoConfig(feast.FeatureStore)
105+
repoConfig := getClientRepoConfig(feast.Handler.FeatureStore)
103106
Expect(repoConfig.OfflineStore.Port).To(Equal(HttpsPort))
104107
Expect(repoConfig.OfflineStore.Scheme).To(Equal(HttpsScheme))
105108
Expect(repoConfig.OfflineStore.Cert).To(ContainSubstring(string(OfflineFeastType)))
@@ -147,8 +150,8 @@ var _ = Describe("TLS Config", func() {
147150
Expect(onlineDeploy.Spec.Template.Spec.Volumes).To(HaveLen(3))
148151

149152
// registry service w/ tls and in an openshift cluster
150-
feast.FeatureStore = minimalFeatureStore()
151-
feast.FeatureStore.Spec.Services = &feastdevv1alpha1.FeatureStoreServices{
153+
feast.Handler.FeatureStore = minimalFeatureStore()
154+
feast.Handler.FeatureStore.Spec.Services = &feastdevv1alpha1.FeatureStoreServices{
152155
OnlineStore: &feastdevv1alpha1.OnlineStore{
153156
TLS: &feastdevv1alpha1.TlsConfigs{},
154157
},
@@ -190,12 +193,12 @@ var _ = Describe("TLS Config", func() {
190193
Expect(openshiftTls).To(BeFalse())
191194

192195
// all services w/ tls and in an openshift cluster
193-
feast.FeatureStore = minimalFeatureStoreWithAllServices()
196+
feast.Handler.FeatureStore = minimalFeatureStoreWithAllServices()
194197
disable := true
195-
feast.FeatureStore.Spec.Services.OnlineStore.TLS = &feastdevv1alpha1.TlsConfigs{
198+
feast.Handler.FeatureStore.Spec.Services.OnlineStore.TLS = &feastdevv1alpha1.TlsConfigs{
196199
Disable: &disable,
197200
}
198-
feast.FeatureStore.Spec.Services.Registry = &feastdevv1alpha1.Registry{
201+
feast.Handler.FeatureStore.Spec.Services.Registry = &feastdevv1alpha1.Registry{
199202
Local: &feastdevv1alpha1.LocalRegistryConfig{
200203
TLS: &feastdevv1alpha1.TlsConfigs{
201204
Disable: &disable,
@@ -205,7 +208,7 @@ var _ = Describe("TLS Config", func() {
205208
err = feast.ApplyDefaults()
206209
Expect(err).To(BeNil())
207210

208-
repoConfig = getClientRepoConfig(feast.FeatureStore)
211+
repoConfig = getClientRepoConfig(feast.Handler.FeatureStore)
209212
Expect(repoConfig.OfflineStore.Port).To(Equal(HttpsPort))
210213
Expect(repoConfig.OfflineStore.Scheme).To(Equal(HttpsScheme))
211214
Expect(repoConfig.OfflineStore.Cert).To(ContainSubstring(string(OfflineFeastType)))

0 commit comments

Comments
 (0)