Skip to content

Commit

Permalink
Use same runner id generation as production
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Mar 7, 2024
1 parent 6e026f4 commit 3af4a9a
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 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 All @@ -28,8 +27,6 @@ type LocalScaling struct {

portAllocator *bind.BindAllocator
controllerAddresses []*url.URL

idSeed int
}

func NewLocalScaling(portAllocator *bind.BindAllocator, controllerAddresses []*url.URL) (*LocalScaling, error) {
Expand Down Expand Up @@ -82,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 @@ -92,18 +90,6 @@ func (l *LocalScaling) SetReplicas(ctx context.Context, replicas int, idleRunner
return err
}

// Create a readable ULID for the runner.
idSeed := l.idSeed + 1
l.idSeed = idSeed

var ulid [16]byte
binary.BigEndian.PutUint32(ulid[10:], uint32(idSeed))
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

0 comments on commit 3af4a9a

Please sign in to comment.