Skip to content

Commit

Permalink
MLCronJob status update (#1526)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwierzbo authored Dec 7, 2023
1 parent 44733f2 commit 244c362
Show file tree
Hide file tree
Showing 10 changed files with 236 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .circleci/continue_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parameters:
executors:
golang-executor:
docker:
- image: gcr.io/gcr-for-testing/golang:1.20.11
- image: gcr.io/gcr-for-testing/golang:1.20.12
machine-executor:
machine:
image: ubuntu-2204:current
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- (Feature) (ML) Extension Storage Condition
- (Improvement) (ML) Switch to fsnotify for file watching for MacOS support
- (Feature) (ML) Unify Images, Resources and Lifecycle
- (Improvement) (ML) CronJob status update

## [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
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ endif

TEST_BUILD ?= 0
GOBUILDARGS ?=
GOBASEVERSION := 1.20.11
GOBASEVERSION := 1.20.12
GOVERSION := $(GOBASEVERSION)-alpine3.17
DISTRIBUTION := alpine:3.15
GOBUILDTAGS := $(RELEASE_MODE)
Expand Down Expand Up @@ -779,6 +779,7 @@ set-api-version/%:
synchronize: synchronize-v2alpha1-with-v1

synchronize-v2alpha1-with-v1:
@echo ">> Please use only COMMUNITY mode! Current RELEASE_MODE=$(RELEASE_MODE)"
@rm -f pkg/apis/deployment/v1/zz_generated.deepcopy.go pkg/apis/deployment/v2alpha1/zz_generated.deepcopy.go
@for file in $$(find "$(ROOT)/pkg/apis/deployment/v1/" -type f -exec $(REALPATH) --relative-to "$(ROOT)/pkg/apis/deployment/v1/" {} \;); do if [ ! -d "$(ROOT)/pkg/apis/deployment/v2alpha1/$$(dirname $${file})" ]; then mkdir -p "$(ROOT)/pkg/apis/deployment/v2alpha1/$$(dirname $${file})"; fi; done
@for file in $$(find "$(ROOT)/pkg/apis/deployment/v1/" -type f -exec $(REALPATH) --relative-to "$(ROOT)/pkg/apis/deployment/v1/" {} \;); do cat "$(ROOT)/pkg/apis/deployment/v1/$${file}" | $(SED) "s#package v1#package v2alpha1#g" | $(SED) 's#ArangoDeploymentVersion = "v1"#ArangoDeploymentVersion = "v2alpha1"#g' > "$(ROOT)/pkg/apis/deployment/v2alpha1/$${file}"; done
Expand Down
30 changes: 27 additions & 3 deletions docs/api/ArangoMLCronJob.V1Alpha1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### .spec

Type: `batch.CronJobSpec` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_spec.go#L32)</sup>
Type: `batch.CronJobSpec` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_spec.go#L33)</sup>

Links:
* [Kubernetes Documentation](https://godoc.org/k8s.io/api/batch/v1beta1#CronJobSpec)
Expand All @@ -13,7 +13,7 @@ Links:

### .status

Type: `batch.CronJobStatus` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L36)</sup>
Type: `batch.CronJobStatus` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L38)</sup>

Links:
* [Kubernetes Documentation](https://godoc.org/k8s.io/api/batch/v1beta1#CronJobStatus)
Expand All @@ -22,7 +22,31 @@ Links:

### .status.conditions

Type: `api.Conditions` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L32)</sup>
Type: `api.Conditions` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/ml/v1alpha1/cronjob_status.go#L34)</sup>

Conditions specific to the entire cron job

***

### .status.ref.name

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/object.go#L46)</sup>

Name of the object

***

### .status.ref.namespace

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/object.go#L49)</sup>

Namespace of the object. Should default to the namespace of the parent object

***

### .status.ref.uid

Type: `string` <sup>[\[ref\]](https://github.com/arangodb/kube-arangodb/blob/1.2.35/pkg/apis/shared/v1/object.go#L52)</sup>

UID keeps the information about object UID

16 changes: 13 additions & 3 deletions pkg/apis/ml/v1alpha1/cronjob_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,27 @@
package v1alpha1

import (
batchApi "k8s.io/api/batch/v1beta1"
batch "k8s.io/api/batch/v1"

"github.com/arangodb/kube-arangodb/pkg/apis/shared"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
)

type ArangoMLCronJobSpec struct {
// +doc/type: batch.CronJobSpec
// +doc/link: Kubernetes Documentation|https://godoc.org/k8s.io/api/batch/v1beta1#CronJobSpec
*batchApi.CronJobSpec `json:",inline"`
*batch.CronJobSpec `json:",inline"`
}

func (a *ArangoMLCronJobSpec) Validate() error {
return shared.WithErrors(shared.PrefixResourceErrors("spec"))
if a == nil {
return errors.Newf("Spec is not defined")
}

var err []error
if a.CronJobSpec == nil {
err = append(err, shared.PrefixResourceErrors("spec", errors.Newf("CronJobSpec is not defined")))
}

return shared.WithErrors(err...)
}
13 changes: 11 additions & 2 deletions pkg/apis/ml/v1alpha1/cronjob_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
package v1alpha1

import (
batchApi "k8s.io/api/batch/v1beta1"
batch "k8s.io/api/batch/v1"

api "github.com/arangodb/kube-arangodb/pkg/apis/deployment/v1"
"github.com/arangodb/kube-arangodb/pkg/apis/shared"
sharedApi "github.com/arangodb/kube-arangodb/pkg/apis/shared/v1"
)

type ArangoMLCronJobStatus struct {
Expand All @@ -33,5 +35,12 @@ type ArangoMLCronJobStatus struct {

// +doc/type: batch.CronJobStatus
// +doc/link: Kubernetes Documentation|https://godoc.org/k8s.io/api/batch/v1beta1#CronJobStatus
batchApi.CronJobStatus `json:",inline"`
*batch.CronJobStatus `json:",inline"`

// Ref keeps the reference to the CronJob
Ref *sharedApi.Object `json:"ref,omitempty"`
}

func (a *ArangoMLCronJobStatus) Validate() error {
return shared.WithErrors(shared.PrefixResourceErrors("spec"))
}
1 change: 1 addition & 0 deletions pkg/apis/ml/v1alpha1/extension_conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ const (
ExtensionMetadataServiceValidCondition api.ConditionType = "MetadataServiceValid"
ExtensionServiceAccountReadyCondition api.ConditionType = "ServiceAccountReady"
LicenseValidCondition api.ConditionType = "LicenseValid"
CronJobSyncedCondition api.ConditionType = "CronJobSynced"
)
15 changes: 12 additions & 3 deletions pkg/apis/ml/v1alpha1/zz_generated.deepcopy.go

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

5 changes: 4 additions & 1 deletion pkg/operatorV2/operator_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ package operator

import (
"context"
"fmt"

"github.com/arangodb/kube-arangodb/pkg/operatorV2/operation"
"github.com/arangodb/kube-arangodb/pkg/util/errors"
Expand Down Expand Up @@ -109,7 +110,9 @@ func (o *operator) processObject(obj interface{}) error {
o.workqueue.AddRateLimited(key)

if !IsReconcile(err) {
return errors.Newf("error syncing '%s': %s, re-queuing", key, err.Error())
message := fmt.Sprintf("error syncing '%s': %s, re-queuing", key, err.Error())
loggerWorker.Debug(message)
return errors.Newf(message)
}

return nil
Expand Down
Loading

0 comments on commit 244c362

Please sign in to comment.