Skip to content

Commit

Permalink
Merge pull request #462 from hangscer8/add_spray_job_timeout
Browse files Browse the repository at this point in the history
Add spray job timeout
  • Loading branch information
kubean-pr-robot[bot] authored Jan 6, 2023
2 parents ab2248b + 927582b commit 8635bcc
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 61 deletions.
4 changes: 3 additions & 1 deletion api/apis/clusteroperation/v1alpha1/types.go
Original file line number Diff line number Diff line change
@@ -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"
)

Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions api/apis/clusteroperation/v1alpha1/zz_generated.deepcopy.go

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

3 changes: 3 additions & 0 deletions api/charts/crds/kubean.io_clusteroperations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
type: string
actionType:
type: string
activeDeadlineSeconds:
format: int64
type: integer
backoffLimit:
type: integer
cluster:
Expand Down

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

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

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

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

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

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

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

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

3 changes: 0 additions & 3 deletions charts/kubean/Chart.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions charts/kubean/crds/kubean.io_clusteroperations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ spec:
type: string
actionType:
type: string
activeDeadlineSeconds:
format: int64
type: integer
backoffLimit:
type: integer
cluster:
Expand Down
3 changes: 3 additions & 0 deletions pkg/controllers/clusterops/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions pkg/controllers/clusterops/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 3 additions & 1 deletion vendor/kubean.io/api/apis/clusteroperation/v1alpha1/types.go

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

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

0 comments on commit 8635bcc

Please sign in to comment.