Skip to content
Merged
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 @@ -9,6 +9,7 @@
- (Feature) (ACS) Add ACS handler
- (Feature) Allow to restart DBServers in cases when WriteConcern will be satisfied
- (Feature) Allow to configure action timeouts
- (Feature) (AT) Add ArangoTask API

## [1.2.8](https://github.com/arangodb/kube-arangodb/tree/1.2.8) (2022-02-24)
- Do not check License V2 on Community images
Expand Down
1 change: 1 addition & 0 deletions chart/kube-arangodb/templates/crd/cluster-role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ rules:
verbs: ["get", "list", "watch", "update", "delete"]
resourceNames:
- "arangoclustersynchronizations.database.arangodb.com"
- "arangotasks.database.arangodb.com"

{{- end }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ metadata:
release: {{ .Release.Name }}
rules:
- apiGroups: ["database.arangodb.com"]
resources: ["arangodeployments", "arangodeployments/status","arangomembers", "arangomembers/status", "arangoclustersynchronizations", "arangoclustersynchronizations/status"]
resources: ["arangodeployments", "arangodeployments/status","arangomembers", "arangomembers/status", "arangoclustersynchronizations", "arangoclustersynchronizations/status", "arangotasks", "arangotasks/status"]
verbs: ["*"]
- apiGroups: [""]
resources: ["pods", "services", "endpoints", "persistentvolumeclaims", "events", "secrets", "serviceaccounts"]
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ require (
github.com/arangodb/go-driver v1.2.1
github.com/arangodb/go-driver/v2 v2.0.0-20211021031401-d92dcd5a4c83
github.com/arangodb/go-upgrade-rules v0.0.0-20180809110947-031b4774ff21
github.com/arangodb/rebalancer v0.1.1
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/dchest/uniuri v0.0.0-20160212164326-8902c56451e9
github.com/ghodss/yaml v1.0.0
Expand Down
47 changes: 47 additions & 0 deletions pkg/apis/deployment/v1/arango_task.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1

import (
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ArangoTaskList is a list of ArangoDB tasks.
type ArangoTaskList struct {
meta.TypeMeta `json:",inline"`
// Standard list metadata
// More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata
meta.ListMeta `json:"metadata,omitempty"`
Items []ArangoTask `json:"items"`
}

// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// ArangoTask contains task definition info.
type ArangoTask struct {
meta.TypeMeta `json:",inline"`
meta.ObjectMeta `json:"metadata,omitempty"`
Spec ArangoTaskSpec `json:"spec,omitempty"`
Status ArangoTaskStatus `json:"status,omitempty"`
}
74 changes: 74 additions & 0 deletions pkg/apis/deployment/v1/arango_task_spec.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1

import "encoding/json"

type ArangoTaskType string

type ArangoTaskDetails []byte

func (a ArangoTaskDetails) MarshalJSON() ([]byte, error) {
d := make([]byte, len(a))

copy(d, a)

return d, nil
}

func (a *ArangoTaskDetails) UnmarshalJSON(bytes []byte) error {
var i interface{}

if err := json.Unmarshal(bytes, &i); err != nil {
return err
}

d := make([]byte, len(bytes))

copy(d, bytes)

*a = d

return nil
}

func (a ArangoTaskDetails) Get(i interface{}) error {
return json.Unmarshal(a, &i)
}

func (a *ArangoTaskDetails) Set(i interface{}) error {
if d, err := json.Marshal(i); err != nil {
return err
} else {
*a = d
}

return nil
}

var _ json.Unmarshaler = &ArangoTaskDetails{}
var _ json.Marshaler = ArangoTaskDetails{}

type ArangoTaskSpec struct {
Type ArangoTaskType `json:"type,omitempty"`

Details ArangoTaskDetails `json:"details,omitempty"`
}
38 changes: 38 additions & 0 deletions pkg/apis/deployment/v1/arango_task_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1

type ArangoTaskState string

const (
ArangoTaskUnknownState ArangoTaskState = ""
ArangoTaskPendingState ArangoTaskState = "Pending"
ArangoTaskRunningState ArangoTaskState = "Running"
ArangoTaskSuccessState ArangoTaskState = "Success"
ArangoTaskFailedState ArangoTaskState = "Failed"
)

type ArangoTaskStatus struct {
AcceptedSpec *ArangoTaskSpec `json:"acceptedSpec,omitempty"`

State ArangoTaskState `json:"state,omitempty"`
Details ArangoTaskDetails `json:"details,omitempty"`
}
60 changes: 60 additions & 0 deletions pkg/apis/deployment/v1/arango_task_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
//
// DISCLAIMER
//
// Copyright 2016-2022 ArangoDB GmbH, Cologne, Germany
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Copyright holder is ArangoDB GmbH, Cologne, Germany
//

package v1

import (
"encoding/json"
"reflect"
"testing"

"github.com/stretchr/testify/require"
)

func Test_ArangoTask_Details(t *testing.T) {
arangoTaskDetails(t, int(5))
arangoTaskDetails(t, "test")
arangoTaskDetails(t, []interface{}{"data", "two"})
arangoTaskDetails(t, map[string]interface{}{
"data": "exp",
})
}

func arangoTaskDetails(t *testing.T, obj interface{}) {
arangoTaskDetailsExp(t, obj, obj)
}

func arangoTaskDetailsExp(t *testing.T, obj, exp interface{}) {
t.Run(reflect.TypeOf(obj).String(), func(t *testing.T) {
var d ArangoTaskDetails

require.NoError(t, d.Set(obj))

b, err := json.Marshal(d)
require.NoError(t, err)

var n ArangoTaskDetails
require.NoError(t, json.Unmarshal(b, &n))

require.NoError(t, n.Get(&exp))

require.EqualValues(t, obj, exp)
})
}
2 changes: 2 additions & 0 deletions pkg/apis/deployment/v1/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func addKnownTypes(s *runtime.Scheme) error {
&ArangoMemberList{},
&ArangoClusterSynchronization{},
&ArangoClusterSynchronizationList{},
&ArangoTask{},
&ArangoTaskList{},
)
metav1.AddToGroupVersion(s, SchemeGroupVersion)
return nil
Expand Down
Loading