Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartwdouglas committed Sep 4, 2024
1 parent f6bf629 commit 89204e6
Show file tree
Hide file tree
Showing 67 changed files with 188 additions and 369 deletions.
3 changes: 0 additions & 3 deletions Dockerfile.box
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ RUN go mod download -x

COPY . /src/

# Build runner template
RUN just build-kt-runtime

# Build runner
RUN just errtrace
# Reset timestamps so that the build state is reset
Expand Down
36 changes: 0 additions & 36 deletions Dockerfile.provisioner

This file was deleted.

3 changes: 0 additions & 3 deletions Dockerfile.runner
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ RUN go mod download -x

COPY . /src/

# Build runner template
RUN just build-kt-runtime

# Build runner
RUN just errtrace
# Reset timestamps so that the build state is reset
Expand Down
4 changes: 2 additions & 2 deletions backend/controller/console/testdata/go/console/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/cronjobs/testdata/go/cron/go.sum

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

21 changes: 0 additions & 21 deletions backend/controller/dal/dal.go
Original file line number Diff line number Diff line change
Expand Up @@ -731,27 +731,6 @@ func (d *DAL) deploymentWillDeactivate(ctx context.Context, key model.Deployment
return d.removeSubscriptionsAndSubscribers(ctx, key)
}

// GetDeploymentsNeedingReconciliation returns deployments that have a
// mismatch between the number of assigned and required replicas.
func (d *DAL) GetDeploymentsNeedingReconciliation(ctx context.Context) ([]Reconciliation, error) {
counts, err := d.db.GetDeploymentsNeedingReconciliation(ctx)
if err != nil {
if libdal.IsNotFound(err) {
return nil, nil
}
return nil, libdal.TranslatePGError(err)
}
return slices.Map(counts, func(t dalsql.GetDeploymentsNeedingReconciliationRow) Reconciliation {
return Reconciliation{
Deployment: t.DeploymentKey,
Module: t.ModuleName,
Language: t.Language,
AssignedReplicas: int(t.AssignedRunnersCount),
RequiredReplicas: int(t.RequiredRunnersCount),
}
}), nil
}

// GetActiveDeployments returns all active deployments.
func (d *DAL) GetActiveDeployments(ctx context.Context) ([]Deployment, error) {
rows, err := d.db.GetActiveDeployments(ctx)
Expand Down
46 changes: 12 additions & 34 deletions backend/controller/dal/dal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,20 +105,22 @@ func TestDAL(t *testing.T) {

t.Run("RegisterRunner", func(t *testing.T) {
err = dal.UpsertRunner(ctx, Runner{
Key: runnerID,
Labels: labels,
Endpoint: "http://localhost:8080",
State: RunnerStateNew,
Key: runnerID,
Labels: labels,
Endpoint: "http://localhost:8080",
State: RunnerStateNew,
Deployment: deploymentKey,
})
assert.NoError(t, err)
})

t.Run("RegisterRunnerFailsOnDuplicate", func(t *testing.T) {
err = dal.UpsertRunner(ctx, Runner{
Key: model.NewRunnerKey("localhost", "8080"),
Labels: labels,
Endpoint: "http://localhost:8080",
State: RunnerStateNew,
Key: model.NewRunnerKey("localhost", "8080"),
Labels: labels,
Endpoint: "http://localhost:8080",
State: RunnerStateNew,
Deployment: deploymentKey,
})
assert.Error(t, err)
assert.IsError(t, err, libdal.ErrConflict)
Expand All @@ -132,29 +134,11 @@ func TestDAL(t *testing.T) {
Deployment: deploymentKey,
}

t.Run("GetDeploymentsNeedingReconciliation", func(t *testing.T) {
reconcile, err := dal.GetDeploymentsNeedingReconciliation(ctx)
assert.NoError(t, err)
assert.Equal(t, []Reconciliation{}, reconcile)
})

t.Run("SetDeploymentReplicas", func(t *testing.T) {
err := dal.SetDeploymentReplicas(ctx, deploymentKey, 1)
assert.NoError(t, err)
})

t.Run("GetDeploymentsNeedingReconciliation", func(t *testing.T) {
reconcile, err := dal.GetDeploymentsNeedingReconciliation(ctx)
assert.NoError(t, err)
assert.Equal(t, []Reconciliation{{
Deployment: deploymentKey,
Module: deployment.Module,
Language: deployment.Language,
AssignedReplicas: 0,
RequiredReplicas: 1,
}}, reconcile)
})

t.Run("UpdateRunnerAssigned", func(t *testing.T) {
err := dal.UpsertRunner(ctx, Runner{
Key: runnerID,
Expand All @@ -166,12 +150,6 @@ func TestDAL(t *testing.T) {
assert.NoError(t, err)
})

t.Run("GetDeploymentsNeedingReconciliation", func(t *testing.T) {
reconcile, err := dal.GetDeploymentsNeedingReconciliation(ctx)
assert.NoError(t, err)
assert.Equal(t, []Reconciliation{}, reconcile)
})

t.Run("GetRunnersForDeployment", func(t *testing.T) {
runners, err := dal.GetRunnersForDeployment(ctx, deploymentKey)
assert.NoError(t, err)
Expand Down Expand Up @@ -279,11 +257,11 @@ func TestDAL(t *testing.T) {
Deployment: model.NewDeploymentKey("test"),
})
assert.Error(t, err)
assert.IsError(t, err, libdal.ErrNotFound)
assert.IsError(t, err, libdal.ErrConstraint)
})

t.Run("GetRoutingTable", func(t *testing.T) {
_, err := dal.GetRoutingTable(ctx, []string{deployment.Module})
_, err := dal.GetRoutingTable(ctx, []string{"non-existent"})
assert.IsError(t, err, libdal.ErrNotFound)
})

Expand Down
2 changes: 0 additions & 2 deletions backend/controller/dal/internal/sql/querier.go

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

16 changes: 1 addition & 15 deletions backend/controller/dal/internal/sql/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,7 @@ FROM matches;
-- name: DeregisterRunner :one
WITH matches AS (
UPDATE runners
SET state = 'dead',
deployment_id = NULL
SET state = 'dead'
WHERE key = sqlc.arg('key')::runner_key
RETURNING 1)
SELECT COUNT(*)
Expand Down Expand Up @@ -173,19 +172,6 @@ WHERE m.name = $1
AND min_replicas > 0
LIMIT 1;

-- name: GetDeploymentsNeedingReconciliation :many
-- Get deployments that have a mismatch between the number of assigned and required replicas.
SELECT d.key AS deployment_key,
m.name AS module_name,
m.language AS language,
COUNT(r.id) AS assigned_runners_count,
d.min_replicas::BIGINT AS required_runners_count
FROM deployments d
LEFT JOIN runners r ON d.id = r.deployment_id AND r.state <> 'dead'
JOIN modules m ON d.module_id = m.id
GROUP BY d.key, d.min_replicas, m.name, m.language
HAVING COUNT(r.id) <> d.min_replicas;

-- name: GetRunnerState :one
SELECT state
FROM runners
Expand Down
54 changes: 1 addition & 53 deletions backend/controller/dal/internal/sql/queries.sql.go

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

4 changes: 2 additions & 2 deletions backend/controller/dal/testdata/go/fsm/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/dal/testdata/go/fsmnext/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/dal/testdata/go/fsmretry/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/ingress/testdata/go/httpingress/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/leases/testdata/go/leases/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/pubsub/testdata/go/publisher/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/pubsub/testdata/go/slow/go.sum

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

4 changes: 2 additions & 2 deletions backend/controller/pubsub/testdata/go/subscriber/go.sum

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

Loading

0 comments on commit 89204e6

Please sign in to comment.