Skip to content

Commit 5a68abc

Browse files
committed
fix tests
1 parent fecd2b8 commit 5a68abc

File tree

13 files changed

+190
-16
lines changed

13 files changed

+190
-16
lines changed

agent/agent.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,7 +1042,9 @@ func (a *agent) run() (retErr error) {
10421042
})
10431043

10441044
err = connMan.wait()
1045-
a.logger.Error(context.Background(), "connection manager errored", slog.Error(err))
1045+
if err != nil {
1046+
a.logger.Error(context.Background(), "connection manager errored", slog.Error(err))
1047+
}
10461048
return err
10471049
}
10481050

@@ -1959,7 +1961,7 @@ func (a *apiConnRoutineManager) startAgentAPI(
19591961
a.eg.Go(func() error {
19601962
logger.Debug(ctx, "starting agent routine")
19611963
err := f(ctx, a.aAPI)
1962-
if xerrors.Is(err, context.Canceled) && ctx.Err() != nil {
1964+
if errors.Is(err, context.Canceled) && ctx.Err() != nil {
19631965
logger.Debug(ctx, "swallowing context canceled")
19641966
// Don't propagate context canceled errors to the error group, because we don't want the
19651967
// graceful context being canceled to halt the work of routines with
@@ -1996,7 +1998,7 @@ func (a *apiConnRoutineManager) startTailnetAPI(
19961998
a.eg.Go(func() error {
19971999
logger.Debug(ctx, "starting tailnet routine")
19982000
err := f(ctx, a.tAPI)
1999-
if xerrors.Is(err, context.Canceled) && ctx.Err() != nil {
2001+
if errors.Is(err, context.Canceled) && ctx.Err() != nil {
20002002
logger.Debug(ctx, "swallowing context canceled")
20012003
// Don't propagate context canceled errors to the error group, because we don't want the
20022004
// graceful context being canceled to halt the work of routines with

cli/testdata/coder_server_--help.golden

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -658,6 +658,12 @@ workspaces stopping during the day due to template scheduling.
658658
must be *. Only one hour and minute can be specified (ranges or comma
659659
separated values are not supported).
660660

661+
WORKSPACE PREBUILDS OPTIONS:
662+
Configure how workspace prebuilds behave.
663+
664+
--workspace-prebuilds-reconciliation-interval duration, $CODER_WORKSPACE_PREBUILDS_RECONCILIATION_INTERVAL (default: 15s)
665+
How often to reconcile workspace prebuilds state.
666+
661667
⚠️ DANGEROUS OPTIONS:
662668
--dangerous-allow-path-app-sharing bool, $CODER_DANGEROUS_ALLOW_PATH_APP_SHARING
663669
Allow workspace apps that are not served from subdomains to be shared.

cli/testdata/server-config.yaml.golden

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,3 +677,15 @@ notifications:
677677
# How often to query the database for queued notifications.
678678
# (default: 15s, type: duration)
679679
fetchInterval: 15s
680+
# Configure how workspace prebuilds behave.
681+
workspace_prebuilds:
682+
# How often to reconcile workspace prebuilds state.
683+
# (default: 15s, type: duration)
684+
reconciliation_interval: 15s
685+
# Interval to increase reconciliation backoff by when unrecoverable errors occur.
686+
# (default: 15s, type: duration)
687+
reconciliation_backoff_interval: 15s
688+
# Interval to look back to determine number of failed builds, which influences
689+
# backoff.
690+
# (default: 1h0m0s, type: duration)
691+
reconciliation_backoff_lookback_period: 1h0m0s

coderd/apidoc/docs.go

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/apidoc/swagger.json

Lines changed: 38 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/dbauthz/dbauthz_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -979,8 +979,8 @@ func (s *MethodTestSuite) TestOrganization() {
979979
})
980980

981981
check.Args(database.OrganizationMembersParams{
982-
OrganizationID: uuid.UUID{},
983-
UserID: uuid.UUID{},
982+
OrganizationID: o.ID,
983+
UserID: u.ID,
984984
}).Asserts(
985985
mem, policy.ActionRead,
986986
)

coderd/database/modelmethods.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ func ConvertUserRows(rows []GetUsersRow) []User {
423423
AvatarURL: r.AvatarURL,
424424
Deleted: r.Deleted,
425425
LastSeenAt: r.LastSeenAt,
426+
IsSystem: r.IsSystem,
426427
}
427428
}
428429

coderd/database/querier_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,6 @@ func TestUserLastSeenFilter(t *testing.T) {
13391339
LastSeenBefore: now.Add(time.Hour * -24),
13401340
})
13411341
require.NoError(t, err)
1342-
database.ConvertUserRows(beforeToday)
13431342

13441343
requireUsersMatch(t, []database.User{yesterday, lastWeek}, beforeToday, "before today")
13451344

@@ -3475,5 +3474,6 @@ func TestOrganizationDeleteTrigger(t *testing.T) {
34753474

34763475
func requireUsersMatch(t testing.TB, expected []database.User, found []database.GetUsersRow, msg string) {
34773476
t.Helper()
3478-
require.ElementsMatch(t, expected, database.ConvertUserRows(found), msg)
3477+
foundUsers := database.ConvertUserRows(found)
3478+
require.ElementsMatch(t, expected, foundUsers, msg)
34793479
}

coderd/workspaceagents.go

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,15 +1048,13 @@ func (api *API) workspaceAgentPostLogSource(rw http.ResponseWriter, r *http.Requ
10481048
httpapi.Write(ctx, rw, http.StatusCreated, apiSource)
10491049
}
10501050

1051-
// TODO @Summary Post workspace agent log source
1052-
// TODO @ID post-workspace-agent-log-source
1053-
// TODO @Security CoderSessionToken
1054-
// TODO @Accept json
1055-
// TODO @Produce json
1056-
// TODO @Tags Agents
1057-
// TODO @Param request body agentsdk.PostLogSourceRequest true "Log source request"
1058-
// TODO @Success 200 {object} codersdk.WorkspaceAgentLogSource
1059-
// TODO @Router /workspaceagents/me/log-source [post]
1051+
// @Summary Get workspace agent reinitialization
1052+
// @ID get-workspace-agent-reinitialization
1053+
// @Security CoderSessionToken
1054+
// @Produce json
1055+
// @Tags Agents
1056+
// @Success 200 {object} agentsdk.ReinitializationResponse
1057+
// @Router /workspaceagents/me/reinit [get]
10601058
func (api *API) workspaceAgentReinit(rw http.ResponseWriter, r *http.Request) {
10611059
// Allow us to interrupt watch via cancel.
10621060
ctx, cancel := context.WithCancel(r.Context())

codersdk/deployment.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,6 +2970,7 @@ Write out the current server config as YAML to stdout.`,
29702970
Default: (time.Second * 15).String(),
29712971
Group: &deploymentGroupPrebuilds,
29722972
YAML: "reconciliation_interval",
2973+
Annotations: serpent.Annotations{}.Mark(annotationFormatDuration, "true"),
29732974
},
29742975
{
29752976
Name: "Reconciliation Backoff Interval",

0 commit comments

Comments
 (0)