Skip to content

Commit

Permalink
Merge pull request #1783 from mesg-foundation/feature/simplify-inst-e…
Browse files Browse the repository at this point in the history
…nv-hash

Calculate the instance env hash with only the customized env
  • Loading branch information
antho1404 authored Apr 14, 2020
2 parents bbc506f + 58bfa5a commit 209a08a
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 18 deletions.
2 changes: 1 addition & 1 deletion server/grpc/orchestrator/runner.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/grpc/orchestrator/runner.proto
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ message RunnerRegisterRequest {
(gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash"
];

// Hash of the environmental variables to start the runner with.
// Hash of the customized environmental variables (not the ones in the service configuration).
bytes envHash = 2 [
(gogoproto.moretags) = 'validate:"omitempty,hash"',
(gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash"
Expand Down
15 changes: 1 addition & 14 deletions x/runner/client/rest/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ import (
"github.com/cosmos/cosmos-sdk/client/context"
"github.com/cosmos/cosmos-sdk/types/rest"
"github.com/gorilla/mux"
"github.com/mesg-foundation/engine/ext/xos"
"github.com/mesg-foundation/engine/hash"
"github.com/mesg-foundation/engine/instance"
"github.com/mesg-foundation/engine/runner"
"github.com/mesg-foundation/engine/service"
"github.com/mesg-foundation/engine/x/runner/internal/types"
)

Expand Down Expand Up @@ -138,18 +136,7 @@ func queryHashHandlerFn(cliCtx context.CLIContext) http.HandlerFunc {
return
}

srvRes, _, err := cliCtx.Query("custom/service/get/" + req.ServiceHash.String())
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
return
}
var srv service.Service
if err := cliCtx.Codec.UnmarshalJSON(srvRes, &srv); err != nil {
rest.WriteErrorResponse(w, http.StatusInternalServerError, err.Error())
return
}

envHash := hash.Dump(xos.EnvMergeSlices(srv.Configuration.Env, req.Env))
envHash := hash.Dump(req.Env)
inst, err := instance.New(req.ServiceHash, envHash)
if err != nil {
rest.WriteErrorResponse(w, http.StatusBadRequest, err.Error())
Expand Down
2 changes: 1 addition & 1 deletion x/runner/internal/types/msg.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion x/runner/internal/types/msg.proto
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ message MsgCreate {
(gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash"
];

// Environmental variables to start the runner with.
// Hash of the customized environmental variables (not the ones in the service configuration).
bytes envHash = 3 [
(gogoproto.moretags) = 'validate:"omitempty,hash"',
(gogoproto.casttype) = "github.com/mesg-foundation/engine/hash.Hash"
Expand Down

0 comments on commit 209a08a

Please sign in to comment.