Skip to content

Commit

Permalink
Make the rollout knob GKE deployer specific
Browse files Browse the repository at this point in the history
Right now the `rollout` knob is global, and it applies to all deployers.
However, each deployer has its own rollout story. E.g., single, multi -
no rollout story, SSH - no rollout story, kube - up to the DevOps people
how to do it.

The rollout knob makes sense only for the GKE deployer, where we have a
custom rollout strategy, so it makes sense to make the knob a GKE
deployer specific knob. However, if in the future we'll decide to add a
system component that can compute rollout strategies and it can be
applied to many deployers, we can move it back.

I will remove the `rollout` knob from the weaver repo in a followup PR.
  • Loading branch information
rgrandl committed Oct 5, 2023
1 parent 465beec commit 5cc03cf
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 37 deletions.
71 changes: 43 additions & 28 deletions internal/config/config.pb.go

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

7 changes: 7 additions & 0 deletions internal/config/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,11 @@ message GKEConfig {
repeated string component = 1;
}
map<string, Components> identity_allowlist = 10;

// A knob that lets the user specifies how many nanoseconds it expects for
// the rollout to take. This is used internally by the GKE deployer to figure
// out the rollout strategy.
//
// If not specified, Service Weaver will pick a default value.
int64 rollout_nanos = 11;
}
2 changes: 1 addition & 1 deletion internal/gke/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ func enableMultiClusterServices(config CloudConfig) error {

func finalizeConfig(cloudConfig CloudConfig, gkeConfig *config.GKEConfig) error {
// Finalize the rollout duration.
if gkeConfig.Deployment.App.RolloutNanos == 0 {
if gkeConfig.RolloutNanos == 0 {
scanner := bufio.NewScanner(os.Stdin)
fmt.Print(
`No rollout duration specified in the config: the app version will be
Expand Down
2 changes: 1 addition & 1 deletion internal/nanny/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ func (c *controller) rollout(ctx context.Context, req *RolloutRequest) error {
}

// Compute the rollout strategy.
durationHint := time.Duration(req.Config.Deployment.App.RolloutNanos)
durationHint := time.Duration(req.Config.RolloutNanos)
rolloutLocs := make([]string, len(req.Locations))
for i := 0; i < len(req.Locations); i++ {
rolloutLocs[i] = req.Locations[i].Name
Expand Down
10 changes: 4 additions & 6 deletions internal/nanny/controller/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1316,13 +1316,11 @@ func registerNewAppVersion(ctx context.Context, controller *controller, v versio
req := &RolloutRequest{
Config: &config.GKEConfig{
Deployment: &protos.Deployment{
App: &protos.AppConfig{
Name: v.appName,
RolloutNanos: int64(rollout),
},
Id: v.id,
App: &protos.AppConfig{Name: v.appName},
Id: v.id,
},
Listeners: v.listenerOpts,
Listeners: v.listenerOpts,
RolloutNanos: int64(rollout),
},
}
for _, location := range v.locations {
Expand Down
4 changes: 3 additions & 1 deletion internal/tool/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func makeGKEConfig(app *protos.AppConfig) (*config.GKEConfig, error) {
Regions []string
Listeners map[string]lisOpts
MTLS bool
Rollout time.Duration
}
parsed := &gkeConfigSchema{}
if err := runtime.ParseConfigSection(gkeKey, shortGKEKey, app.Sections, parsed); err != nil {
Expand Down Expand Up @@ -157,7 +158,8 @@ func makeGKEConfig(app *protos.AppConfig) (*config.GKEConfig, error) {
App: app,
Id: depID.String(),
},
Mtls: parsed.MTLS,
Mtls: parsed.MTLS,
RolloutNanos: int64(parsed.Rollout),
}

return cfg, nil
Expand Down

0 comments on commit 5cc03cf

Please sign in to comment.