Skip to content

Commit 9fadfec

Browse files
authored
implement v1beta3 tortoise (#219)
1 parent 8685a86 commit 9fadfec

File tree

203 files changed

+3061
-4499
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

203 files changed

+3061
-4499
lines changed

PROJECT

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
# Code generated by tool. DO NOT EDIT.
2-
# This file is used to track the info used to scaffold your project
3-
# and allow the plugins properly work.
4-
# More info: https://book.kubebuilder.io/reference/project-config.html
51
domain: mercari.com
62
layout:
73
- go.kubebuilder.io/v3
@@ -41,4 +37,12 @@ resources:
4137
kind: Tortoise
4238
path: github.com/mercari/tortoise/api/v1beta2
4339
version: v1beta2
40+
- api:
41+
crdVersion: v1
42+
namespaced: true
43+
domain: mercari.com
44+
group: autoscaling
45+
kind: Tortoise
46+
path: github.com/mercari/tortoise/api/v1beta3
47+
version: v1beta3
4448
version: "3"

api/autoscaling/v2/horizontalpodautoscaler_webhook.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import (
3737
"k8s.io/klog/v2"
3838
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
3939

40-
"github.com/mercari/tortoise/api/v1beta2"
40+
"github.com/mercari/tortoise/api/v1beta3"
4141
"github.com/mercari/tortoise/pkg/annotation"
4242
"github.com/mercari/tortoise/pkg/hpa"
4343
"github.com/mercari/tortoise/pkg/tortoise"
@@ -83,7 +83,7 @@ func (h *HPAWebhook) Default(ctx context.Context, obj runtime.Object) error {
8383
return nil
8484
}
8585

86-
if t.Spec.UpdateMode == v1beta2.UpdateModeOff {
86+
if t.Spec.UpdateMode == v1beta3.UpdateModeOff {
8787
// DryRun, don't update HPA
8888
return nil
8989
}
@@ -151,7 +151,7 @@ func (h *HPAWebhook) ValidateDelete(ctx context.Context, obj runtime.Object) (wa
151151

152152
message := fmt.Sprintf("HPA(%s/%s) is being deleted while Tortoise(%s) is running. Please delete Tortoise first", hpa.Namespace, hpa.Name, tortoiseName)
153153

154-
if t.Spec.UpdateMode == v1beta2.UpdateModeOff {
154+
if t.Spec.UpdateMode == v1beta3.UpdateModeOff {
155155
// DryRun - don't block the deletion of HPA, but emit warning.
156156
return []string{message}, nil
157157
}

api/autoscaling/v2/horizontalpodautoscaler_webhook_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import (
3838
"k8s.io/apimachinery/pkg/util/yaml"
3939
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
4040

41-
"github.com/mercari/tortoise/api/v1beta2"
41+
"github.com/mercari/tortoise/api/v1beta3"
4242

4343
. "github.com/onsi/ginkgo/v2"
4444
. "github.com/onsi/gomega"
@@ -49,7 +49,7 @@ func mutateTest(before, after, tortoise string) {
4949

5050
y, err := os.ReadFile(tortoise)
5151
Expect(err).NotTo(HaveOccurred())
52-
tor := &v1beta2.Tortoise{}
52+
tor := &v1beta3.Tortoise{}
5353
err = yaml.NewYAMLOrJSONDecoder(bytes.NewReader(y), 4096).Decode(tor)
5454
status := tor.Status
5555
Expect(err).NotTo(HaveOccurred())
@@ -93,11 +93,11 @@ func mutateTest(before, after, tortoise string) {
9393
func validateDeletionTest(hpa, tortoise string, valid bool) {
9494
ctx := context.Background()
9595

96-
var tor *v1beta2.Tortoise
96+
var tor *v1beta3.Tortoise
9797
if tortoise != "" {
9898
y, err := os.ReadFile(tortoise)
9999
Expect(err).NotTo(HaveOccurred())
100-
tor = &v1beta2.Tortoise{}
100+
tor = &v1beta3.Tortoise{}
101101
err = yaml.NewYAMLOrJSONDecoder(bytes.NewReader(y), 4096).Decode(tor)
102102
status := tor.Status
103103
Expect(err).NotTo(HaveOccurred())
@@ -174,7 +174,7 @@ var _ = Describe("v2.HPA Webhook", func() {
174174
// create tortoise
175175
y, err := os.ReadFile(filepath.Join("testdata", "validating", "hpa-with-auto-being-deleted", "tortoise.yaml"))
176176
Expect(err).NotTo(HaveOccurred())
177-
tor := &v1beta2.Tortoise{}
177+
tor := &v1beta3.Tortoise{}
178178
err = yaml.NewYAMLOrJSONDecoder(bytes.NewReader(y), 4096).Decode(tor)
179179
// add finalizer
180180
controllerutil.AddFinalizer(tor, tortoiseFinalizer)

api/autoscaling/v2/testdata/mutating/has-annotation-but-invalid1/tortoise.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ spec:
1111
scaleTargetRef:
1212
kind: Deployment
1313
name: sample
14-
resourcePolicy:
14+
status:
15+
autoscalingPolicy:
1516
- containerName: istio-proxy
16-
autoscalingPolicy:
17+
policy:
1718
cpu: Horizontal
1819
memory: Vertical
1920
- containerName: nginx
20-
autoscalingPolicy:
21+
policy:
2122
cpu: Horizontal
2223
memory: Vertical
23-
status:
2424
tortoisePhase: Working
2525
containerResourcePhases:
2626
- containerName: "nginx"

api/autoscaling/v2/testdata/mutating/has-annotation-but-invalid2/tortoise.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ spec:
1111
scaleTargetRef:
1212
kind: Deployment
1313
name: sample
14-
resourcePolicy:
14+
status:
15+
autoscalingPolicy:
1516
- containerName: istio-proxy
16-
autoscalingPolicy:
17+
policy:
1718
cpu: Horizontal
1819
memory: Vertical
1920
- containerName: nginx
20-
autoscalingPolicy:
21+
policy:
2122
cpu: Horizontal
2223
memory: Vertical
23-
status:
2424
tortoisePhase: Working
2525
containerResourcePhases:
2626
- containerName: "nginx"

api/autoscaling/v2/testdata/mutating/mutate-by-recommendations/tortoise.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ spec:
1111
scaleTargetRef:
1212
kind: Deployment
1313
name: sample
14-
resourcePolicy:
14+
status:
15+
autoscalingPolicy:
1516
- containerName: istio-proxy
16-
autoscalingPolicy:
17+
policy:
1718
cpu: Horizontal
1819
memory: Vertical
1920
- containerName: nginx
20-
autoscalingPolicy:
21+
policy:
2122
cpu: Horizontal
2223
memory: Vertical
23-
status:
2424
tortoisePhase: Working
2525
containerResourcePhases:
2626
- containerName: "nginx"

api/autoscaling/v2/testdata/mutating/no-mutate-by-recommendations-when-dryrun/tortoise.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ spec:
1111
scaleTargetRef:
1212
kind: Deployment
1313
name: sample
14-
resourcePolicy:
14+
status:
15+
autoscalingPolicy:
1516
- containerName: istio-proxy
16-
autoscalingPolicy:
17+
policy:
1718
cpu: Horizontal
1819
memory: Vertical
1920
- containerName: nginx
20-
autoscalingPolicy:
21+
policy:
2122
cpu: Horizontal
2223
memory: Vertical
23-
status:
2424
tortoisePhase: Working
2525
containerResourcePhases:
2626
- containerName: "nginx"

api/autoscaling/v2/testdata/validating/hpa-with-auto-being-deleted/tortoise.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,16 @@ spec:
1212
scaleTargetRef:
1313
kind: Deployment
1414
name: sample
15-
resourcePolicy:
15+
status:
16+
autoscalingPolicy:
1617
- containerName: istio-proxy
17-
autoscalingPolicy:
18+
policy:
1819
cpu: Horizontal
1920
memory: Vertical
2021
- containerName: nginx
21-
autoscalingPolicy:
22+
policy:
2223
cpu: Horizontal
2324
memory: Vertical
24-
status:
2525
tortoisePhase: Working
2626
containerResourcePhases:
2727
- containerName: "nginx"

api/autoscaling/v2/testdata/validating/hpa-with-auto-existing/tortoise.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ spec:
1111
scaleTargetRef:
1212
kind: Deployment
1313
name: sample
14-
resourcePolicy:
14+
status:
15+
autoscalingPolicy:
1516
- containerName: istio-proxy
16-
autoscalingPolicy:
17+
policy:
1718
cpu: Horizontal
1819
memory: Vertical
1920
- containerName: nginx
20-
autoscalingPolicy:
21+
policy:
2122
cpu: Horizontal
2223
memory: Vertical
23-
status:
2424
tortoisePhase: Working
2525
containerResourcePhases:
2626
- containerName: "nginx"

api/autoscaling/v2/testdata/validating/hpa-with-off/tortoise.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,16 @@ spec:
1111
scaleTargetRef:
1212
kind: Deployment
1313
name: sample
14-
resourcePolicy:
14+
status:
15+
autoscalingPolicy:
1516
- containerName: istio-proxy
16-
autoscalingPolicy:
17+
policy:
1718
cpu: Horizontal
1819
memory: Vertical
1920
- containerName: nginx
20-
autoscalingPolicy:
21+
policy:
2122
cpu: Horizontal
2223
memory: Vertical
23-
status:
2424
tortoisePhase: Working
2525
containerResourcePhases:
2626
- containerName: "nginx"

0 commit comments

Comments
 (0)