From 28ca0b08aa35d05433e7f0ade2dfb2d9f54b9907 Mon Sep 17 00:00:00 2001
From: ajanikow <12255597+ajanikow@users.noreply.github.com>
Date: Thu, 23 Nov 2023 20:33:43 +0000
Subject: [PATCH 1/2] [Feature] [ML] Introduce basic Conditions to types
---
CHANGELOG.md | 1 +
pkg/apis/ml/v1alpha1/batchjob.go | 8 ++++++
pkg/apis/ml/v1alpha1/batchjob_spec.go | 6 +++++
pkg/apis/ml/v1alpha1/batchjob_status.go | 5 ++++
pkg/apis/ml/v1alpha1/conditions.go | 27 +++++++++++++++++++
pkg/apis/ml/v1alpha1/cronjob.go | 8 ++++++
pkg/apis/ml/v1alpha1/cronjob_spec.go | 6 +++++
pkg/apis/ml/v1alpha1/cronjob_status.go | 5 ++++
pkg/apis/ml/v1alpha1/extension_spec.go | 6 +++++
pkg/apis/ml/v1alpha1/storage.go | 8 ++++++
pkg/apis/ml/v1alpha1/storage_status.go | 5 ++++
pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go | 27 ++++++++++++++++---
pkg/operatorV2/update_wraps.go | 12 +++++++++
13 files changed, 121 insertions(+), 3 deletions(-)
create mode 100644 pkg/apis/ml/v1alpha1/conditions.go
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a53b81c3e..69720e41d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -19,6 +19,7 @@
- (Maintenance) yamlfmt as CI Step
- (Maintenance) Expose Context in OperatorV2 Item Handler
- (Feature) Improve K8S Mock for UT
+- (Feature) (ML) Introduce basic Conditions
## [1.2.35](https://github.com/arangodb/kube-arangodb/tree/1.2.35) (2023-11-06)
- (Maintenance) Update go-driver to v1.6.0, update IsNotFound() checks
diff --git a/pkg/apis/ml/v1alpha1/batchjob.go b/pkg/apis/ml/v1alpha1/batchjob.go
index aa00e8f37..01d7cfaf5 100644
--- a/pkg/apis/ml/v1alpha1/batchjob.go
+++ b/pkg/apis/ml/v1alpha1/batchjob.go
@@ -45,3 +45,11 @@ type ArangoMLBatchJob struct {
Spec ArangoMLBatchJobSpec `json:"spec"`
Status ArangoMLBatchJobStatus `json:"status"`
}
+
+func (a *ArangoMLBatchJob) GetStatus() ArangoMLBatchJobStatus {
+ return a.Status
+}
+
+func (a *ArangoMLBatchJob) SetStatus(status ArangoMLBatchJobStatus) {
+ a.Status = status
+}
diff --git a/pkg/apis/ml/v1alpha1/batchjob_spec.go b/pkg/apis/ml/v1alpha1/batchjob_spec.go
index 51378e766..119c386bf 100644
--- a/pkg/apis/ml/v1alpha1/batchjob_spec.go
+++ b/pkg/apis/ml/v1alpha1/batchjob_spec.go
@@ -20,5 +20,11 @@
package v1alpha1
+import "github.com/arangodb/kube-arangodb/pkg/apis/shared"
+
type ArangoMLBatchJobSpec struct {
}
+
+func (a *ArangoMLBatchJobSpec) Validate() error {
+ return shared.WithErrors(shared.PrefixResourceErrors("spec"))
+}
diff --git a/pkg/apis/ml/v1alpha1/batchjob_status.go b/pkg/apis/ml/v1alpha1/batchjob_status.go
index 0ff33a6e1..d80b42bea 100644
--- a/pkg/apis/ml/v1alpha1/batchjob_status.go
+++ b/pkg/apis/ml/v1alpha1/batchjob_status.go
@@ -20,5 +20,10 @@
package v1alpha1
+import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
+
type ArangoMLBatchJobStatus struct {
+ // Conditions specific to the entire batch job
+ // +doc/type: api.Conditions
+ Conditions api.ConditionList `json:"conditions,omitempty"`
}
diff --git a/pkg/apis/ml/v1alpha1/conditions.go b/pkg/apis/ml/v1alpha1/conditions.go
new file mode 100644
index 000000000..b6c6e969f
--- /dev/null
+++ b/pkg/apis/ml/v1alpha1/conditions.go
@@ -0,0 +1,27 @@
+//
+// DISCLAIMER
+//
+// Copyright 2023 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 v1alpha1
+
+import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
+
+const (
+ SpecValidCondition api.ConditionType = "SpecValid"
+)
diff --git a/pkg/apis/ml/v1alpha1/cronjob.go b/pkg/apis/ml/v1alpha1/cronjob.go
index f3e924254..9cf434f9a 100644
--- a/pkg/apis/ml/v1alpha1/cronjob.go
+++ b/pkg/apis/ml/v1alpha1/cronjob.go
@@ -45,3 +45,11 @@ type ArangoMLCronJob struct {
Spec ArangoMLCronJobSpec `json:"spec"`
Status ArangoMLCronJobStatus `json:"status"`
}
+
+func (a *ArangoMLCronJob) GetStatus() ArangoMLCronJobStatus {
+ return a.Status
+}
+
+func (a *ArangoMLCronJob) SetStatus(status ArangoMLCronJobStatus) {
+ a.Status = status
+}
diff --git a/pkg/apis/ml/v1alpha1/cronjob_spec.go b/pkg/apis/ml/v1alpha1/cronjob_spec.go
index 45eb91753..f6e0f4f48 100644
--- a/pkg/apis/ml/v1alpha1/cronjob_spec.go
+++ b/pkg/apis/ml/v1alpha1/cronjob_spec.go
@@ -20,5 +20,11 @@
package v1alpha1
+import "github.com/arangodb/kube-arangodb/pkg/apis/shared"
+
type ArangoMLCronJobSpec struct {
}
+
+func (a *ArangoMLCronJobSpec) Validate() error {
+ return shared.WithErrors(shared.PrefixResourceErrors("spec"))
+}
diff --git a/pkg/apis/ml/v1alpha1/cronjob_status.go b/pkg/apis/ml/v1alpha1/cronjob_status.go
index 4e492987d..25da806b5 100644
--- a/pkg/apis/ml/v1alpha1/cronjob_status.go
+++ b/pkg/apis/ml/v1alpha1/cronjob_status.go
@@ -20,5 +20,10 @@
package v1alpha1
+import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
+
type ArangoMLCronJobStatus struct {
+ // Conditions specific to the entire cron job
+ // +doc/type: api.Conditions
+ Conditions api.ConditionList `json:"conditions,omitempty"`
}
diff --git a/pkg/apis/ml/v1alpha1/extension_spec.go b/pkg/apis/ml/v1alpha1/extension_spec.go
index ae39f1c3c..63c2d2fd9 100644
--- a/pkg/apis/ml/v1alpha1/extension_spec.go
+++ b/pkg/apis/ml/v1alpha1/extension_spec.go
@@ -20,5 +20,11 @@
package v1alpha1
+import "github.com/arangodb/kube-arangodb/pkg/apis/shared"
+
type ArangoMLExtensionSpec struct {
}
+
+func (a *ArangoMLExtensionSpec) Validate() error {
+ return shared.WithErrors(shared.PrefixResourceErrors("spec"))
+}
diff --git a/pkg/apis/ml/v1alpha1/storage.go b/pkg/apis/ml/v1alpha1/storage.go
index f2e5efb4e..ca1d8251e 100644
--- a/pkg/apis/ml/v1alpha1/storage.go
+++ b/pkg/apis/ml/v1alpha1/storage.go
@@ -45,3 +45,11 @@ type ArangoMLStorage struct {
Spec ArangoMLStorageSpec `json:"spec"`
Status ArangoMLStorageStatus `json:"status"`
}
+
+func (a *ArangoMLStorage) GetStatus() ArangoMLStorageStatus {
+ return a.Status
+}
+
+func (a *ArangoMLStorage) SetStatus(status ArangoMLStorageStatus) {
+ a.Status = status
+}
diff --git a/pkg/apis/ml/v1alpha1/storage_status.go b/pkg/apis/ml/v1alpha1/storage_status.go
index 2c2b858be..30974065e 100644
--- a/pkg/apis/ml/v1alpha1/storage_status.go
+++ b/pkg/apis/ml/v1alpha1/storage_status.go
@@ -20,5 +20,10 @@
package v1alpha1
+import api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
+
type ArangoMLStorageStatus struct {
+ // Conditions specific to the entire storage
+ // +doc/type: api.Conditions
+ Conditions api.ConditionList `json:"conditions,omitempty"`
}
diff --git a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go
index 5a0aab8cd..70e817fdf 100644
--- a/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go
+++ b/pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go
@@ -36,7 +36,7 @@ func (in *ArangoMLBatchJob) DeepCopyInto(out *ArangoMLBatchJob) {
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
- out.Status = in.Status
+ in.Status.DeepCopyInto(&out.Status)
return
}
@@ -110,6 +110,13 @@ func (in *ArangoMLBatchJobSpec) DeepCopy() *ArangoMLBatchJobSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ArangoMLBatchJobStatus) DeepCopyInto(out *ArangoMLBatchJobStatus) {
*out = *in
+ if in.Conditions != nil {
+ in, out := &in.Conditions, &out.Conditions
+ *out = make(v1.ConditionList, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
return
}
@@ -129,7 +136,7 @@ func (in *ArangoMLCronJob) DeepCopyInto(out *ArangoMLCronJob) {
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.Spec = in.Spec
- out.Status = in.Status
+ in.Status.DeepCopyInto(&out.Status)
return
}
@@ -203,6 +210,13 @@ func (in *ArangoMLCronJobSpec) DeepCopy() *ArangoMLCronJobSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ArangoMLCronJobStatus) DeepCopyInto(out *ArangoMLCronJobStatus) {
*out = *in
+ if in.Conditions != nil {
+ in, out := &in.Conditions, &out.Conditions
+ *out = make(v1.ConditionList, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
return
}
@@ -322,7 +336,7 @@ func (in *ArangoMLStorage) DeepCopyInto(out *ArangoMLStorage) {
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
in.Spec.DeepCopyInto(&out.Spec)
- out.Status = in.Status
+ in.Status.DeepCopyInto(&out.Status)
return
}
@@ -423,6 +437,13 @@ func (in *ArangoMLStorageSpec) DeepCopy() *ArangoMLStorageSpec {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ArangoMLStorageStatus) DeepCopyInto(out *ArangoMLStorageStatus) {
*out = *in
+ if in.Conditions != nil {
+ in, out := &in.Conditions, &out.Conditions
+ *out = make(v1.ConditionList, len(*in))
+ for i := range *in {
+ (*in)[i].DeepCopyInto(&(*out)[i])
+ }
+ }
return
}
diff --git a/pkg/operatorV2/update_wraps.go b/pkg/operatorV2/update_wraps.go
index c9d4cd394..c7a4ed0f4 100644
--- a/pkg/operatorV2/update_wraps.go
+++ b/pkg/operatorV2/update_wraps.go
@@ -36,3 +36,15 @@ func WithArangoBackupUpdateStatusInterfaceRetry(ctx context.Context, client Upda
func WithArangoExtensionUpdateStatusInterfaceRetry(ctx context.Context, client UpdateStatusInterface[mlApi.ArangoMLExtensionStatus, *mlApi.ArangoMLExtension], obj *mlApi.ArangoMLExtension, status mlApi.ArangoMLExtensionStatus, opts meta.UpdateOptions) (*mlApi.ArangoMLExtension, error) {
return WithUpdateStatusInterfaceRetry[mlApi.ArangoMLExtensionStatus, *mlApi.ArangoMLExtension](ctx, client, obj, status, opts)
}
+
+func WithArangoCronJobUpdateStatusInterfaceRetry(ctx context.Context, client UpdateStatusInterface[mlApi.ArangoMLCronJobStatus, *mlApi.ArangoMLCronJob], obj *mlApi.ArangoMLCronJob, status mlApi.ArangoMLCronJobStatus, opts meta.UpdateOptions) (*mlApi.ArangoMLCronJob, error) {
+ return WithUpdateStatusInterfaceRetry[mlApi.ArangoMLCronJobStatus, *mlApi.ArangoMLCronJob](ctx, client, obj, status, opts)
+}
+
+func WithArangoBatchJobUpdateStatusInterfaceRetry(ctx context.Context, client UpdateStatusInterface[mlApi.ArangoMLBatchJobStatus, *mlApi.ArangoMLBatchJob], obj *mlApi.ArangoMLBatchJob, status mlApi.ArangoMLBatchJobStatus, opts meta.UpdateOptions) (*mlApi.ArangoMLBatchJob, error) {
+ return WithUpdateStatusInterfaceRetry[mlApi.ArangoMLBatchJobStatus, *mlApi.ArangoMLBatchJob](ctx, client, obj, status, opts)
+}
+
+func WithArangoStorageUpdateStatusInterfaceRetry(ctx context.Context, client UpdateStatusInterface[mlApi.ArangoMLStorageStatus, *mlApi.ArangoMLStorage], obj *mlApi.ArangoMLStorage, status mlApi.ArangoMLStorageStatus, opts meta.UpdateOptions) (*mlApi.ArangoMLStorage, error) {
+ return WithUpdateStatusInterfaceRetry[mlApi.ArangoMLStorageStatus, *mlApi.ArangoMLStorage](ctx, client, obj, status, opts)
+}
From 25c51f2b114c5a2eb0fadf29e4fda539ba4c5c71 Mon Sep 17 00:00:00 2001
From: ajanikow <12255597+ajanikow@users.noreply.github.com>
Date: Fri, 24 Nov 2023 08:03:36 +0000
Subject: [PATCH 2/2] Generate docs
---
docs/api/ArangoMLBatchJob.V1Alpha1.md | 6 ++++++
docs/api/ArangoMLCronJob.V1Alpha1.md | 6 ++++++
docs/api/ArangoMLStorage.V1Alpha1.md | 6 ++++++
3 files changed, 18 insertions(+)
diff --git a/docs/api/ArangoMLBatchJob.V1Alpha1.md b/docs/api/ArangoMLBatchJob.V1Alpha1.md
index 9845cbc02..48da8dfd7 100644
--- a/docs/api/ArangoMLBatchJob.V1Alpha1.md
+++ b/docs/api/ArangoMLBatchJob.V1Alpha1.md
@@ -4,3 +4,9 @@
## Status
+### .status.conditions
+
+Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/batchjob_status.go#L28)
+
+Conditions specific to the entire batch job
+
diff --git a/docs/api/ArangoMLCronJob.V1Alpha1.md b/docs/api/ArangoMLCronJob.V1Alpha1.md
index f7f281463..3d1a09f04 100644
--- a/docs/api/ArangoMLCronJob.V1Alpha1.md
+++ b/docs/api/ArangoMLCronJob.V1Alpha1.md
@@ -4,3 +4,9 @@
## Status
+### .status.conditions
+
+Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L28)
+
+Conditions specific to the entire cron job
+
diff --git a/docs/api/ArangoMLStorage.V1Alpha1.md b/docs/api/ArangoMLStorage.V1Alpha1.md
index 680fc16a2..a15311fc2 100644
--- a/docs/api/ArangoMLStorage.V1Alpha1.md
+++ b/docs/api/ArangoMLStorage.V1Alpha1.md
@@ -70,3 +70,9 @@ Default Value: `""`
## Status
+### .status.conditions
+
+Type: `api.Conditions` [\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/storage_status.go#L28)
+
+Conditions specific to the entire storage
+