Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: allow disabling autostart and custom autostop for template#6933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
deansheather merged 13 commits intomainfromdean/disable-template-autostart-autostop
Apr 4, 2023

Conversation

deansheather
Copy link
Member

@deansheatherdeansheather commentedMar 31, 2023
edited
Loading

Adds template controls for disabling autostart and for disabling user-customizable autostop for all workspaces on the template. Autostart preferences apply instantly, but autostop preferences will apply after workspaces are rebuilt.

TODO:

  • Frontend
  • Update template schedule endpoint tests

Relates to#6047
Relates to#6497

@deansheatherdeansheather self-assigned thisMar 31, 2023
Copy link
Member

@mtojekmtojek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I can only imagine how much time you spent on wiring it all together :)
Anyway, I went through the source, but due to the massive size of the PR, please keep in mind that for sure I missed something.

General comments:

  1. Autostart vs "auto start", it seems that we're using the first one.
  2. I checked the main flow: set options via template settings, and make sure that the user can autostart or autostop the workspace. It seems 👍 to me.
  3. Maybe try to split it into smaller chunks next time :)

Comment on lines 2 to 3
ADD COLUMN"allow_user_auto_start"boolean DEFAULT trueNOT NULL,
ADD COLUMN"allow_user_auto_stop"boolean DEFAULT trueNOT NULL;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You won't like this comment... In the codebase, we're using "autostart" and "autostop".

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nothing a sed can't fix :^)

updated_at= $2,
default_ttl= $3,
max_ttl= $4
allow_user_auto_start= $3,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Oh, is it safe and backward-compatible to change the order of items here?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

It shouldn't matter since the generated Golang query uses named parameters in a struct, not ordered parameters in a function.

Telemetry:api.Telemetry,
Auditor:&api.AGPL.Auditor,
TemplateScheduleStore:&api.AGPL.TemplateScheduleStore,
TemplateScheduleStore:api.AGPL.TemplateScheduleStore,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: is it intentional change?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yes,provisionerdserver was using a*atomic.Pointer[T] so we had to use& before sincecoderd was only usingatomic.Pointer[T].coderd now uses*atomic.Pointer[T] so we just copy the pointer here.

returnxerrors.Errorf("notify systemd: %w",err)
}

autobuildPoller:=time.NewTicker(cfg.AutobuildPollInterval.Value())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

nit: why did you remove this part?

Maybe I have to go through the entire review to find the answer...

Copy link
Member

@johnstcnjohnstcnApr 4, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

⚠️ Might be more than a nit? I don't see any other calls toexecutor.New in the review.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Yeah this was a mistake, good catch to both of you. I removed this code and moved it somewhere else, and decided I wanted to move it back but forgot to put it back I guess.

johnstcn reacted with thumbs up emoji
e.log.Error(e.ctx,"get workspaces for autostart or autostop",slog.Error(err))
returnstats
}
workspaces:=database.ConvertWorkspaceRows(workspaceRows)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍

Copy link
Member

@johnstcnjohnstcn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Is the deletion incli/server.go on line 1020 expected?

Comment on lines 201 to 214
funcisEligibleForAutoStartStop(ws database.Workspace,priorHistory database.WorkspaceBuild,templateSchedule schedule.TemplateScheduleOptions)bool {
ifws.Deleted {
returnfalse
}
iftemplateSchedule.UserAutoStartEnabled&&ws.AutostartSchedule.Valid&&ws.AutostartSchedule.String!="" {
returntrue
}
// Don't check the template schedule to see whether it allows autostop, this
// is done during the build when determining the deadline.
ifpriorHistory.Transition==database.WorkspaceTransitionStart&&!priorHistory.Deadline.IsZero() {
returntrue
}

returnfalse
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍

Comment on lines 615 to 616
allowAutoStart atomic.Bool
allowAutoStop atomic.Bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

When I initially looked at this, I was wondering whether it would make more sense to instead use achan bool instead to assert the values passed tosetFn. But this does seem to be simpler in some ways and, crucially, will failquickly if it fails. Not so for a channel... so 👍

returnxerrors.Errorf("notify systemd: %w",err)
}

autobuildPoller:=time.NewTicker(cfg.AutobuildPollInterval.Value())
Copy link
Member

@johnstcnjohnstcnApr 4, 2023
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

⚠️ Might be more than a nit? I don't see any other calls toexecutor.New in the review.

@deansheather
Copy link
MemberAuthor

I'll make a ticket for doing frontend in a follow-up PR.

@deansheather
Copy link
MemberAuthor

Actually we can just reuse the other tickets.

@deansheatherdeansheatherenabled auto-merge (squash)April 4, 2023 12:41
@deansheatherdeansheather merged commite33941b intomainApr 4, 2023
@deansheatherdeansheather deleted the dean/disable-template-autostart-autostop branchApril 4, 2023 12:48
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsApr 4, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@mtojekmtojekmtojek approved these changes

Assignees

@deansheatherdeansheather

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@deansheather@johnstcn@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp