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: add provisioner daemon and jobs endpoints and commands#15940

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

Closed
mafredri wants to merge21 commits intomainfrommafredri/feat-provisioner-and-jobs-list

Conversation

mafredri
Copy link
Member

Fixes#15190
Fixes#15191
Updates#15084

@mafredrimafredri marked this pull request as draftDecember 19, 2024 18:21
@mafredrimafredriforce-pushed themafredri/feat-provisioner-and-jobs-list branch fromb776b1b toaf6789aCompareDecember 20, 2024 15:05
Comment on lines 2 to 3
==========[version job ID]========== ====[timestamp]===== succeeded map[owner: scope:organization] template_version_import Coder
======[workspace build job ID]====== ====[timestamp]===== succeeded map[owner: scope:organization] workspace_build Coder
Copy link
Member

@johnstcnjohnstcnDec 20, 2024
edited
Loading

Choose a reason for hiding this comment

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

It would be nice if tags were listed ink1=v1,k2=v2 format.
We can also probably "lie" a bit about the case{"owner": "", "scope": "organization"} and just pretend it's empty.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good suggestions, and I agree we should hide default owner/scope. We should probably update table formatter to change how maps are output.

Copy link
Member

Choose a reason for hiding this comment

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

I would move "Queue" column to be the first one.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I would move "Queue" column to be the first one.

@mtojek I'm going to create a follow-up issue for this as ordering columns is not supported in our table formatter currently. I would like to avoid us having to craft custom structs every time we want to re-order columns.

Comment on lines 121 to 126
funcconvertSlice[D,S~string](dstType []D,src []S) []D {
for_,item:=rangesrc {
dstType=append(dstType,D(item))
}
returndstType
}
Copy link
Member

Choose a reason for hiding this comment

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

Maybe throw this intoslice asToEnum 🤷‍♂️

Similar to ToStrings

// ToStrings works for any type where the base type is a string.
funcToStrings[T~string](a []T) []string {
tmp:=make([]string,0,len(a))
for_,v:=rangea {
tmp=append(tmp,string(v))
}
returntmp
}

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Can do 👍🏻

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Btw, any good reason these utils undercoderd? I wouldn't move it in this PR but could make it more accessible.

Copy link
Member

Choose a reason for hiding this comment

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

no good reason at all. I think it just grew over time

Versionstring`json:"version" table:"version"`
APIVersionstring`json:"api_version" table:"api version"`
Provisioners []ProvisionerType`json:"provisioners" table:"-"`
Tagsmap[string]string`json:"tags" table:"tags"`
Copy link
Member

Choose a reason for hiding this comment

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

I do not love this output:map[owner: scope:organization], but I'm ok with it.

We could have the table formatter know how to handle some basic types likemap[string]string. Just leave it for this PR though.

mafredri reacted with thumbs up emoji
Copy link
Member

Choose a reason for hiding this comment

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

I had a similar thought, something human-readable and copy/paste friendly:

owner = (none)scope = organization

Comment on lines +8 to +12
cmd:=r.RootCmd.Provisioners()
cmd.AddSubcommands(
r.provisionerDaemonStart(),
r.provisionerKeys(),
)
Copy link
Member

Choose a reason for hiding this comment

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

This is a crafty

mafredri reacted with heart emoji
),
Handler:func(inv*serpent.Invocation)error {
varclosersclosers
deferclosers.Close()
Copy link
Member

@EmyrkEmyrkDec 20, 2024
edited
Loading

Choose a reason for hiding this comment

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

Lol,closers was a nice thought, but never closing the closers is quite the funny bug.

mafredri reacted with laugh emoji
Copy link
Member

Choose a reason for hiding this comment

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

varlosersclosersdeferlosers.Close()

:)

Comment on lines +1010 to +1012
r.Route("/provisionerdaemons",func(r chi.Router) {
r.Get("/",api.provisionerDaemons)
})
Copy link
Member

Choose a reason for hiding this comment

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

If we add filtering bykey, can we merge this with/organizations/{organization}/provisionerkeys/daemons? Or at least merge the code they both invoke? If possible, just to make sure we are consistent.

func (api*API)provisionerKeyDaemons(rw http.ResponseWriter,r*http.Request) {

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

That's a good idea, I wasn't sure how much to move to AGPL vs enterprise but none of this code is critical to keep in enterprise 👍🏻

Copy link
Member

Choose a reason for hiding this comment

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

Generally I thinkGET endpoints can be made AGPL, andPOST/PATCH should be enterprise.

johnstcn reacted with thumbs up emoji
ifval!=nil {
v=val.Format(time.RFC3339)
}
case codersdk.NullTime:
Copy link
Member

Choose a reason for hiding this comment

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

nit: shouldn't we extract it to a separate PR?

johnstcn reacted with thumbs up emoji

jobs,err:=client.OrganizationProvisionerJobs(ctx,org.ID,&codersdk.OrganizationProvisionerJobsOptions{
Status: slice.ToStringEnums[codersdk.ProvisionerJobStatus](status),
Limit:int(limit),
Copy link
Member

Choose a reason for hiding this comment

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

nit: paging?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I want to keep it simple for now, I realized we don't have a precedent on the CLI for paging so I didn't want to introduce it here. Granted--limit is also new, so I could remove that too but I was worried about how many entries there will be.

The original issue#15084 mentioned we should have "created at" (or rather "created after"), and I added that initially, but then I realized we don't have a precedent for filtering on time on the CLI either. (There's even a lack of serpent support there.) For this reason both pagination and created at filter have been omitted and should IMO be part of a grander plan for how to support these in a unified way on the CLI.

johnstcn and mtojek reacted with thumbs up emoji
Comment on lines 2 to 3
==========[version job ID]========== ====[timestamp]===== succeeded map[owner: scope:organization] template_version_import Coder
======[workspace build job ID]====== ====[timestamp]===== succeeded map[owner: scope:organization] workspace_build Coder
Copy link
Member

Choose a reason for hiding this comment

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

I would move "Queue" column to be the first one.

Comment on lines 467 to 469
iferr!=nil {
return"",nil,xerrors.Errorf("open container: %w",err)
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: double-checking, is it intentional?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yes, in some cases this will cause a nil pointer dereference otherwise.

// @Param tags query object false "Provisioner tags to filter by (JSON of the form {'tag1':'value1','tag2':'value2'})"
// @Success 200 {array} codersdk.ProvisionerDaemonWithStatus
// @Router /organizations/{organization}/provisionerdaemons [get]
func (api*API)provisionerDaemons(rw http.ResponseWriter,r*http.Request) {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason why endpoint changes and CLI go together? Alternatively, you could split the PR in half, and keep all golden files aside. Large PRs are typically a problem when somebody needs to revert them.

Copy link
MemberAuthor

@mafredrimafredriDec 23, 2024
edited
Loading

Choose a reason for hiding this comment

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

Yes and no, for development I'm working on them in tandem, CLI requirements have and keep resulted in API changes, etc. Stacking could be a better approach though.

I don't think the golden files should be separate as that would make the feature harder to revert, but API and CLI can definitely be.

Copy link
Member

Choose a reason for hiding this comment

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

It should be possible to have the DB stuff in its own PR and the CLI stuff then in a separate PR based off that. No need to have a really deep stack here IMO.

I'm fine with reviewing initially here "all-in-one".

Copy link
Member

Choose a reason for hiding this comment

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

👍

Versionstring`json:"version" table:"version"`
APIVersionstring`json:"api_version" table:"api version"`
Provisioners []ProvisionerType`json:"provisioners" table:"-"`
Tagsmap[string]string`json:"tags" table:"tags"`
Copy link
Member

Choose a reason for hiding this comment

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

I had a similar thought, something human-readable and copy/paste friendly:

owner = (none)scope = organization

Comment on lines 1149 to 1159
"path":"reference/cli/provisioner_keys.md"
"path":"reference/cli/provisioners_keys.md"
Copy link
Member

Choose a reason for hiding this comment

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

nit: renaming could go in a separate PR, right?

mafredri reacted with thumbs up emoji
),
Handler:func(inv*serpent.Invocation)error {
varclosersclosers
deferclosers.Close()
Copy link
Member

Choose a reason for hiding this comment

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

varlosersclosersdeferlosers.Close()

:)

// We may in future decide to scope provisioner daemons to organizations, so we'll keep the API
// route as is.
r.Route("/organizations/{organization}/provisionerdaemons",func(r chi.Router) {
r.Route("/organizations/{organization}/provisionerdaemons/serve",func(r chi.Router) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: does this change give any special benefits? Most likely I'm missing something...

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We removed the other endpoints from here that were under/organizations/{organization}/provisionerdaemons and only/organizations/{organization}/provisionerdaemons/serve remains. There's no reason to keep the broader one and IIRC it also interfered with the AGPL endpoint.

mtojek reacted with thumbs up emoji
Comment on lines +48 to +54
iferr!=nil {
httpapi.Write(ctx,rw,http.StatusInternalServerError, codersdk.Response{
Message:"Internal error fetching provisioner daemons.",
Detail:err.Error(),
})
return
}
Copy link
Member

Choose a reason for hiding this comment

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

nit: doessql.ErrNoRows need to be handled separately?

@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelDec 31, 2024
@mafredrimafredriforce-pushed themafredri/feat-provisioner-and-jobs-list branch 5 times, most recently from5b54ed6 to720b715CompareDecember 31, 2024 13:11
@github-actionsgithub-actionsbot removed the staleThis issue is like stale bread. labelJan 1, 2025
@mafredrimafredriforce-pushed themafredri/feat-provisioner-and-jobs-list branch from720b715 to24d49daCompareJanuary 2, 2025 10:27
mafredri added a commit that referenced this pull requestJan 3, 2025
mafredri added a commit that referenced this pull requestJan 3, 2025
mafredri added a commit that referenced this pull requestJan 3, 2025
mafredri added a commit that referenced this pull requestJan 3, 2025
mafredri added a commit that referenced this pull requestJan 3, 2025
mafredri added a commit that referenced this pull requestJan 3, 2025
mafredri added a commit that referenced this pull requestJan 3, 2025
@github-actionsgithub-actionsbot added the staleThis issue is like stale bread. labelJan 10, 2025
@johnstcnjohnstcn reopened thisJan 13, 2025
@johnstcnjohnstcn removed the staleThis issue is like stale bread. labelJan 13, 2025
@mafredri
Copy link
MemberAuthor

mafredri commentedJan 13, 2025
edited
Loading

Closing this as it's split up into#16028,#16029 and#16030 (and a few other small PRs that fixed unrelated things).

@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJan 13, 2025
@mafredrimafredri deleted the mafredri/feat-provisioner-and-jobs-list branchJanuary 13, 2025 10:05
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.

Reviewers

@johnstcnjohnstcnjohnstcn left review comments

@EmyrkEmyrkEmyrk left review comments

@mtojekmtojekmtojek left review comments

Assignees

@mafredrimafredri

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

add CLI command to list provisioner jobs Add an API endpoint that lists all provisioner jobs.

4 participants

@mafredri@johnstcn@Emyrk@mtojek

[8]ページ先頭

©2009-2025 Movatter.jp