Skip to content

Commit

Permalink
introduce LastTransitionTime and change phase based on that (#167)
Browse files Browse the repository at this point in the history
* introduce LastTransitionTime and change phase based on that

* fix by lint
  • Loading branch information
sanposhiho authored Oct 11, 2023
1 parent f24677d commit c555c8b
Show file tree
Hide file tree
Showing 39 changed files with 973 additions and 234 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ status:
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
targets:
deployment: sample
horizontalPodAutoscaler: sample
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ status:
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
targets:
deployment: sample
horizontalPodAutoscaler: sample2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ status:
containerResourcePhases:
- containerName: "nginx"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
targets:
deployment: sample
horizontalPodAutoscaler: sample
Expand Down
14 changes: 13 additions & 1 deletion api/v1beta1/tortoise_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,15 @@ type ContainerResourcePhases struct {
// ContainerName is the name of target container.
ContainerName string `json:"containerName" protobuf:"bytes,1,name=containerName"`
// ResourcePhases is the phase of each resource of this container.
ResourcePhases map[v1.ResourceName]ContainerResourcePhase `json:"resourcePhases" protobuf:"bytes,2,name=resourcePhases"`
ResourcePhases map[v1.ResourceName]ResourcePhase `json:"resourcePhases" protobuf:"bytes,2,name=resourcePhases"`
}

type ResourcePhase struct {
Phase ContainerResourcePhase `json:"phase" protobuf:"bytes,1,name=phase"`
// lastTransitionTime is the last time the condition transitioned from
// one status to another
// +optional
LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty" protobuf:"bytes,2,opt,name=lastTransitionTime"`
}

type ContainerResourcePhase string
Expand All @@ -176,6 +184,10 @@ const (
// TortoisePhaseWorking means tortoise is making the recommendations,
// and applying the recommendation values.
TortoisePhaseWorking TortoisePhase = "Working"
// TortoisePhasePartlyWorking means tortoise is making the recommendations,
// and applying the recommendation values.
// But, some of the resources are not scaled due to some reasons. (probably still gathering data)
TortoisePhasePartlyWorking TortoisePhase = "PartlyWorking"
// TortoisePhaseEmergency means tortoise is in the emergency mode.
TortoisePhaseEmergency TortoisePhase = "Emergency"
// TortoisePhaseBackToNormal means tortoise was in the emergency mode, and now it's coming back to the normal operation.
Expand Down
20 changes: 18 additions & 2 deletions api/v1beta1/zz_generated.deepcopy.go

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

12 changes: 11 additions & 1 deletion config/crd/bases/autoscaling.mercari.com_tortoises.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,17 @@ spec:
type: string
resourcePhases:
additionalProperties:
type: string
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
transitioned from one status to another
format: date-time
type: string
phase:
type: string
required:
- phase
type: object
description: ResourcePhases is the phase of each resource of
this container.
type: object
Expand Down
14 changes: 9 additions & 5 deletions controllers/testdata/deletion-no-delete/before/tortoise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
14 changes: 9 additions & 5 deletions controllers/testdata/deletion-policy-all/before/tortoise.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: GatheringData
resourcePhases:
cpu:
phase: Working
memory:
phase: GatheringData
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: GatheringData
memory: Working
cpu:
phase: GatheringData
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,13 @@ status:
containerResourcePhases:
- containerName: "app"
resourcePhases:
cpu: Working
memory: Working
cpu:
phase: Working
memory:
phase: Working
- containerName: "istio-proxy"
resourcePhases:
cpu: Working
memory: Working
resourcePhases:
cpu:
phase: Working
memory:
phase: Working
Loading

0 comments on commit c555c8b

Please sign in to comment.