Skip to content

Commit

Permalink
Gt-23 ArangoTask handler
Browse files Browse the repository at this point in the history
  • Loading branch information
jwierzbo committed Jun 22, 2022
1 parent db986e2 commit 37acf23
Show file tree
Hide file tree
Showing 20 changed files with 432 additions and 52 deletions.
14 changes: 12 additions & 2 deletions pkg/apis/deployment/v1/arango_task_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import "encoding/json"

type ArangoTaskType string

const (
// ArangoTaskPingType send ping to the db server
ArangoTaskPingType ArangoTaskType = "Ping"
)

type ArangoTaskDetails []byte

func (a ArangoTaskDetails) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -68,7 +73,12 @@ var _ json.Unmarshaler = &ArangoTaskDetails{}
var _ json.Marshaler = ArangoTaskDetails{}

type ArangoTaskSpec struct {
Type ArangoTaskType `json:"type,omitempty"`
Type ArangoTaskType `json:"type,required"`
DeploymentName string `json:"deploymentName,required"`
Details ArangoTaskDetails `json:"details,omitempty"`
}

Details ArangoTaskDetails `json:"details,omitempty"`
type ArangoTaskPing struct {
DurationSeconds int `json:"durationSeconds"`
Counts int `json:"counts"`
}
10 changes: 7 additions & 3 deletions pkg/apis/deployment/v1/arango_task_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ const (
)

type ArangoTaskStatus struct {
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
State ArangoTaskState `json:"state,omitempty"`
ActionsState []ArangoActionState `json:"actionsState,omitempty"`
}

State ArangoTaskState `json:"state,omitempty"`
Details ArangoTaskDetails `json:"details,omitempty"`
type ArangoActionState struct {
ActionId string `json:"actionId,omitempty"`
State ArangoTaskState `json:"state,omitempty"`
}
3 changes: 3 additions & 0 deletions pkg/apis/deployment/v1/deployment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type DeploymentStatus struct {
// ResourcesPlan to update this deployment. Executed before plan, after highPlan
ResourcesPlan Plan `json:"resourcesPlan,omitempty"`

// TaskPlan to update this deployment. Executed as the last one
TaskPlan Plan `json:"taskPlan,omitempty"`

// AcceptedSpec contains the last specification that was accepted by the operator.
AcceptedSpec *DeploymentSpec `json:"accepted-spec,omitempty"`

Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/deployment/v1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ const (

// Resources
ActionTypeResourceSync ActionType = "ResourceSync"

// ArangoTask actions

// ActionTypePing it a mock to check if the action flow is working
ActionTypePing ActionType = "Ping"
)

const (
Expand Down Expand Up @@ -327,6 +332,12 @@ func (a Action) SetImage(image string) Action {
return a
}

// SetTaskID sets the TaskID field to the given value and returns the modified action.
func (a Action) SetTaskID(taskID types.UID) Action {
a.TaskID = taskID
return a
}

// IsStarted returns true if the action has been started already.
func (a Action) IsStarted() bool {
return !a.StartTime.IsZero()
Expand Down
45 changes: 42 additions & 3 deletions pkg/apis/deployment/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 12 additions & 2 deletions pkg/apis/deployment/v2alpha1/arango_task_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import "encoding/json"

type ArangoTaskType string

const (
// ArangoTaskPingType send ping to the db server
ArangoTaskPingType ArangoTaskType = "Ping"
)

type ArangoTaskDetails []byte

func (a ArangoTaskDetails) MarshalJSON() ([]byte, error) {
Expand Down Expand Up @@ -68,7 +73,12 @@ var _ json.Unmarshaler = &ArangoTaskDetails{}
var _ json.Marshaler = ArangoTaskDetails{}

type ArangoTaskSpec struct {
Type ArangoTaskType `json:"type,omitempty"`
Type ArangoTaskType `json:"type,required"`
DeploymentName string `json:"deploymentName,required"`
Details ArangoTaskDetails `json:"details,omitempty"`
}

Details ArangoTaskDetails `json:"details,omitempty"`
type ArangoTaskPing struct {
DurationSeconds int `json:"durationSeconds"`
Counts int `json:"counts"`
}
10 changes: 7 additions & 3 deletions pkg/apis/deployment/v2alpha1/arango_task_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,12 @@ const (
)

type ArangoTaskStatus struct {
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`
State ArangoTaskState `json:"state,omitempty"`
ActionsState []ArangoActionState `json:"actionsState,omitempty"`
}

State ArangoTaskState `json:"state,omitempty"`
Details ArangoTaskDetails `json:"details,omitempty"`
type ArangoActionState struct {
ActionId string `json:"actionId,omitempty"`
State ArangoTaskState `json:"state,omitempty"`
}
3 changes: 3 additions & 0 deletions pkg/apis/deployment/v2alpha1/deployment_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ type DeploymentStatus struct {
// ResourcesPlan to update this deployment. Executed before plan, after highPlan
ResourcesPlan Plan `json:"resourcesPlan,omitempty"`

// TaskPlan to update this deployment. Executed as the last one
TaskPlan Plan `json:"taskPlan,omitempty"`

// AcceptedSpec contains the last specification that was accepted by the operator.
AcceptedSpec *DeploymentSpec `json:"accepted-spec,omitempty"`

Expand Down
11 changes: 11 additions & 0 deletions pkg/apis/deployment/v2alpha1/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@ const (

// Resources
ActionTypeResourceSync ActionType = "ResourceSync"

// ArangoTask actions

// ActionTypePing it a mock to check if the action flow is working
ActionTypePing ActionType = "Ping"
)

const (
Expand Down Expand Up @@ -327,6 +332,12 @@ func (a Action) SetImage(image string) Action {
return a
}

// SetTaskID sets the TaskID field to the given value and returns the modified action.
func (a Action) SetTaskID(taskID types.UID) Action {
a.TaskID = taskID
return a
}

// IsStarted returns true if the action has been started already.
func (a Action) IsStarted() bool {
return !a.StartTime.IsZero()
Expand Down
45 changes: 42 additions & 3 deletions pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 37acf23

Please sign in to comment.