- Notifications
You must be signed in to change notification settings - Fork1.1k
feat: propagate job error codes#6507
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
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
b77747bbfa9140e41136e55f46b777d7d7d43e6b7aee381ab20fe286d782120File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -41,6 +41,17 @@ type ProvisionerJobOptions struct { | ||||||
| Silent bool | ||||||
| } | ||||||
| type ProvisionerJobError struct { | ||||||
| Message string | ||||||
| Code codersdk.JobErrorCode | ||||||
| } | ||||||
mtojek marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||||||
| var _ error = new(ProvisionerJobError) | ||||||
| func (err *ProvisionerJobError) Error() string { | ||||||
| return err.Message | ||||||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Just an idea, could be useful sometime. Suggested change
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Thanks for suggestion, but this message will be shown in CLI or site, let's not scare the customer :) | ||||||
| } | ||||||
| // ProvisionerJob renders a provisioner job with interactive cancellation. | ||||||
| func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOptions) error { | ||||||
| if opts.FetchInterval == 0 { | ||||||
| @@ -181,7 +192,10 @@ func ProvisionerJob(ctx context.Context, writer io.Writer, opts ProvisionerJobOp | ||||||
| return nil | ||||||
| case codersdk.ProvisionerJobFailed: | ||||||
| } | ||||||
| err = &ProvisionerJobError{ | ||||||
| Message: job.Error, | ||||||
| Code: job.ErrorCode, | ||||||
| } | ||||||
| jobMutex.Unlock() | ||||||
| flushLogBuffer() | ||||||
| return err | ||||||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTER TABLE provisioner_jobs DROP COLUMN error_code; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| ALTERTABLE provisioner_jobs ADD COLUMN error_codetext DEFAULTNULL; | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Could we potentially run into multiple errors? Would it make sense to store an array here? MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I would stick to the | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -91,6 +91,7 @@ UPDATE | ||
| SET | ||
| updated_at = $2, | ||
| completed_at = $3, | ||
| error = $4, | ||
| error_code = $5 | ||
| WHERE | ||
| id = $1; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -67,6 +67,14 @@ const ( | ||
| ProvisionerJobFailed ProvisionerJobStatus = "failed" | ||
| ) | ||
| // JobErrorCode defines the error code returned by job runner. | ||
| type JobErrorCode string | ||
| const ( | ||
| MissingTemplateParameter JobErrorCode = "MISSING_TEMPLATE_PARAMETER" | ||
| RequiredTemplateVariables JobErrorCode = "REQUIRED_TEMPLATE_VARIABLES" | ||
| ) | ||
| // ProvisionerJob describes the job executed by the provisioning daemon. | ||
| type ProvisionerJob struct { | ||
| ID uuid.UUID `json:"id" format:"uuid"` | ||
| @@ -75,6 +83,7 @@ type ProvisionerJob struct { | ||
| CompletedAt *time.Time `json:"completed_at,omitempty" format:"date-time"` | ||
| CanceledAt *time.Time `json:"canceled_at,omitempty" format:"date-time"` | ||
| Error string `json:"error,omitempty"` | ||
| ErrorCode JobErrorCode `json:"error_code,omitempty" enums:"MISSING_TEMPLATE_PARAMETER,REQUIRED_TEMPLATE_VARIABLES"` | ||
Member There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Question: Is the MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. I checked it now - unfortunately, swaggo removed enum parts from the docs and | ||
| Status ProvisionerJobStatus `json:"status" enums:"pending,running,succeeded,canceling,canceled,failed"` | ||
| WorkerID *uuid.UUID `json:"worker_id,omitempty" format:"uuid"` | ||
| FileID uuid.UUID `json:"file_id" format:"uuid"` | ||
Uh oh!
There was an error while loading.Please reload this page.