From bec48205a41884adaf9594e13e1ba7cb8042bd60 Mon Sep 17 00:00:00 2001 From: "hang.jiang" Date: Fri, 6 Jan 2023 11:18:20 +0800 Subject: [PATCH 1/2] update api --- api/apis/clusteroperation/v1alpha1/types.go | 4 +++- .../v1alpha1/zz_generated.deepcopy.go | 5 +++++ api/charts/crds/kubean.io_clusteroperations.yaml | 3 +++ .../cluster/clientset/versioned/fake/register.go | 14 +++++++------- .../cluster/clientset/versioned/scheme/register.go | 14 +++++++------- .../clientset/versioned/fake/register.go | 14 +++++++------- .../clientset/versioned/scheme/register.go | 14 +++++++------- .../clientset/versioned/fake/register.go | 14 +++++++------- .../clientset/versioned/scheme/register.go | 14 +++++++------- .../manifest/clientset/versioned/fake/register.go | 14 +++++++------- .../clientset/versioned/scheme/register.go | 14 +++++++------- .../kubean/crds/kubean.io_clusteroperations.yaml | 3 +++ .../api/apis/clusteroperation/v1alpha1/types.go | 4 +++- .../v1alpha1/zz_generated.deepcopy.go | 5 +++++ 14 files changed, 78 insertions(+), 58 deletions(-) diff --git a/api/apis/clusteroperation/v1alpha1/types.go b/api/apis/clusteroperation/v1alpha1/types.go index e298f811f..3058351f1 100644 --- a/api/apis/clusteroperation/v1alpha1/types.go +++ b/api/apis/clusteroperation/v1alpha1/types.go @@ -1,8 +1,8 @@ package v1alpha1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "kubean.io/api/apis" ) @@ -65,6 +65,8 @@ type Spec struct { PostHook []HookAction `json:"postHook"` // +optional Resources corev1.ResourceRequirements `json:"resources"` + // +optional + ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds"` } type HookAction struct { diff --git a/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go b/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go index bc08d7f11..0ca48a752 100644 --- a/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go +++ b/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go @@ -121,6 +121,11 @@ func (in *Spec) DeepCopyInto(out *Spec) { copy(*out, *in) } in.Resources.DeepCopyInto(&out.Resources) + if in.ActiveDeadlineSeconds != nil { + in, out := &in.ActiveDeadlineSeconds, &out.ActiveDeadlineSeconds + *out = new(int64) + **out = **in + } return } diff --git a/api/charts/crds/kubean.io_clusteroperations.yaml b/api/charts/crds/kubean.io_clusteroperations.yaml index 7d4f01153..41179ad92 100644 --- a/api/charts/crds/kubean.io_clusteroperations.yaml +++ b/api/charts/crds/kubean.io_clusteroperations.yaml @@ -45,6 +45,9 @@ spec: type: string actionType: type: string + activeDeadlineSeconds: + format: int64 + type: integer backoffLimit: type: integer cluster: diff --git a/api/generated/cluster/cluster/clientset/versioned/fake/register.go b/api/generated/cluster/cluster/clientset/versioned/fake/register.go index f3348645b..f33304d4f 100644 --- a/api/generated/cluster/cluster/clientset/versioned/fake/register.go +++ b/api/generated/cluster/cluster/clientset/versioned/fake/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/api/generated/cluster/cluster/clientset/versioned/scheme/register.go b/api/generated/cluster/cluster/clientset/versioned/scheme/register.go index e108c8a43..0e45b5107 100644 --- a/api/generated/cluster/cluster/clientset/versioned/scheme/register.go +++ b/api/generated/cluster/cluster/clientset/versioned/scheme/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/api/generated/clusteroperation/clusteroperation/clientset/versioned/fake/register.go b/api/generated/clusteroperation/clusteroperation/clientset/versioned/fake/register.go index 2bb23ea7a..d9fdd6f7e 100644 --- a/api/generated/clusteroperation/clusteroperation/clientset/versioned/fake/register.go +++ b/api/generated/clusteroperation/clusteroperation/clientset/versioned/fake/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/api/generated/clusteroperation/clusteroperation/clientset/versioned/scheme/register.go b/api/generated/clusteroperation/clusteroperation/clientset/versioned/scheme/register.go index 7036bd3d3..bf7f894d3 100644 --- a/api/generated/clusteroperation/clusteroperation/clientset/versioned/scheme/register.go +++ b/api/generated/clusteroperation/clusteroperation/clientset/versioned/scheme/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/api/generated/localartifactset/localartifactset/clientset/versioned/fake/register.go b/api/generated/localartifactset/localartifactset/clientset/versioned/fake/register.go index ed35531c7..3fa3fb9d0 100644 --- a/api/generated/localartifactset/localartifactset/clientset/versioned/fake/register.go +++ b/api/generated/localartifactset/localartifactset/clientset/versioned/fake/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/api/generated/localartifactset/localartifactset/clientset/versioned/scheme/register.go b/api/generated/localartifactset/localartifactset/clientset/versioned/scheme/register.go index cb1f1c060..cf6116e4e 100644 --- a/api/generated/localartifactset/localartifactset/clientset/versioned/scheme/register.go +++ b/api/generated/localartifactset/localartifactset/clientset/versioned/scheme/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/api/generated/manifest/manifest/clientset/versioned/fake/register.go b/api/generated/manifest/manifest/clientset/versioned/fake/register.go index a1a92cf1b..2c958a5e9 100644 --- a/api/generated/manifest/manifest/clientset/versioned/fake/register.go +++ b/api/generated/manifest/manifest/clientset/versioned/fake/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/api/generated/manifest/manifest/clientset/versioned/scheme/register.go b/api/generated/manifest/manifest/clientset/versioned/scheme/register.go index 81ffe7d54..cc9c8aecf 100644 --- a/api/generated/manifest/manifest/clientset/versioned/scheme/register.go +++ b/api/generated/manifest/manifest/clientset/versioned/scheme/register.go @@ -21,14 +21,14 @@ var localSchemeBuilder = runtime.SchemeBuilder{ // AddToScheme adds all types of this clientset into the given scheme. This allows composition // of clientsets, like in: // -// import ( -// "k8s.io/client-go/kubernetes" -// clientsetscheme "k8s.io/client-go/kubernetes/scheme" -// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" -// ) +// import ( +// "k8s.io/client-go/kubernetes" +// clientsetscheme "k8s.io/client-go/kubernetes/scheme" +// aggregatorclientsetscheme "k8s.io/kube-aggregator/pkg/client/clientset_generated/clientset/scheme" +// ) // -// kclientset, _ := kubernetes.NewForConfig(c) -// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) +// kclientset, _ := kubernetes.NewForConfig(c) +// _ = aggregatorclientsetscheme.AddToScheme(clientsetscheme.Scheme) // // After this, RawExtensions in Kubernetes types will serialize kube-aggregator types // correctly. diff --git a/charts/kubean/crds/kubean.io_clusteroperations.yaml b/charts/kubean/crds/kubean.io_clusteroperations.yaml index 7d4f01153..41179ad92 100644 --- a/charts/kubean/crds/kubean.io_clusteroperations.yaml +++ b/charts/kubean/crds/kubean.io_clusteroperations.yaml @@ -45,6 +45,9 @@ spec: type: string actionType: type: string + activeDeadlineSeconds: + format: int64 + type: integer backoffLimit: type: integer cluster: diff --git a/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/types.go b/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/types.go index e298f811f..3058351f1 100644 --- a/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/types.go +++ b/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/types.go @@ -1,8 +1,8 @@ package v1alpha1 import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" corev1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "kubean.io/api/apis" ) @@ -65,6 +65,8 @@ type Spec struct { PostHook []HookAction `json:"postHook"` // +optional Resources corev1.ResourceRequirements `json:"resources"` + // +optional + ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds"` } type HookAction struct { diff --git a/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go b/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go index bc08d7f11..0ca48a752 100644 --- a/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/kubean.io/api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go @@ -121,6 +121,11 @@ func (in *Spec) DeepCopyInto(out *Spec) { copy(*out, *in) } in.Resources.DeepCopyInto(&out.Resources) + if in.ActiveDeadlineSeconds != nil { + in, out := &in.ActiveDeadlineSeconds, &out.ActiveDeadlineSeconds + *out = new(int64) + **out = **in + } return } From 927582bc692ca19a4977dbd38b254834fe99b2ed Mon Sep 17 00:00:00 2001 From: "hang.jiang" Date: Fri, 6 Jan 2023 11:24:41 +0800 Subject: [PATCH 2/2] remove charts addon annotations --- charts/kubean/Chart.yaml | 3 --- pkg/controllers/clusterops/controller.go | 3 +++ pkg/controllers/clusterops/controller_test.go | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/charts/kubean/Chart.yaml b/charts/kubean/Chart.yaml index 505fb83e8..25f1cb862 100644 --- a/charts/kubean/Chart.yaml +++ b/charts/kubean/Chart.yaml @@ -1,6 +1,3 @@ -annotations: - addon.kpanda.io/namespace: kubean-system - addon.kpanda.io/release-name: kubean apiVersion: v2 name: kubean description: A Helm chart for kubean diff --git a/pkg/controllers/clusterops/controller.go b/pkg/controllers/clusterops/controller.go index 0080dd689..06e6f19f5 100644 --- a/pkg/controllers/clusterops/controller.go +++ b/pkg/controllers/clusterops/controller.go @@ -457,6 +457,9 @@ func (c *Controller) NewKubesprayJob(clusterOps *clusteroperationv1alpha1.Cluste }, }) } + if clusterOps.Spec.ActiveDeadlineSeconds != nil && *clusterOps.Spec.ActiveDeadlineSeconds > 0 { + job.Spec.ActiveDeadlineSeconds = clusterOps.Spec.ActiveDeadlineSeconds + } if !reflect.ValueOf(clusterOps.Spec.Resources).IsZero() { if len(job.Spec.Template.Spec.Containers) > 0 && job.Spec.Template.Spec.Containers[0].Name == "kubespray" { job.Spec.Template.Spec.Containers[0].Resources = clusterOps.Spec.Resources diff --git a/pkg/controllers/clusterops/controller_test.go b/pkg/controllers/clusterops/controller_test.go index 975c87873..3f3b9f732 100644 --- a/pkg/controllers/clusterops/controller_test.go +++ b/pkg/controllers/clusterops/controller_test.go @@ -454,6 +454,25 @@ func TestNewKubesprayJob(t *testing.T) { }, want: true, }, + { + name: "activeDeadlineSeconds args", + args: func() bool { + ActiveDeadlineSeconds := int64(10) + clusterOps.Spec.ActiveDeadlineSeconds = &ActiveDeadlineSeconds + job := controller.NewKubesprayJob(clusterOps) + return *job.Spec.ActiveDeadlineSeconds == 10 + }, + want: true, + }, + { + name: "nil activeDeadlineSeconds args", + args: func() bool { + clusterOps.Spec.ActiveDeadlineSeconds = nil + job := controller.NewKubesprayJob(clusterOps) + return job.Spec.ActiveDeadlineSeconds == nil + }, + want: true, + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) {