Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gt-23 ArangoTask handler #1029

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- (Bugfix) Ensure Wait actions to be present after AddMember
- (Documentation) Refactor metrics (Part 1)
- (Bugfix) Extend Agency HealthCheck for replace
- (Feature) ArangoTask handler (Ping type)

## [1.2.13](https://github.com/arangodb/kube-arangodb/tree/1.2.13) (2022-06-07)
- (Bugfix) Fix arangosync members state inspection
Expand Down
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"`
DeploymentName string `json:"deploymentName"`
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 is 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"`
DeploymentName string `json:"deploymentName"`
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 is 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