Skip to content

Commit

Permalink
Merge pull request #582 from shunki-fujita/DBOP-867
Browse files Browse the repository at this point in the history
Enable cpu specification in jobConfig
  • Loading branch information
ymmt2005 authored Oct 25, 2023
2 parents 86d246b + 0f033d1 commit 50fb210
Show file tree
Hide file tree
Showing 17 changed files with 317 additions and 42 deletions.
11 changes: 11 additions & 0 deletions api/v1beta1/job_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ type JobConfig struct {
// +optional
Threads int `json:"threads,omitempty"`

// CPU is the amount of CPU requested for the Pod.
// +kubebuilder:default=4
// +nullable
// +optional
CPU *resource.Quantity `json:"cpu,omitempty"`

// MaxCPU is the amount of maximum CPU for the Pod.
// +nullable
// +optional
MaxCPU *resource.Quantity `json:"maxCpu,omitempty"`

// Memory is the amount of memory requested for the Pod.
// +kubebuilder:default="4Gi"
// +nullable
Expand Down
4 changes: 4 additions & 0 deletions api/v1beta1/zz_generated.conversion.go

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

10 changes: 10 additions & 0 deletions api/v1beta1/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/v1beta2/backuppolicy_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ var _ = Describe("BackupPolicy Webhook", func() {
Expect(err).NotTo(HaveOccurred())

Expect(r.Spec.JobConfig.Threads).To(Equal(4))
Expect(r.Spec.JobConfig.CPU).NotTo(BeNil())
Expect(r.Spec.JobConfig.CPU.Value()).To(Equal(int64(4)))
Expect(r.Spec.JobConfig.MaxCPU).To(BeNil())
Expect(r.Spec.JobConfig.Memory).NotTo(BeNil())
Expect(r.Spec.JobConfig.Memory.Value()).To(Equal(int64(4) << 30))
Expect(r.Spec.JobConfig.MaxMemory).To(BeNil())
Expand Down
11 changes: 11 additions & 0 deletions api/v1beta2/job_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ type JobConfig struct {
// +optional
Threads int `json:"threads,omitempty"`

// CPU is the amount of CPU requested for the Pod.
// +kubebuilder:default=4
// +nullable
// +optional
CPU *resource.Quantity `json:"cpu,omitempty"`

// MaxCPU is the amount of maximum CPU for the Pod.
// +nullable
// +optional
MaxCPU *resource.Quantity `json:"maxCpu,omitempty"`

// Memory is the amount of memory requested for the Pod.
// +kubebuilder:default="4Gi"
// +nullable
Expand Down
10 changes: 10 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

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

68 changes: 68 additions & 0 deletions charts/moco/templates/generated/crds/moco_crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -516,6 +525,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down Expand Up @@ -2447,6 +2464,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -2529,6 +2555,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down Expand Up @@ -7699,6 +7733,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -7781,6 +7824,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down Expand Up @@ -13566,6 +13617,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -13648,6 +13708,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down
34 changes: 34 additions & 0 deletions config/crd/bases/moco.cybozu.com_backuppolicies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -564,6 +573,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down Expand Up @@ -2644,6 +2661,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -2734,6 +2760,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down
34 changes: 34 additions & 0 deletions config/crd/bases/moco.cybozu.com_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4011,6 +4011,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -4102,6 +4111,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down Expand Up @@ -10425,6 +10442,15 @@ spec:
required:
- bucketName
type: object
cpu:
anyOf:
- type: integer
- type: string
default: 4
description: CPU is the amount of CPU requested for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
env:
description: List of environment variables to set in the contai
items:
Expand Down Expand Up @@ -10516,6 +10542,14 @@ spec:
type: object
type: object
type: array
maxCpu:
anyOf:
- type: integer
- type: string
description: MaxCPU is the amount of maximum CPU for the Pod.
nullable: true
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
x-kubernetes-int-or-string: true
maxMemory:
anyOf:
- type: integer
Expand Down
Loading

0 comments on commit 50fb210

Please sign in to comment.