Skip to content

Commit

Permalink
Merge branch 'main' into worstell/20240306-validate-enums-ingress
Browse files Browse the repository at this point in the history
  • Loading branch information
worstell authored Mar 7, 2024
2 parents c75e278 + 2b8f713 commit 6fdf5eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
5 changes: 3 additions & 2 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Config struct {
RunnerTimeout time.Duration `help:"Runner heartbeat timeout." default:"10s"`
DeploymentReservationTimeout time.Duration `help:"Deployment reservation timeout." default:"120s"`
ArtefactChunkSize int `help:"Size of each chunk streamed to the client." default:"1048576"`
IdleRunners int `help:"Number of idle runners to keep around (not supported in production)." default:"1"`
}

func (c *Config) SetDefaults() {
Expand Down Expand Up @@ -787,7 +788,7 @@ func (s *Service) reconcileDeployments(ctx context.Context) (time.Duration, erro
deploymentLogger.Debugf("Need %d more runners for %s", require, reconcile.Deployment)
wg.Go(func(ctx context.Context) error {
if err := s.deploy(ctx, deployment); err != nil {
deploymentLogger.Debugf("Failed to increase deployment replicas: %s", err)
deploymentLogger.Errorf(err, "Failed to increase deployment replicas")
} else {
deploymentLogger.Debugf("Reconciled %s to %d/%d replicas", reconcile.Deployment, reconcile.AssignedReplicas+1, reconcile.RequiredReplicas)
if reconcile.AssignedReplicas+1 == reconcile.RequiredReplicas {
Expand Down Expand Up @@ -825,7 +826,7 @@ func (s *Service) reconcileRunners(ctx context.Context) (time.Duration, error) {
return 0, fmt.Errorf("%s: %w", "failed to get deployments needing reconciliation", err)
}

totalRunners := 0
totalRunners := s.config.IdleRunners
for _, deployment := range activeDeployments {
totalRunners += deployment.MinReplicas
}
Expand Down
11 changes: 1 addition & 10 deletions backend/controller/scaling/localscaling/local_scaling.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package localscaling

import (
"context"
"encoding/binary"
"errors"
"fmt"
"net/url"
Expand Down Expand Up @@ -80,6 +79,7 @@ func (l *LocalScaling) SetReplicas(ctx context.Context, replicas int, idleRunner
Bind: l.portAllocator.Next(),
ControllerEndpoint: controllerEndpoint,
TemplateDir: templateDir(ctx),
Key: model.NewRunnerKey(),
}

name := fmt.Sprintf("runner%d", i)
Expand All @@ -90,15 +90,6 @@ func (l *LocalScaling) SetReplicas(ctx context.Context, replicas int, idleRunner
return err
}

// Create a readable ULID for the runner.
var ulid [16]byte
binary.BigEndian.PutUint32(ulid[10:], uint32(len(l.runners)+1))
ulidStr := fmt.Sprintf("%025X", ulid)
err := config.Key.Scan(ulidStr)
if err != nil {
return err
}

runnerCtx := log.ContextWithLogger(ctx, logger.Scope(name))

runnerCtx, cancel := context.WithCancel(runnerCtx)
Expand Down
2 changes: 2 additions & 0 deletions cmd/ftl/cmd_serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type serveCmd struct {
Background bool `help:"Run in the background." default:"false"`
Stop bool `help:"Stop the running FTL instance. Can be used to --background to restart the server" default:"false"`
StartupTimeout time.Duration `help:"Timeout for the server to start up." default:"20s"`
IdleRunners int `help:"Number of idle runners to keep around (not supported in production)." default:"1"`
}

const ftlContainerName = "ftl-db-1"
Expand Down Expand Up @@ -100,6 +101,7 @@ func (s *serveCmd) Run(ctx context.Context) error {
DSN: dsn,
AllowOrigins: s.AllowOrigins,
NoConsole: s.NoConsole,
IdleRunners: s.IdleRunners,
}
if err := kong.ApplyDefaults(&config); err != nil {
return err
Expand Down

0 comments on commit 6fdf5eb

Please sign in to comment.