Skip to content

feat: add podtransitionrule available adaptive policy and generate code #40

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

Merged
merged 1 commit into from
Jul 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
26 changes: 24 additions & 2 deletions apps/v1alpha1/podtransitionrule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,35 @@ type LabelCheckRule struct {
}

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

// MinAvailableValue is the expected min available replicas which is allowed to be a integer or a percentage of the whole
// MaxUnavailablePolicy is an option to apply max unavailable by adaptive policy.
// +optional
MaxUnavailablePolicy *AdaptivePolicy `json:"maxUnavailablePolicy,omitempty"`

// MinAvailableValue is the expected min available replicas which is allowed to be an integer or a percentage of the whole
// number of the target resources.
MinAvailableValue *intstr.IntOrString `json:"minAvailableValue,omitempty"`

// MaxUnavailablePolicy is an option to apply min available by adaptive policy.
// +optional
MinAvailablePolicy *AdaptivePolicy `json:"minAvailablePolicy,omitempty"`
}

type AdaptivePolicy struct {
// ExpFunc is an exponentiation expression to calculate the expected value.
// func: f(x) = coeff * x ^ pow.
ExpFunc *ExpFunc `json:"expFunc,omitempty"`
}

type ExpFunc struct {
// Coeff stands for coefficient in this exponentiation.
Coeff *string `json:"coeff,omitempty"`

// Pow stands for power in this exponentiation.
Pow *string `json:"pow,omitempty"`
}

type TransitionRuleWebhook struct {
Expand Down
57 changes: 57 additions & 0 deletions apps/v1alpha1/zz_generated.deepcopy.go

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

134 changes: 101 additions & 33 deletions config/crd/apps/apps.kusionstack.io_collasets.yaml

Large diffs are not rendered by default.

918 changes: 593 additions & 325 deletions config/crd/apps/apps.kusionstack.io_poddecorations.yaml

Large diffs are not rendered by default.

40 changes: 38 additions & 2 deletions config/crd/apps/apps.kusionstack.io_podtransitionrules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,56 @@ spec:
description: AvailablePolicy is the rule to check if the max
unavailable number is reached by current resource updated.
properties:
maxUnavailablePolicy:
description: MaxUnavailablePolicy is an option to apply
max unavailable by adaptive policy.
properties:
expFunc:
description: |-
ExpFunc is an exponentiation expression to calculate the expected value.
func: f(x) = coeff * x ^ pow.
properties:
coeff:
description: Coeff stands for coefficient in this
exponentiation.
type: string
pow:
description: Pow stands for power in this exponentiation.
type: string
type: object
type: object
maxUnavailableValue:
anyOf:
- type: integer
- type: string
description: |-
MaxUnavailableValue is the expected max unavailable replicas which is allowed to be a integer or a percentage of the whole
MaxUnavailableValue is the expected max unavailable replicas which is allowed to be an integer or a percentage of the whole
number of the target resources.
x-kubernetes-int-or-string: true
minAvailablePolicy:
description: MaxUnavailablePolicy is an option to apply
min available by adaptive policy.
properties:
expFunc:
description: |-
ExpFunc is an exponentiation expression to calculate the expected value.
func: f(x) = coeff * x ^ pow.
properties:
coeff:
description: Coeff stands for coefficient in this
exponentiation.
type: string
pow:
description: Pow stands for power in this exponentiation.
type: string
type: object
type: object
minAvailableValue:
anyOf:
- type: integer
- type: string
description: |-
MinAvailableValue is the expected min available replicas which is allowed to be a integer or a percentage of the whole
MinAvailableValue is the expected min available replicas which is allowed to be an integer or a percentage of the whole
number of the target resources.
x-kubernetes-int-or-string: true
type: object
Expand Down
17 changes: 1 addition & 16 deletions config/crd/rollout/rollout.kusionstack.io_backendroutings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2409,22 +2409,7 @@ spec:
conditions:
description: Conditions is the list of conditions
items:
description: |-
Condition contains details for one aspect of the current state of this API Resource.
---
This struct is intended for direct use as an array at the field path .status.conditions. For example,
type FooStatus struct{
// Represents the observations of a foo's current state.
// Known .status.conditions.type are: "Available", "Progressing", and "Degraded"
// +patchMergeKey=type
// +patchStrategy=merge
// +listType=map
// +listMapKey=type
Conditions []metav1.Condition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type" protobuf:"bytes,1,rep,name=conditions"`


// other fields
}
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}"
properties:
lastTransitionTime:
description: |-
Expand Down
2 changes: 1 addition & 1 deletion hack/make-rules/install-go-tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ install::yq() {
}

install::yamlfmt() {
if test -e "${LOCALBIN_OS_ARCH}"/yq; then
if test -e "${LOCALBIN_OS_ARCH}"/yamlfmt; then
return
fi
log::status "Installing google/yamlfmt"
Expand Down
4 changes: 2 additions & 2 deletions hack/make-rules/update-manifests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ for dir in apps cluster rollout; do
continue
fi
# Traversal delete x-kubernetes-validations fields in crd yaml
yq -i eval 'del(.. | ."x-kubernetes-validations"?)' "$file"
${ROOT_DIR}/bin/yq -i eval 'del(.. | ."x-kubernetes-validations"?)' "$file"
# delete array indent
yamlfmt -formatter indentless_arrays=true "$file"
${ROOT_DIR}/bin/yamlfmt -formatter indentless_arrays=true "$file"
done
done
23 changes: 23 additions & 0 deletions rollout/v1alpha1/zz_generated.deepcopy.go

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

Loading