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: 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

Merged
mtojek merged 9 commits intocoder:mainfrommtojek:6100-error-codes
Mar 8, 2023
Merged

Conversation

mtojek
Copy link
Member

Related:#6100

This PR extends a provisioner job runner to return error codes related to specificc failures. So far we need two different codes:
MISSING_TEMPLATE_PARAMETER andREQUIRED_TEMPLATE_VARIABLES.

@mtojekmtojek self-assigned thisMar 8, 2023
@mtojekmtojek marked this pull request as ready for reviewMarch 8, 2023 13:31
@mtojekmtojek requested a review fromkylecarbsMarch 8, 2023 13:32
Copy link
Collaborator

@BrunoQuaresmaBrunoQuaresma left a comment
edited
Loading

Choose a reason for hiding this comment

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

That is nice! Would be great to have the errors being exported on typesGenerated as:

exportconstErrors={REQUIRED_TEMPLATE_VARIABLES:"REQUIRED_TEMPLATE_VARIABLES",  ...}

So we could easily find out what are the available error codes and use as:

someError === Errors.REQUIRED_TEMPLATE_VARIABLES

mafredri reacted with thumbs up emoji
Copy link
Member

@mafredrimafredri left a comment

Choose a reason for hiding this comment

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

A few comments but looks good otherwise 👍🏻

@@ -0,0 +1 @@
ALTER TABLE provisioner_jobs ADD COLUMN error_code text DEFAULT NULL;
Copy link
Member

Choose a reason for hiding this comment

The 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?

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 stick to theerror_code at the moment. Most (all?) flows fail fast (return failJob(...)), so there is no simple way to aggregate multiple errors.
Moreover, we have singleerror property. In this case, we would neederrors [] as well.

mafredri reacted with thumbs up emoji
code = MissingParameterErrorCode
} else if strings.Contains(message, requiredTemplateVariablesErrorText) {
code = RequiredTemplateVariablesErrorCode
}
Copy link
Member

Choose a reason for hiding this comment

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

This format seems like it'd be easy to miss, e.g. when adding new error messages/codes.

How about storing them in a map and iterating over it here?

varerrorCodes=map[string]string{MissingParameterErrorCode:missingParameterErrorText,// ...}forc,m:=rangeerrorCodes {// ...}

Ultimately though, this logic is a bit hidden behind a "print function", it might be a good idea to refactor so that it can accept anerr error which could be a predefined&jobError{m: "missing x", c: "MISSING_X}.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Good idea with the map, added.

Ultimately though, this logic is a bit hidden behind a "print function", it might be a good idea to refactor so that it can accept an err error which could be a predefined &jobError{m: "missing x", c: "MISSING_X}.

This is risky, as it would require refactoring of interfaces, and I'm sure that I don't want to deal with it now...

@mtojek
Copy link
MemberAuthor

@BrunoQuaresma I added these errors totypesGenerated, but wasn't able to create a map, only an array. Could you please link an enum where it works as intended?

var _ error = new(ProvisionerJobError)

func (err *ProvisionerJobError) Error() string {
return err.Message
Copy link
Member

Choose a reason for hiding this comment

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

Just an idea, could be useful sometime.

Suggested change
returnerr.Message
returnfmt.Sprintf("%s (%s)",err.Message,err.Code)

Copy link
MemberAuthor

Choose a reason for hiding this comment

The 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 :)

@@ -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"`
Copy link
Member

Choose a reason for hiding this comment

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

Question: Is theenums: still required for code gen even after the update ofswaggo? In my experience it has been able to auto-detect but it might be very specific.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I checked it now - unfortunately, swaggo removed enum parts from the docs andswagger.json, so I will leave it as is.

@mtojekmtojek merged commit3b87316 intocoder:mainMar 8, 2023
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMar 8, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@mafredrimafredrimafredri approved these changes

@BrunoQuaresmaBrunoQuaresmaBrunoQuaresma approved these changes

@kylecarbskylecarbsAwaiting requested review from kylecarbs

Assignees

@mtojekmtojek

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@mtojek@mafredri@BrunoQuaresma

[8]ページ先頭

©2009-2025 Movatter.jp