Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic switch to emergency mode when metrics unavailable #424

Open
wants to merge 37 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
438f653
upgrade kubebuilder to plugin/v4
randytqwjp Oct 10, 2024
df7b7b8
add test utils
randytqwjp Oct 10, 2024
52780ef
fix controller test
randytqwjp Oct 22, 2024
9c153b5
fix gha test
randytqwjp Oct 22, 2024
f4454f4
chmod tortoisectl test
randytqwjp Oct 22, 2024
bba0747
edit tortoisectl
randytqwjp Oct 23, 2024
a968c7a
fix lint
randytqwjp Oct 23, 2024
691c4f4
fix lint
randytqwjp Oct 23, 2024
e28d881
add lint-fix to ci
randytqwjp Oct 23, 2024
192fecf
go mod tidy
randytqwjp Oct 23, 2024
4343ea9
add make dependencies
randytqwjp Oct 23, 2024
93556df
remove lint-fix
randytqwjp Oct 23, 2024
5cda06c
upgrade tools
randytqwjp Oct 23, 2024
0fbfff5
lint-fix
randytqwjp Oct 23, 2024
ae2334a
add tool chain version
randytqwjp Oct 23, 2024
28080e3
change toolchain to 1.22
randytqwjp Oct 23, 2024
ca36611
add timeout
randytqwjp Oct 23, 2024
5677abc
remove lint-fix
randytqwjp Oct 23, 2024
a6b0318
edit licenses
randytqwjp Oct 29, 2024
e8454e9
remove chmod
randytqwjp Nov 1, 2024
3725788
Merge branch 'main' of github.com:mercari/tortoise into kubebuilder-i…
randytqwjp Nov 26, 2024
ba4351e
automatic emergency mode trigger when kube metrics unavailable for hpa
randytqwjp Nov 26, 2024
11d8cb8
add return statement
randytqwjp Nov 26, 2024
c056d82
clean up code
randytqwjp Nov 28, 2024
b47578c
clean up code
randytqwjp Nov 28, 2024
7d07efd
add hpa test and try to fix controller test
randytqwjp Dec 3, 2024
12c7b05
fix old controller tests
randytqwjp Dec 4, 2024
ed22342
add controller test and fix checkHPAStatus function
randytqwjp Dec 6, 2024
bddb139
clean up code
randytqwjp Dec 6, 2024
0dc2749
remove autoemergency phase and use emergency instead
randytqwjp Dec 6, 2024
dd7c10a
fix lint
randytqwjp Dec 6, 2024
2e261c4
refactor tortoisephase change into tortoise service and write unit tests
randytqwjp Dec 12, 2024
7c0e997
fix lint
randytqwjp Dec 13, 2024
5be0c1a
fix lint
randytqwjp Dec 13, 2024
d8ae58d
fix review comments
randytqwjp Dec 19, 2024
46d71a9
fix nits
randytqwjp Jan 9, 2025
e41aab4
fix nits
randytqwjp Jan 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions internal/controller/testdata/deletion-no-delete/before/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ metadata:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
name: tortoise-hpa-mercari
namespace: default
status:
conditions:
- status: "True"
type: AbleToScale
message: "recommended size matches current size"
- status: "True"
type: ScalingActive
message: "the HPA was able to compute the replica count"
currentMetrics:
- containerResource:
container: app
name: cpu
current:
value: 3
- containerResource:
container: istio-proxy
name: cpu
current:
value: 3
spec:
behavior:
scaleDown:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ metadata:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
name: tortoise-hpa-mercari
namespace: default
status:
conditions:
- status: "True"
type: AbleToScale
message: "recommended size matches current size"
- status: "True"
type: ScalingActive
message: "the HPA was able to compute the replica count"
currentMetrics:
- containerResource:
container: app
name: cpu
current:
value: 3
- containerResource:
container: istio-proxy
name: cpu
current:
value: 3
spec:
behavior:
scaleDown:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,21 @@ spec:
kind: Deployment
name: mercari-app
status:
currentMetrics: null
desiredReplicas: 0
conditions:
- status: "True"
type: AbleToScale
message: "recommended size matches current size"
- status: "True"
type: ScalingActive
message: "the HPA was able to compute the replica count"
currentMetrics:
- containerResource:
container: app
name: cpu
current:
value: 3
- containerResource:
container: istio-proxy
name: cpu
current:
value: 3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ metadata:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
name: tortoise-hpa-mercari
namespace: default
status:
conditions:
- status: "True"
type: AbleToScale
message: "recommended size matches current size"
- status: "True"
type: ScalingActive
message: "the HPA was able to compute the replica count"
currentMetrics:
- containerResource:
container: app
name: cpu
current:
value: 3
- containerResource:
container: istio-proxy
name: cpu
current:
value: 3
spec:
behavior:
scaleDown:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ spec:
strategy: {}
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: "2023-01-01T00:00:00Z"
annotations: null
creationTimestamp: null
labels:
app: mercari
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,110 +20,97 @@ status:
cpu: Vertical
memory: Vertical
conditions:
containerResourceRequests:
- containerName: app
resource:
cpu: "10"
memory: 10Gi
- containerName: istio-proxy
resource:
cpu: "4"
memory: 4Gi
tortoiseConditions:
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
status: "False"
type: FailedToReconcile
containerRecommendationFromVPA:
- containerName: app
maxRecommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
quantity: "10"
updatedAt: null
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
quantity: 10Gi
updatedAt: null
recommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
quantity: "10"
updatedAt: null
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
quantity: 10Gi
updatedAt: null
- containerName: istio-proxy
maxRecommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
quantity: "4"
updatedAt: null
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
quantity: 4Gi
updatedAt: null
recommendation:
cpu:
quantity: "3"
updatedAt: "2023-01-01T00:00:00Z"
quantity: "4"
updatedAt: null
memory:
quantity: 3Gi
updatedAt: "2023-01-01T00:00:00Z"
containerResourceRequests:
- containerName: app
resource:
cpu: "10"
memory: 3Gi
- containerName: istio-proxy
resource:
cpu: "3"
memory: 3Gi
tortoiseConditions:
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
message: the current number of replicas is not bigger than the preferred max
replica number
reason: ScaledUpBasedOnPreferredMaxReplicas
status: "False"
type: ScaledUpBasedOnPreferredMaxReplicas
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
message: The recommendation is provided
status: "True"
type: VerticalRecommendationUpdated
- lastTransitionTime: "2023-01-01T00:00:00Z"
lastUpdateTime: "2023-01-01T00:00:00Z"
status: "False"
type: FailedToReconcile
containerResourcePhases:
- containerName: app
resourcePhases:
cpu:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: GatheringData
memory:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
- containerName: istio-proxy
resourcePhases:
cpu:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
memory:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
quantity: 4Gi
updatedAt: null
recommendations:
horizontal:
maxReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-01-01T00:00:00Z"
updatedAt: "2023-10-06T01:15:47Z"
value: 20
minReplicas:
- from: 0
timezone: Local
to: 24
updatedAt: "2023-01-01T00:00:00Z"
updatedAt: "2023-10-06T01:15:47Z"
value: 5
targetUtilizations:
- containerName: app
targetUtilization:
cpu: 70
targetUtilization: {}
- containerName: istio-proxy
targetUtilization: {}
vertical:
containerResourceRecommendation:
- RecommendedResource:
cpu: "10"
memory: 3Gi
memory: 10Gi
containerName: app
- RecommendedResource:
cpu: "3"
memory: 3Gi
cpu: "4"
memory: 4Gi
containerName: istio-proxy
containerResourcePhases:
- containerName: app
resourcePhases:
cpu:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: GatheringData
memory:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
- containerName: istio-proxy
resourcePhases:
cpu:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
memory:
lastTransitionTime: "2023-01-01T00:00:00Z"
phase: Working
targets:
horizontalPodAutoscaler: tortoise-hpa-mercari
scaleTargetRef:
Expand All @@ -132,4 +119,4 @@ status:
verticalPodAutoscalers:
- name: tortoise-monitor-mercari
role: Monitor
tortoisePhase: Working
tortoisePhase: PartlyWorking
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,21 @@ spec:
kind: Deployment
name: mercari-app
status:
currentMetrics: null
desiredReplicas: 0
conditions:
- status: "True"
type: AbleToScale
message: "recommended size matches current size"
- status: "True"
type: ScalingActive
message: "the HPA was able to compute the replica count"
currentMetrics:
- containerResource:
container: app
name: cpu
current:
value: 3
- containerResource:
container: istio-proxy
name: cpu
current:
value: 3
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ metadata:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
name: tortoise-hpa-mercari
namespace: default
status:
conditions:
- status: "True"
type: AbleToScale
message: "recommended size matches current size"
- status: "True"
type: ScalingActive
message: "the HPA was able to compute the replica count"
currentMetrics:
- containerResource:
container: app
name: cpu
current:
value: 3
- containerResource:
container: istio-proxy
name: cpu
current:
value: 3
spec:
behavior:
scaleDown:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ metadata:
tortoise.autoscaling.mercari.com/managed-by-tortoise: "true"
name: tortoise-hpa-mercari
namespace: default
status:
conditions:
- status: "True"
type: AbleToScale
message: "recommended size matches current size"
- status: "True"
type: ScalingActive
message: "the HPA was able to compute the replica count"
currentMetrics:
- containerResource:
container: app
name: cpu
current:
value: 3
- containerResource:
container: istio-proxy
name: cpu
current:
value: 3
spec:
behavior:
scaleDown:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
metadata:
name: mercari-app
namespace: default
spec:
selector:
matchLabels:
app: mercari
strategy: {}
template:
metadata:
annotations:
kubectl.kubernetes.io/restartedAt: "2023-01-01T00:00:00Z"
creationTimestamp: null
labels:
app: mercari
spec:
containers:
- image: awesome-mercari-app-image
name: app
resources:
requests:
cpu: "10"
memory: 10Gi
- image: awesome-istio-proxy-image
name: istio-proxy
resources:
requests:
cpu: "4"
memory: 4Gi
status: {}
Loading
Loading