Skip to content

Commit 6c7b8be

Browse files
Bugfix: Fix pyfunc ensembler undeployment bug (#331)
* Remove redundant error handling * Remove unused envType argument from NewRouterEndpoint * Remove unsused secretName argument in buildRouterEnvs * Remove unused envType argument from NewEnricherService * Remove unused envType argument from NewEnsemblerService * Rename unused request argument in experiments api methods * Rename unused arguments in routers api * Rename unused arguments in all remaining api files * Rename unused arguments in router deployment service test file * Remove obsolete labels from mocked and expected responses * Remove redundant fields * Align sdk e2e test configs with those in api tests * Add additional steps to update enricher and ensemblers separately * Remove obsolete todo comment * Add an additional step to sdk e2e test to ensure that the router status is pending * Add additional checks before saving enrichers and ensemblers to db
1 parent 6824961 commit 6c7b8be

17 files changed

+71
-83
lines changed

api/e2e/test/config/config.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,7 @@ func (k *K8sConfig) UnmarshalYAML(unmarshal func(interface{}) error) error {
9292
return err
9393
}
9494
// use sigyaml.Unmarshal to convert to json object then unmarshal
95-
if err := sigyaml.Unmarshal(byteForm, k); err != nil {
96-
return err
97-
}
98-
return nil
95+
return sigyaml.Unmarshal(byteForm, k)
9996
}
10097

10198
type ClusterConfig struct {

api/e2e/test/router_e2e_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
184184

185185
Eventually(func(g Gomega) {
186186
router = api.GetRouter(apiE, routerCtx.ProjectID, routerCtx.ID)
187-
// TODO: Why is it pending? - g.Expect(router.Value("status").Raw()).To(Equal(api.Status.Pending))
188187
g.Expect(router.Value("status").Raw()).To(Equal(api.Status.Undeployed))
189188
}, arbitraryUpdateIntervals...).Should(Succeed())
190189
})

api/turing/api/alerts_api.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ func (c AlertsController) CreateAlert(r *http.Request, vars RequestVars, body in
5959
return Ok(created)
6060
}
6161

62-
func (c AlertsController) ListAlerts(r *http.Request, vars RequestVars, _ interface{}) *Response {
62+
func (c AlertsController) ListAlerts(_ *http.Request, vars RequestVars, _ interface{}) *Response {
6363
if c.AlertService == nil {
6464
return BadRequest(ErrAlertDisabled.Error(), "")
6565
}
@@ -79,7 +79,7 @@ func (c AlertsController) ListAlerts(r *http.Request, vars RequestVars, _ interf
7979
return Ok(alerts)
8080
}
8181

82-
func (c AlertsController) GetAlert(r *http.Request, vars RequestVars, _ interface{}) *Response {
82+
func (c AlertsController) GetAlert(_ *http.Request, vars RequestVars, _ interface{}) *Response {
8383
if c.AlertService == nil {
8484
return BadRequest(ErrAlertDisabled.Error(), "")
8585
}

api/turing/api/ensemblers_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type EnsemblersController struct {
1616
}
1717

1818
func (c EnsemblersController) ListEnsemblers(
19-
r *http.Request,
19+
_ *http.Request,
2020
vars RequestVars,
2121
_ interface{},
2222
) *Response {

api/turing/api/ensembling_job_api.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ type EnsemblingJobController struct {
1818
// Create is a HTTP Post Method that creates an Ensembling job.
1919
// This method will only return the acceptance/rejection of the job rather than the actual result of the job.
2020
func (c EnsemblingJobController) Create(
21-
r *http.Request,
21+
_ *http.Request,
2222
vars RequestVars,
2323
body interface{},
2424
) *Response {

api/turing/api/experiments_api.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ func (c ExperimentsController) ListExperimentEngines(
2222

2323
// ListExperimentEngineClients returns a list of clients on the given experiment engine
2424
func (c ExperimentsController) ListExperimentEngineClients(
25-
r *http.Request,
25+
_ *http.Request,
2626
vars RequestVars,
2727
_ interface{},
2828
) *Response {
@@ -42,7 +42,7 @@ func (c ExperimentsController) ListExperimentEngineClients(
4242
// ListExperimentEngineExperiments returns a list of experiments on the given experiment engine,
4343
// optionally tied to the given client id
4444
func (c ExperimentsController) ListExperimentEngineExperiments(
45-
r *http.Request,
45+
_ *http.Request,
4646
vars RequestVars,
4747
_ interface{},
4848
) *Response {
@@ -64,7 +64,7 @@ func (c ExperimentsController) ListExperimentEngineExperiments(
6464

6565
// ListExperimentEngineVariables returns a list of variables for the given client and/or experiments
6666
func (c ExperimentsController) ListExperimentEngineVariables(
67-
r *http.Request,
67+
_ *http.Request,
6868
vars RequestVars,
6969
_ interface{},
7070
) *Response {

api/turing/api/router_versions_api.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type RouterVersionsController struct {
1616

1717
// ListRouterVersions lists the router versions of the provided router.
1818
func (c RouterVersionsController) ListRouterVersions(
19-
r *http.Request,
19+
_ *http.Request,
2020
vars RequestVars, _ interface{},
2121
) *Response {
2222
// Parse request vars
@@ -38,7 +38,7 @@ func (c RouterVersionsController) ListRouterVersions(
3838
// CreateRouterVersion creates a router version from the provided configuration. If no router exists
3939
// within the provided project with the provided id, this method will throw an error.
4040
// If the update is valid, a new RouterVersion will be created but NOT deployed.
41-
func (c RouterVersionsController) CreateRouterVersion(r *http.Request, vars RequestVars, body interface{}) *Response {
41+
func (c RouterVersionsController) CreateRouterVersion(_ *http.Request, vars RequestVars, body interface{}) *Response {
4242
// Parse request vars
4343
var errResp *Response
4444
var router *models.Router
@@ -81,7 +81,7 @@ func (c RouterVersionsController) CreateRouterVersion(r *http.Request, vars Requ
8181

8282
// GetRouterVersion gets the router version for the provided router id and version number.
8383
func (c RouterVersionsController) GetRouterVersion(
84-
r *http.Request,
84+
_ *http.Request,
8585
vars RequestVars, _ interface{},
8686
) *Response {
8787
// Parse request vars
@@ -97,7 +97,7 @@ func (c RouterVersionsController) GetRouterVersion(
9797

9898
// DeleteRouterVersion deletes the config for the given version number.
9999
func (c RouterVersionsController) DeleteRouterVersion(
100-
r *http.Request,
100+
_ *http.Request,
101101
vars RequestVars,
102102
_ interface{},
103103
) *Response {
@@ -132,9 +132,9 @@ func (c RouterVersionsController) DeleteRouterVersion(
132132

133133
// DeployRouterVersion deploys the given router version into the associated kubernetes cluster
134134
func (c RouterVersionsController) DeployRouterVersion(
135-
r *http.Request,
135+
_ *http.Request,
136136
vars RequestVars,
137-
body interface{},
137+
_ interface{},
138138
) *Response {
139139
// Parse request vars
140140
var errResp *Response

api/turing/api/routers_api.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ type RoutersController struct {
2020
// ListRouters lists all routers configured in the provided project.
2121
// If none are found, an error will be thrown.
2222
func (c RoutersController) ListRouters(
23-
r *http.Request,
23+
_ *http.Request,
2424
vars RequestVars, _ interface{},
2525
) *Response {
2626
// Parse input
@@ -41,7 +41,7 @@ func (c RoutersController) ListRouters(
4141

4242
// GetRouter gets a router matching the provided routerID.
4343
func (c RoutersController) GetRouter(
44-
r *http.Request,
44+
_ *http.Request,
4545
vars RequestVars, _ interface{},
4646
) *Response {
4747
// Parse input
@@ -59,7 +59,7 @@ func (c RoutersController) GetRouter(
5959
// a router within the provided project with the same name, this method will throw an error.
6060
// If not, a new Router and associated RouterVersion will be created and deployed.
6161
func (c RoutersController) CreateRouter(
62-
r *http.Request,
62+
_ *http.Request,
6363
vars RequestVars,
6464
body interface{},
6565
) *Response {
@@ -134,7 +134,7 @@ func (c RoutersController) CreateRouter(
134134
// UpdateRouter updates a router from the provided configuration. If no router exists
135135
// within the provided project with the provided id, this method will throw an error.
136136
// If the update is valid, a new RouterVersion will be created and deployed.
137-
func (c RoutersController) UpdateRouter(r *http.Request, vars RequestVars, body interface{}) *Response {
137+
func (c RoutersController) UpdateRouter(_ *http.Request, vars RequestVars, body interface{}) *Response {
138138
// Parse request vars
139139
var errResp *Response
140140
var project *mlp.Project
@@ -196,7 +196,7 @@ func (c RoutersController) UpdateRouter(r *http.Request, vars RequestVars, body
196196

197197
// DeleteRouter deletes a router and all its associated versions.
198198
func (c RoutersController) DeleteRouter(
199-
r *http.Request,
199+
_ *http.Request,
200200
vars RequestVars,
201201
_ interface{},
202202
) *Response {
@@ -231,9 +231,9 @@ func (c RoutersController) DeleteRouter(
231231
// DeployRouter deploys the current version of the given router into the associated
232232
// kubernetes cluster. If there is no current version, an error is returned.
233233
func (c RoutersController) DeployRouter(
234-
r *http.Request,
234+
_ *http.Request,
235235
vars RequestVars,
236-
body interface{},
236+
_ interface{},
237237
) *Response {
238238
// Parse request vars
239239
var errResp *Response
@@ -284,9 +284,9 @@ func (c RoutersController) DeployRouter(
284284

285285
// UndeployRouter deletes the given router specs from the associated kubernetes cluster
286286
func (c RoutersController) UndeployRouter(
287-
r *http.Request,
287+
_ *http.Request,
288288
vars RequestVars,
289-
body interface{},
289+
_ interface{},
290290
) *Response {
291291
// Parse request vars
292292
var errResp *Response
@@ -308,9 +308,9 @@ func (c RoutersController) UndeployRouter(
308308
return Ok(map[string]int{"router_id": int(router.ID)})
309309
}
310310

311-
func (c RoutersController) ListRouterEvents(r *http.Request,
311+
func (c RoutersController) ListRouterEvents(_ *http.Request,
312312
vars RequestVars,
313-
body interface{},
313+
_ interface{},
314314
) *Response {
315315
// Parse request vars
316316
var errResp *Response

api/turing/cluster/servicebuilder/router.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ func (sb *clusterSvcBuilder) NewRouterService(
123123

124124
// Build env vars
125125
envs, err := sb.buildRouterEnvs(namespace, envType, routerDefaults,
126-
sentryEnabled, sentryDSN, secretName, routerVersion)
126+
sentryEnabled, sentryDSN, routerVersion)
127127
if err != nil {
128128
return nil, err
129129
}
@@ -166,7 +166,6 @@ func (sb *clusterSvcBuilder) NewRouterService(
166166
func (sb *clusterSvcBuilder) NewRouterEndpoint(
167167
routerVersion *models.RouterVersion,
168168
project *mlp.Project,
169-
envType string,
170169
versionEndpoint string,
171170
) (*cluster.VirtualService, error) {
172171
labels := buildLabels(project, routerVersion.Router)
@@ -208,7 +207,6 @@ func (sb *clusterSvcBuilder) buildRouterEnvs(
208207
routerDefaults *config.RouterDefaults,
209208
sentryEnabled bool,
210209
sentryDSN string,
211-
secretName string,
212210
ver *models.RouterVersion,
213211
) ([]corev1.EnvVar, error) {
214212
// Add app name, router timeout, jaeger collector

api/turing/cluster/servicebuilder/router_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,7 +1058,7 @@ func TestNewRouterEndpoint(t *testing.T) {
10581058
MatchURIPrefixes: defaultMatchURIPrefixes,
10591059
}
10601060

1061-
got, err := sb.NewRouterEndpoint(&routerVersion, project, "test-env", versionEndpoint)
1061+
got, err := sb.NewRouterEndpoint(&routerVersion, project, versionEndpoint)
10621062
assert.NoError(t, err)
10631063
assert.Equal(t, expected, got)
10641064
}
@@ -1193,7 +1193,6 @@ func TestBuildRouterEnvsResultLogger(t *testing.T) {
11931193
tt.args.routerDefaults,
11941194
tt.args.sentryEnabled,
11951195
tt.args.sentryDSN,
1196-
tt.args.secretName,
11971196
tt.args.ver)
11981197
assert.Equal(t, tt.want, got)
11991198
})

0 commit comments

Comments
 (0)