From 71a6a9ec9d6137a9ab0fa84fb42bbf81ef93113c Mon Sep 17 00:00:00 2001 From: David Orozco Date: Wed, 5 Jun 2024 12:54:02 -0500 Subject: [PATCH 1/2] add retry from ict --- generate/swagger.json | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/generate/swagger.json b/generate/swagger.json index b546941..064f671 100644 --- a/generate/swagger.json +++ b/generate/swagger.json @@ -491,6 +491,12 @@ }, "state": { "$ref": "#/definitions/jobs.State" + }, + "tries": { + "items": { + "$ref": "#/definitions/jobs.Try" + }, + "type": "array" } }, "type": "object" @@ -519,14 +525,17 @@ }, "message": { "type": "string" + }, + "retryAttempt": { + "type": "boolean" } }, "type": "object" }, "jobs.QueuedState": { "properties": { - "inCluster": { - "type": "boolean" + "lastMessage": { + "type": "string" }, "message": { "type": "string" @@ -582,6 +591,14 @@ }, "type": "object" }, + "jobs.Try": { + "properties": { + "lastCompleted": { + "$ref": "#/definitions/jobs.CompletedState" + } + }, + "type": "object" + }, "local": { "properties": { "from": { From b29704b26c36c0e2bb33055fe458c0f2cef63136 Mon Sep 17 00:00:00 2001 From: David Orozco Date: Wed, 5 Jun 2024 13:01:41 -0500 Subject: [PATCH 2/2] add retry from ict --- models/jobs_attempt.go | 63 +++++++++++++++++++ models/jobs_completed_state.go | 3 + models/jobs_queued_state.go | 4 +- models/jobs_try.go | 109 +++++++++++++++++++++++++++++++++ 4 files changed, 177 insertions(+), 2 deletions(-) create mode 100644 models/jobs_try.go diff --git a/models/jobs_attempt.go b/models/jobs_attempt.go index c650d48..7fcd917 100644 --- a/models/jobs_attempt.go +++ b/models/jobs_attempt.go @@ -7,6 +7,7 @@ package models import ( "context" + "strconv" "github.com/go-openapi/errors" "github.com/go-openapi/strfmt" @@ -35,6 +36,9 @@ type JobsAttempt struct { // state State *JobsState `json:"state,omitempty"` + + // tries + Tries []*JobsTry `json:"tries"` } // Validate validates this jobs attempt @@ -45,6 +49,10 @@ func (m *JobsAttempt) Validate(formats strfmt.Registry) error { res = append(res, err) } + if err := m.validateTries(formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -70,6 +78,32 @@ func (m *JobsAttempt) validateState(formats strfmt.Registry) error { return nil } +func (m *JobsAttempt) validateTries(formats strfmt.Registry) error { + if swag.IsZero(m.Tries) { // not required + return nil + } + + for i := 0; i < len(m.Tries); i++ { + if swag.IsZero(m.Tries[i]) { // not required + continue + } + + if m.Tries[i] != nil { + if err := m.Tries[i].Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tries" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tries" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // ContextValidate validate this jobs attempt based on the context it is used func (m *JobsAttempt) ContextValidate(ctx context.Context, formats strfmt.Registry) error { var res []error @@ -78,6 +112,10 @@ func (m *JobsAttempt) ContextValidate(ctx context.Context, formats strfmt.Regist res = append(res, err) } + if err := m.contextValidateTries(ctx, formats); err != nil { + res = append(res, err) + } + if len(res) > 0 { return errors.CompositeValidationError(res...) } @@ -105,6 +143,31 @@ func (m *JobsAttempt) contextValidateState(ctx context.Context, formats strfmt.R return nil } +func (m *JobsAttempt) contextValidateTries(ctx context.Context, formats strfmt.Registry) error { + + for i := 0; i < len(m.Tries); i++ { + + if m.Tries[i] != nil { + + if swag.IsZero(m.Tries[i]) { // not required + return nil + } + + if err := m.Tries[i].ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("tries" + "." + strconv.Itoa(i)) + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("tries" + "." + strconv.Itoa(i)) + } + return err + } + } + + } + + return nil +} + // MarshalBinary interface implementation func (m *JobsAttempt) MarshalBinary() ([]byte, error) { if m == nil { diff --git a/models/jobs_completed_state.go b/models/jobs_completed_state.go index 38f7ef1..9a4343d 100644 --- a/models/jobs_completed_state.go +++ b/models/jobs_completed_state.go @@ -22,6 +22,9 @@ type JobsCompletedState struct { // message Message string `json:"message,omitempty"` + + // retry attempt + RetryAttempt bool `json:"retryAttempt,omitempty"` } // Validate validates this jobs completed state diff --git a/models/jobs_queued_state.go b/models/jobs_queued_state.go index a9108f6..869fb5e 100644 --- a/models/jobs_queued_state.go +++ b/models/jobs_queued_state.go @@ -17,8 +17,8 @@ import ( // swagger:model jobs.QueuedState type JobsQueuedState struct { - // in cluster - InCluster bool `json:"inCluster,omitempty"` + // last message + LastMessage string `json:"lastMessage,omitempty"` // message Message string `json:"message,omitempty"` diff --git a/models/jobs_try.go b/models/jobs_try.go new file mode 100644 index 0000000..ae8dfe1 --- /dev/null +++ b/models/jobs_try.go @@ -0,0 +1,109 @@ +// Code generated by go-swagger; DO NOT EDIT. + +package models + +// This file was generated by the swagger tool. +// Editing this file might prove futile when you re-run the swagger generate command + +import ( + "context" + + "github.com/go-openapi/errors" + "github.com/go-openapi/strfmt" + "github.com/go-openapi/swag" +) + +// JobsTry jobs try +// +// swagger:model jobs.Try +type JobsTry struct { + + // last completed + LastCompleted *JobsCompletedState `json:"lastCompleted,omitempty"` +} + +// Validate validates this jobs try +func (m *JobsTry) Validate(formats strfmt.Registry) error { + var res []error + + if err := m.validateLastCompleted(formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *JobsTry) validateLastCompleted(formats strfmt.Registry) error { + if swag.IsZero(m.LastCompleted) { // not required + return nil + } + + if m.LastCompleted != nil { + if err := m.LastCompleted.Validate(formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("lastCompleted") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("lastCompleted") + } + return err + } + } + + return nil +} + +// ContextValidate validate this jobs try based on the context it is used +func (m *JobsTry) ContextValidate(ctx context.Context, formats strfmt.Registry) error { + var res []error + + if err := m.contextValidateLastCompleted(ctx, formats); err != nil { + res = append(res, err) + } + + if len(res) > 0 { + return errors.CompositeValidationError(res...) + } + return nil +} + +func (m *JobsTry) contextValidateLastCompleted(ctx context.Context, formats strfmt.Registry) error { + + if m.LastCompleted != nil { + + if swag.IsZero(m.LastCompleted) { // not required + return nil + } + + if err := m.LastCompleted.ContextValidate(ctx, formats); err != nil { + if ve, ok := err.(*errors.Validation); ok { + return ve.ValidateName("lastCompleted") + } else if ce, ok := err.(*errors.CompositeError); ok { + return ce.ValidateName("lastCompleted") + } + return err + } + } + + return nil +} + +// MarshalBinary interface implementation +func (m *JobsTry) MarshalBinary() ([]byte, error) { + if m == nil { + return nil, nil + } + return swag.WriteJSON(m) +} + +// UnmarshalBinary interface implementation +func (m *JobsTry) UnmarshalBinary(b []byte) error { + var res JobsTry + if err := swag.ReadJSON(b, &res); err != nil { + return err + } + *m = res + return nil +}