- Notifications
You must be signed in to change notification settings - Fork915
chore: cherry-pick commits for 2.18.1#15885
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
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
9 commits Select commitHold shift + click to select a range
1375aba
fix(provisioner/terraform/tfparse): evaluate coder_parameter defaults…
johnstcn129cc75
fix: docs reference in create headless user flow (#15826)
ericpaulsen0a71d2d
fix(coderd): extract provisionerdserver.StaleInterval to 90 seconds (…
johnstcn6da1760
fix(cli): handle version mismatch re MatchedProvisioners response (#1…
johnstcn4578e6b
feat(coderd): add matched provisioner daemons information to more pla…
johnstcnac75ebc
feat(site): add a provisioner warning to workspace builds (#15686)
SasSwart9a8d2f1
fix(site): remove a misplaced warning banner in the frontend (#15837)
SasSwartae38ef5
fix(site): only show provisioner warnings for pending workspaces (#15…
SasSwart4c452af
chore(go.mod): update x/crypto to 0.31.0 (#15869) (#15870)
johnstcnFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
53 changes: 53 additions & 0 deletionscli/cliutil/provisionerwarn.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package cliutil | ||
import ( | ||
"encoding/json" | ||
"fmt" | ||
"io" | ||
"strings" | ||
"github.com/coder/coder/v2/cli/cliui" | ||
"github.com/coder/coder/v2/codersdk" | ||
) | ||
var ( | ||
warnNoMatchedProvisioners = `Your build has been enqueued, but there are no provisioners that accept the required tags. Once a compatible provisioner becomes available, your build will continue. Please contact your administrator. | ||
Details: | ||
Provisioner job ID : %s | ||
Requested tags : %s | ||
` | ||
warnNoAvailableProvisioners = `Provisioners that accept the required tags have not responded for longer than expected. This may delay your build. Please contact your administrator if your build does not complete. | ||
Details: | ||
Provisioner job ID : %s | ||
Requested tags : %s | ||
Most recently seen : %s | ||
` | ||
) | ||
// WarnMatchedProvisioners warns the user if there are no provisioners that | ||
// match the requested tags for a given provisioner job. | ||
// If the job is not pending, it is ignored. | ||
func WarnMatchedProvisioners(w io.Writer, mp *codersdk.MatchedProvisioners, job codersdk.ProvisionerJob) { | ||
if mp == nil { | ||
// Nothing in the response, nothing to do here! | ||
return | ||
} | ||
if job.Status != codersdk.ProvisionerJobPending { | ||
// Only warn if the job is pending. | ||
return | ||
} | ||
var tagsJSON strings.Builder | ||
if err := json.NewEncoder(&tagsJSON).Encode(job.Tags); err != nil { | ||
// Fall back to the less-pretty string representation. | ||
tagsJSON.Reset() | ||
_, _ = tagsJSON.WriteString(fmt.Sprintf("%v", job.Tags)) | ||
} | ||
if mp.Count == 0 { | ||
cliui.Warnf(w, warnNoMatchedProvisioners, job.ID, tagsJSON.String()) | ||
return | ||
} | ||
if mp.Available == 0 { | ||
cliui.Warnf(w, warnNoAvailableProvisioners, job.ID, strings.TrimSpace(tagsJSON.String()), mp.MostRecentlySeen.Time) | ||
return | ||
} | ||
} |
74 changes: 74 additions & 0 deletionscli/cliutil/provisionerwarn_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
package cliutil_test | ||
import ( | ||
"strings" | ||
"testing" | ||
"github.com/stretchr/testify/require" | ||
"github.com/coder/coder/v2/cli/cliutil" | ||
"github.com/coder/coder/v2/codersdk" | ||
) | ||
func TestWarnMatchedProvisioners(t *testing.T) { | ||
t.Parallel() | ||
for _, tt := range []struct { | ||
name string | ||
mp *codersdk.MatchedProvisioners | ||
job codersdk.ProvisionerJob | ||
expect string | ||
}{ | ||
{ | ||
name: "no_match", | ||
mp: &codersdk.MatchedProvisioners{ | ||
Count: 0, | ||
Available: 0, | ||
}, | ||
job: codersdk.ProvisionerJob{ | ||
Status: codersdk.ProvisionerJobPending, | ||
}, | ||
expect: `there are no provisioners that accept the required tags`, | ||
}, | ||
{ | ||
name: "no_available", | ||
mp: &codersdk.MatchedProvisioners{ | ||
Count: 1, | ||
Available: 0, | ||
}, | ||
job: codersdk.ProvisionerJob{ | ||
Status: codersdk.ProvisionerJobPending, | ||
}, | ||
expect: `Provisioners that accept the required tags have not responded for longer than expected`, | ||
}, | ||
{ | ||
name: "match", | ||
mp: &codersdk.MatchedProvisioners{ | ||
Count: 1, | ||
Available: 1, | ||
}, | ||
job: codersdk.ProvisionerJob{ | ||
Status: codersdk.ProvisionerJobPending, | ||
}, | ||
}, | ||
{ | ||
name: "not_pending", | ||
mp: &codersdk.MatchedProvisioners{}, | ||
job: codersdk.ProvisionerJob{ | ||
Status: codersdk.ProvisionerJobRunning, | ||
}, | ||
}, | ||
} { | ||
tt := tt | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
var w strings.Builder | ||
cliutil.WarnMatchedProvisioners(&w, tt.mp, tt.job) | ||
if tt.expect != "" { | ||
require.Contains(t, w.String(), tt.expect) | ||
} else { | ||
require.Empty(t, w.String()) | ||
} | ||
}) | ||
} | ||
} |
11 changes: 10 additions & 1 deletioncli/create.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletionscli/delete.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletionscli/delete_test.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletionscli/start.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletionscli/stop.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
27 changes: 2 additions & 25 deletionscli/templatepush.go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.