Skip to content

Commit

Permalink
Remove decryption when retrieving secret from MLP (#338)
Browse files Browse the repository at this point in the history
* Update mlp client

* Remove decryption when retrieving secret from MLP

* Fix lint

* Fix mlp path

* Update default mlp url in documentation and local dev setup

---------

Co-authored-by: Pradithya Aria <pradithya.pura@go-jek.com>
  • Loading branch information
pradithya and Pradithya Aria committed May 26, 2023
1 parent 295bff9 commit 21ddbb1
Show file tree
Hide file tree
Showing 16 changed files with 104 additions and 113 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ ClusterConfig:
TuringEncryptionKey: password
MLPConfig:
MerlinURL: http://localhost:8082/v1
MLPURL: http://localhost:8081/v1
MLPURL: http://localhost:8081
MLPEncryptionKey: password
TuringUIConfig:
ServingDirectory: ../ui/build
Expand Down Expand Up @@ -337,7 +337,7 @@ Then, update the config file `.env.development.local` as shown below.
```
REACT_APP_HOMEPAGE=/turing
REACT_APP_TURING_API=http://localhost:8080/v1
REACT_APP_MLP_API=http://localhost:8081/v1
REACT_APP_MLP_API=http://localhost:8081
REACT_APP_MERLIN_API=http://localhost:8082/v1
REACT_APP_OAUTH_CLIENT_ID=xxxxxxx.apps.googleusercontent.com
REACT_APP_DEFAULT_DOCKER_REGISTRY=docker.io
Expand Down
2 changes: 1 addition & 1 deletion api/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ VAULT_ADDRESS=http://vault.example.com:8200/
VAULT_TOKEN=

MERLIN_URL=http://mlp.example.com/api/merlin/v1
MLP_URL=http://mlp.example.com/api/v1
MLP_URL=http://mlp.example.com/api
MLP_ENCRYPTION_KEY=

TURING_ENCRYPTION_KEY=test_encryption_key
Expand Down
2 changes: 1 addition & 1 deletion api/config-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ ClusterConfig:
TuringEncryptionKey: password
MLPConfig:
MerlinURL: http://localhost:8082/v1
MLPURL: http://localhost:8081/v1
MLPURL: http://localhost:8081
MLPEncryptionKey: password
TuringUIConfig:
ServingDirectory: ../ui/build
Expand Down
26 changes: 13 additions & 13 deletions api/e2e/test/router_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
WithJSON(json.RawMessage(`[{"client": {"id": 4}}, {"client": {"id": 7}}]`)).
Expect().Status(http.StatusOK).
JSON().Array().
Equal(JSONPayload("testdata/responses/router_proprietary_exp_batch_predict.json"))
IsEqual(JSONPayload("testdata/responses/router_proprietary_exp_batch_predict.json"))
})
})
})
Expand Down Expand Up @@ -116,13 +116,13 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
}, defaultDeploymentIntervals...).Should(Succeed())

version.
ValueEqual("status", api.Status.Failed).
ValueEqual("error", "Requested CPU is more than max permissible")
HasValue("status", api.Status.Failed).
HasValue("error", "Requested CPU is more than max permissible")
})

It("keeps previously deployed version active", func() {
router = api.GetRouter(apiE, routerCtx.ProjectID, routerCtx.ID)
router.Path("$.config.version").Equal(1)
router.Path("$.config.version").IsEqual(1)
})
})
})
Expand Down Expand Up @@ -197,8 +197,8 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
}, defaultDeploymentIntervals...).Should(Succeed())

version.
ValueEqual("status", api.Status.Failed).
ValueEqual("error", "Requested CPU is more than max permissible")
HasValue("status", api.Status.Failed).
HasValue("error", "Requested CPU is more than max permissible")
})

It("keeps previous valid version as router's current version", func() {
Expand Down Expand Up @@ -244,8 +244,8 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
}, defaultDeploymentIntervals...).Should(Succeed())

router.
ValueEqual("status", api.Status.Deployed).
Path("$.config.version").Equal(1)
HasValue("status", api.Status.Deployed).
Path("$.config.version").IsEqual(1)
})
})
})
Expand Down Expand Up @@ -276,7 +276,7 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
}, defaultDeploymentIntervals...).Should(Succeed())

version.
ValueEqual("status", api.Status.Deployed).
HasValue("status", api.Status.Deployed).
NotContainsKey("error")
})

Expand All @@ -290,8 +290,8 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp

It("updates router's configuration to the new version", func() {
api.GetRouter(apiE, routerCtx.ProjectID, routerCtx.ID).
ValueEqual("status", api.Status.Deployed).
Path("$.config.version").Equal(3)
HasValue("status", api.Status.Deployed).
Path("$.config.version").IsEqual(3)
})
})

Expand Down Expand Up @@ -320,7 +320,7 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
WithPath("routerId", routerCtx.ID).
Expect().Status(http.StatusBadRequest).
JSON().
Equal(json.RawMessage(`{
IsEqual(json.RawMessage(`{
"description": "invalid delete request",
"error": "router is currently deployed. Undeploy it first."
}`))
Expand Down Expand Up @@ -366,7 +366,7 @@ var _ = DeployedRouterContext("testdata/create_router_nop_logger_proprietary_exp
WithPath("routerId", routerCtx.ID).
Expect().Status(http.StatusNotFound).
JSON().
Equal(json.RawMessage(`{
IsEqual(json.RawMessage(`{
"description": "router not found",
"error": "record not found"
}`))
Expand Down
10 changes: 6 additions & 4 deletions api/e2e/test/router_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var _ = DeployedRouterContext("testdata/create_router_std_ensembler_proprietary_
WithJSON(json.RawMessage(`{"client": {"id": 4}}`)).
Expect().
Status(http.StatusOK).
JSON().Equal(json.RawMessage(`{"version": "control"}`))
JSON().IsEqual(json.RawMessage(`{"version": "control"}`))
})
})

Expand All @@ -48,7 +48,7 @@ var _ = DeployedRouterContext("testdata/create_router_std_ensembler_proprietary_
WithJSON(json.RawMessage(`{"client": {"id": 7}}`)).
Expect().
Status(http.StatusOK).
JSON().Equal(json.RawMessage(`{"version": "treatment-a"}`))
JSON().IsEqual(json.RawMessage(`{"version": "treatment-a"}`))
})
})
})
Expand All @@ -70,7 +70,8 @@ var _ = DeployedRouterContext("testdata/create_router_with_traffic_rules.json.tm
When("request satisfies the first traffic rule", func() {
It("responds with responses from `treatment-a` route", func() {
want = httpexpect.
NewValue(GinkgoT(), JSONPayload("testdata/responses/traffic_rules/traffic-rule-1.json")).
NewValue(GinkgoT(),
JSONPayload("testdata/responses/traffic_rules/traffic-rule-1.json")).
Object()

got = config.NewHTTPExpect(GinkgoT(), routerCtx.Endpoint).
Expand All @@ -87,7 +88,8 @@ var _ = DeployedRouterContext("testdata/create_router_with_traffic_rules.json.tm
When("request satisfies the second traffic rule", func() {
It("responds with responses from `treatment-b` route", func() {
want = httpexpect.
NewValue(GinkgoT(), JSONPayload("testdata/responses/traffic_rules/traffic-rule-2.json")).
NewValue(GinkgoT(),
JSONPayload("testdata/responses/traffic_rules/traffic-rule-2.json")).
Object()

got = config.NewHTTPExpect(GinkgoT(), routerCtx.Endpoint).
Expand Down
10 changes: 5 additions & 5 deletions api/e2e/test/routers_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ func DeployedRouterContext(payloadTpl string, protocol routerConfig.Protocol, ar
}, defaultDeploymentIntervals...).Should(Succeed())

router.
ValueEqual("status", "deployed").
Value("config").Object().ValueEqual("version", 1)
HasValue("status", "deployed").
Value("config").Object().HasValue("version", 1)

endpoint, err := url.Parse(router.Value("endpoint").String().Raw())
Expect(err).ShouldNot(HaveOccurred())
Expand Down Expand Up @@ -292,12 +292,12 @@ func AssertResponsePayload(want, got *httpexpect.Object) {

if len(resp.Response.RouteResponses) > 0 {
got.
ValueEqual("request", want.Value("request").Raw()).
HasValue("request", want.Value("request").Raw()).
Value("response").Object().
ValueEqual("experiment", want.Path("$.response.experiment").Raw()).
HasValue("experiment", want.Path("$.response.experiment").Raw()).
Value("route_responses").Array().
ContainsOnly(want.Path("$.response.route_responses").Array().Raw()...)
} else {
got.Equal(want.Raw())
got.IsEqual(want.Raw())
}
}
23 changes: 13 additions & 10 deletions api/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ require (
github.com/GoogleCloudPlatform/spark-on-k8s-operator v0.0.0-20220214044918-55732a6a392c
github.com/antihax/optional v1.0.0
github.com/caraml-dev/merlin v0.0.0
github.com/caraml-dev/mlp v1.7.7-0.20230428104022-779530aec912
github.com/caraml-dev/mlp v1.7.7-0.20230519042541-3415407aa27b
github.com/caraml-dev/turing/engines/experiment v0.0.0
github.com/caraml-dev/turing/engines/router v0.0.0
github.com/caraml-dev/universal-prediction-interface v0.3.4
github.com/gavv/httpexpect/v2 v2.3.1
github.com/gavv/httpexpect/v2 v2.15.0
github.com/getkin/kin-openapi v0.76.0
github.com/ghodss/yaml v1.0.0
github.com/go-playground/validator/v10 v10.11.1
Expand Down Expand Up @@ -60,7 +60,7 @@ require (
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/ajg/form v1.5.1 // indirect
github.com/andybalholm/brotli v1.0.3 // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/buger/jsonparser v1.1.1 // indirect
Expand Down Expand Up @@ -94,10 +94,11 @@ require (
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator v9.31.0+incompatible // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect
Expand All @@ -114,7 +115,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/imkira/go-interpol v1.0.0 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
github.com/jackc/pgconn v1.13.0 // indirect
github.com/jackc/pgio v1.0.0 // indirect
Expand All @@ -133,11 +134,12 @@ require (
github.com/lib/pq v1.10.3 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.11 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
Expand All @@ -154,6 +156,7 @@ require (
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/sanity-io/litter v1.5.5 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/sirupsen/logrus v1.9.0 // indirect
github.com/spf13/afero v1.9.2 // indirect
Expand All @@ -166,8 +169,8 @@ require (
github.com/uber/jaeger-client-go v2.25.0+incompatible // indirect
github.com/uber/jaeger-lib v2.4.0+incompatible // indirect
github.com/valyala/bytebufferpool v1.0.0 // indirect
github.com/valyala/fasthttp v1.30.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f // indirect
github.com/valyala/fasthttp v1.34.0 // indirect
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
Expand Down Expand Up @@ -197,7 +200,7 @@ require (
k8s.io/kube-openapi v0.0.0-20211109043538-20434351676c // indirect
k8s.io/utils v0.0.0-20221107191617-1a15be271d1d // indirect
knative.dev/networking v0.0.0-20211101215640-8c71a2708e7d // indirect
moul.io/http2curl v1.0.1-0.20190925090545-5cd742060b0e // indirect
moul.io/http2curl/v2 v2.3.0 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
)

Expand Down
Loading

0 comments on commit 21ddbb1

Please sign in to comment.