Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: block/ftl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: cc2bac798276928a10d7d66f93423e742526c09a
Choose a base ref
..
head repository: block/ftl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: ed20faec581d6c08af91ae42f70433cf054a5ac1
Choose a head ref
Showing with 12 additions and 17 deletions.
  1. +8 −9 backend/controller/controller.go
  2. +1 −1 backend/controller/dal/dal.go
  3. +1 −5 backend/controller/dal/notify.go
  4. +1 −1 cmd/ftl/cmd_serve.go
  5. +1 −1 common/configuration/asm_follower.go
17 changes: 8 additions & 9 deletions backend/controller/controller.go
Original file line number Diff line number Diff line change
@@ -202,7 +202,7 @@ type Service struct {
pubSub *pubsub.Manager
controllerListListeners []ControllerListListener

// Map from runnerKey.String() to client.
// Map from endpoint to client.
clients *ttlcache.Cache[string, clients]

// Complete schema synchronised from the database.
@@ -963,7 +963,7 @@ func (s *Service) callWithRequest(
return nil, connect.NewError(connect.CodeNotFound, fmt.Errorf("no routes for module %q", module))
}
route := routes[rand.Intn(len(routes))] //nolint:gosec
client := s.clientsForRunner(route.Runner, route.Endpoint)
client := s.clientsForEndpoint(route.Endpoint)

callers, err := headers.GetCallers(req.Header())
if err != nil {
@@ -1134,17 +1134,17 @@ func (s *Service) getDeployment(ctx context.Context, key string) (*model.Deploym
return deployment, nil
}

// Return or create the RunnerService and VerbService clients for a Runner.
func (s *Service) clientsForRunner(key model.RunnerKey, endpoint string) clients {
clientItem := s.clients.Get(key.String())
// Return or create the RunnerService and VerbService clients for a Runner endpoint.
func (s *Service) clientsForEndpoint(endpoint string) clients {
clientItem := s.clients.Get(endpoint)
if clientItem != nil {
return clientItem.Value()
}
client := clients{
runner: rpc.Dial(ftlv1connect.NewRunnerServiceClient, endpoint, log.Error),
verb: rpc.Dial(ftlv1connect.NewVerbServiceClient, endpoint, log.Error),
}
s.clients.Set(key.String(), client, time.Minute)
s.clients.Set(endpoint, client, time.Minute)
return client
}

@@ -1437,7 +1437,7 @@ func (s *Service) terminateRandomRunner(ctx context.Context, key model.Deploymen
return false, nil
}
runner := runners[rand.Intn(len(runners))] //nolint:gosec
client := s.clientsForRunner(runner.Key, runner.Endpoint)
client := s.clientsForEndpoint(runner.Endpoint)
resp, err := client.runner.Terminate(ctx, connect.NewRequest(&ftlv1.TerminateRequest{DeploymentKey: key.String()}))
if err != nil {
return false, err
@@ -1477,8 +1477,7 @@ func (s *Service) reserveRunner(ctx context.Context, reconcile model.Deployment)
}

err = dal.WithReservation(reservationCtx, claim, func() error {
runner := claim.Runner()
client = s.clientsForRunner(runner.Key, runner.Endpoint)
client = s.clientsForEndpoint(claim.Runner().Endpoint)
_, err = client.runner.Reserve(reservationCtx, connect.NewRequest(&ftlv1.ReserveRequest{DeploymentKey: reconcile.Key.String()}))
if err != nil {
return fmt.Errorf("failed request to reserve a runner for %s at %s: %w", reconcile.Key, claim.Runner().Endpoint, err)
2 changes: 1 addition & 1 deletion backend/controller/dal/dal.go
Original file line number Diff line number Diff line change
@@ -252,7 +252,7 @@ type Tx struct {
func (t *Tx) CommitOrRollback(ctx context.Context, err *error) {
tx, ok := t.db.(*sql.Tx)
if !ok {
panic("inconceivable")
panic("inconcievable")
}
tx.CommitOrRollback(ctx, err)
}
6 changes: 1 addition & 5 deletions backend/controller/dal/notify.go
Original file line number Diff line number Diff line change
@@ -84,11 +84,7 @@ func (d *DAL) PollDeployments(ctx context.Context) {

deployments, err := d.GetDeploymentsWithMinReplicas(ctx)
if err != nil {
if ctx.Err() == context.Canceled {
logger.Debugf("Polling stopped: %v", ctx.Err())
return
}
logger.Errorf(err, "failed to get deployments when polling")
logger.Errorf(err, "failed to get deployments")
time.Sleep(retry.Duration())
continue
}
2 changes: 1 addition & 1 deletion cmd/ftl/cmd_serve.go
Original file line number Diff line number Diff line change
@@ -94,7 +94,7 @@ func (s *serveCmd) run(ctx context.Context, projConfig projectconfig.Config, ini

err = observability.Init(ctx, "ftl-serve", ftl.Version, s.ObservabilityConfig)
if err != nil {
return err
return fmt.Errorf("observability init failed: %w", err)
}

wg, ctx := errgroup.WithContext(ctx)
2 changes: 1 addition & 1 deletion common/configuration/asm_follower.go
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ import (
"github.com/TBD54566975/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
)

const asmFollowerSyncInterval = time.Second * 10
const asmFollowerSyncInterval = time.Minute * 1

// asmFollower uses AdminService to get/set secrets from the leader
type asmFollower struct {