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

fix: allow setting workspace deadline as early as now plus 30 minutes#2328

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
johnstcn merged 3 commits intomainfromcj/2224/deadline-now-plus-30m
Jun 14, 2022

Conversation

johnstcn
Copy link
Member

This PR makes the following changes:

  • coderd:/api/v2/workspaces/:workspace/extend now accepts any time at least 30 minutes in the future
  • coder bump command also allows the above. Some small copy changes to command.

UI changes to come later.

@johnstcnjohnstcn self-assigned thisJun 14, 2022
@johnstcnjohnstcn requested a review froma teamJune 14, 2022 19:59
Comment on lines 886 to 897
now := time.Now()
if new.Before(now) {
return xerrors.New("new deadline must be in the future")
}

delta := new.Sub(old)
if delta < time.Minute {
return xerrors.New("minimum extension is one minute")
}

if delta > 24*time.Hour {
return xerrors.New("maximum extension is 24 hours")
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

review: Dropping these validations for the moment till we have more information from#2318

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Actually, there's one very important validation involving templates that I may have overlooked! Adding this in now.

Comment on lines +1020 to +1025
// And with a deadline greater than the template max_ttl should also fail
deadlineExceedsMaxTTL := time.Now().Add(time.Duration(template.MaxTTLMillis) * time.Millisecond).Add(time.Minute)
err = client.PutExtendWorkspace(ctx, workspace.ID, codersdk.PutExtendWorkspaceRequest{
Deadline: deadlineExceedsMaxTTL,
})
require.ErrorContains(t, err, "new deadline is greater than template allows", "setting a deadline greater than that allowed by the template should fail")
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

review: I forgot to add this in earlier. We don't folks folks sneaking around template-level restrictions this way.

return xerrors.New("minimum extension is one minute")
// No idea how this could happen.
ifnewDeadline.Before(startedAt) {
return xerrors.Errorf("new deadline must be before workspace start time")
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I figure if we get here, time is broken.

Comment on lines +611 to +615
if build.Deadline.IsZero() {
code = http.StatusConflict
resp.Message = "Workspace shutdown is manual."
return xerrors.Errorf("workspace shutdown is manual")
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

review: I'm not allowing this yet as if someone does, then there's currently no way to un-set this.

Copy link
Member

@deansheatherdeansheather left a comment

Choose a reason for hiding this comment

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

LGTM except for "bump" doesn't make sense anymore

@@ -62,7 +72,6 @@ func bump() *cobra.Command {
newDeadline.Format(timeFormat),
newDeadline.Format(dateFormat),
)

return nil
},
}
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Also: this won't be calledcoder bump any more.

@johnstcnjohnstcn merged commit02ad60f intomainJun 14, 2022
@johnstcnjohnstcn deleted the cj/2224/deadline-now-plus-30m branchJune 14, 2022 21:39
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@deansheatherdeansheatherdeansheather approved these changes

Assignees

@johnstcnjohnstcn

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

2 participants
@johnstcn@deansheather

[8]ページ先頭

©2009-2025 Movatter.jp