Skip to content

Commit 11fa6b6

Browse files
authored
feat: add available adaptive policy and generate code (#40)
1 parent 2399b38 commit 11fa6b6

File tree

9 files changed

+840
-381
lines changed

9 files changed

+840
-381
lines changed

apps/v1alpha1/podtransitionrule_types.go

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,35 @@ type LabelCheckRule struct {
7979
}
8080

8181
type AvailableRule struct {
82-
// MaxUnavailableValue is the expected max unavailable replicas which is allowed to be a integer or a percentage of the whole
82+
// MaxUnavailableValue is the expected max unavailable replicas which is allowed to be an integer or a percentage of the whole
8383
// number of the target resources.
8484
MaxUnavailableValue *intstr.IntOrString `json:"maxUnavailableValue,omitempty"`
8585

86-
// MinAvailableValue is the expected min available replicas which is allowed to be a integer or a percentage of the whole
86+
// MaxUnavailablePolicy is an option to apply max unavailable by adaptive policy.
87+
// +optional
88+
MaxUnavailablePolicy *AdaptivePolicy `json:"maxUnavailablePolicy,omitempty"`
89+
90+
// MinAvailableValue is the expected min available replicas which is allowed to be an integer or a percentage of the whole
8791
// number of the target resources.
8892
MinAvailableValue *intstr.IntOrString `json:"minAvailableValue,omitempty"`
93+
94+
// MaxUnavailablePolicy is an option to apply min available by adaptive policy.
95+
// +optional
96+
MinAvailablePolicy *AdaptivePolicy `json:"minAvailablePolicy,omitempty"`
97+
}
98+
99+
type AdaptivePolicy struct {
100+
// ExpFunc is an exponentiation expression to calculate the expected value.
101+
// func: f(x) = coeff * x ^ pow.
102+
ExpFunc *ExpFunc `json:"expFunc,omitempty"`
103+
}
104+
105+
type ExpFunc struct {
106+
// Coeff stands for coefficient in this exponentiation.
107+
Coeff *string `json:"coeff,omitempty"`
108+
109+
// Pow stands for power in this exponentiation.
110+
Pow *string `json:"pow,omitempty"`
89111
}
90112

91113
type TransitionRuleWebhook struct {

apps/v1alpha1/zz_generated.deepcopy.go

Lines changed: 57 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/apps/apps.kusionstack.io_collasets.yaml

Lines changed: 101 additions & 33 deletions
Large diffs are not rendered by default.

config/crd/apps/apps.kusionstack.io_poddecorations.yaml

Lines changed: 593 additions & 325 deletions
Large diffs are not rendered by default.

config/crd/apps/apps.kusionstack.io_podtransitionrules.yaml

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,56 @@ spec:
5050
description: AvailablePolicy is the rule to check if the max
5151
unavailable number is reached by current resource updated.
5252
properties:
53+
maxUnavailablePolicy:
54+
description: MaxUnavailablePolicy is an option to apply
55+
max unavailable by adaptive policy.
56+
properties:
57+
expFunc:
58+
description: |-
59+
ExpFunc is an exponentiation expression to calculate the expected value.
60+
func: f(x) = coeff * x ^ pow.
61+
properties:
62+
coeff:
63+
description: Coeff stands for coefficient in this
64+
exponentiation.
65+
type: string
66+
pow:
67+
description: Pow stands for power in this exponentiation.
68+
type: string
69+
type: object
70+
type: object
5371
maxUnavailableValue:
5472
anyOf:
5573
- type: integer
5674
- type: string
5775
description: |-
58-
MaxUnavailableValue is the expected max unavailable replicas which is allowed to be a integer or a percentage of the whole
76+
MaxUnavailableValue is the expected max unavailable replicas which is allowed to be an integer or a percentage of the whole
5977
number of the target resources.
6078
x-kubernetes-int-or-string: true
79+
minAvailablePolicy:
80+
description: MaxUnavailablePolicy is an option to apply
81+
min available by adaptive policy.
82+
properties:
83+
expFunc:
84+
description: |-
85+
ExpFunc is an exponentiation expression to calculate the expected value.
86+
func: f(x) = coeff * x ^ pow.
87+
properties:
88+
coeff:
89+
description: Coeff stands for coefficient in this
90+
exponentiation.
91+
type: string
92+
pow:
93+
description: Pow stands for power in this exponentiation.
94+
type: string
95+
type: object
96+
type: object
6197
minAvailableValue:
6298
anyOf:
6399
- type: integer
64100
- type: string
65101
description: |-
66-
MinAvailableValue is the expected min available replicas which is allowed to be a integer or a percentage of the whole
102+
MinAvailableValue is the expected min available replicas which is allowed to be an integer or a percentage of the whole
67103
number of the target resources.
68104
x-kubernetes-int-or-string: true
69105
type: object

config/crd/rollout/rollout.kusionstack.io_backendroutings.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,22 +2409,7 @@ spec:
24092409
conditions:
24102410
description: Conditions is the list of conditions
24112411
items:
2412-
description: |-
2413-
Condition contains details for one aspect of the current state of this API Resource.
2414-
---
2415-
This struct is intended for direct use as an array at the field path .status.conditions. For example,
2416-
type FooStatus struct{
2417-
// Represents the observations of a foo's current state.
2418-
// Known .status.conditions.type are: "Available", "Progressing", and "Degraded"
2419-
// +patchMergeKey=type
2420-
// +patchStrategy=merge
2421-
// +listType=map
2422-
// +listMapKey=type
2423-
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`
2424-
2425-
2426-
// other fields
2427-
}
2412+
description: "Condition contains details for one aspect of the current state of this API Resource.\n---\nThis struct is intended for direct use as an array at the field path .status.conditions. For example,\n\n\n\ttype FooStatus struct{\n\t // Represents the observations of a foo's current state.\n\t // Known .status.conditions.type are: \"Available\", \"Progressing\", and \"Degraded\"\n\t // +patchMergeKey=type\n\t // +patchStrategy=merge\n\t // +listType=map\n\t // +listMapKey=type\n\t Conditions []metav1.Condition `json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`\n\n\n\t // other fields\n\t}"
24282413
properties:
24292414
lastTransitionTime:
24302415
description: |-

hack/make-rules/install-go-tools.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ install::yq() {
8686
}
8787

8888
install::yamlfmt() {
89-
if test -e "${LOCALBIN_OS_ARCH}"/yq; then
89+
if test -e "${LOCALBIN_OS_ARCH}"/yamlfmt; then
9090
return
9191
fi
9292
log::status "Installing google/yamlfmt"

hack/make-rules/update-manifests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ for dir in apps cluster rollout; do
4040
continue
4141
fi
4242
# Traversal delete x-kubernetes-validations fields in crd yaml
43-
yq -i eval 'del(.. | ."x-kubernetes-validations"?)' "$file"
43+
${ROOT_DIR}/bin/yq -i eval 'del(.. | ."x-kubernetes-validations"?)' "$file"
4444
# delete array indent
45-
yamlfmt -formatter indentless_arrays=true "$file"
45+
${ROOT_DIR}/bin/yamlfmt -formatter indentless_arrays=true "$file"
4646
done
4747
done

rollout/v1alpha1/zz_generated.deepcopy.go

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)