make work status sync interval configurable (#1009)

* update api

Signed-off-by: zhujian <jiazhu@redhat.com>

* make work status sync interval configurable

Signed-off-by: zhujian <jiazhu@redhat.com>

* add unit tests

Signed-off-by: zhujian <jiazhu@redhat.com>

* fix flaky e2e tests

Signed-off-by: zhujian <jiazhu@redhat.com>

* drop go mod replace

Signed-off-by: zhujian <jiazhu@redhat.com>

---------

Signed-off-by: zhujian <jiazhu@redhat.com>
This commit is contained in:
Jian Zhu
2025-05-27 15:47:58 +08:00
committed by GitHub
parent f13599ffdb
commit 4d1b4ee8d5
20 changed files with 198 additions and 105 deletions

View File

@@ -264,7 +264,10 @@ spec:
reservedClusterClaimSuffixes:
description: Custom suffixes for reserved ClusterClaims.
items:
maxLength: 64
minLength: 1
type: string
maxItems: 10
type: array
required:
- maxCustomClusterClaims
@@ -486,6 +489,13 @@ spec:
If it is set empty, use the default value: 50
format: int32
type: integer
statusSyncInterval:
description: |-
StatusSyncInterval is the interval for the work agent to check the status of ManifestWorks.
Larger value means less frequent status sync and less api calls to the managed cluster, vice versa.
The value(x) should be: 5s <= x <= 1h.
pattern: ^([0-9]+(s|m|h))+$
type: string
type: object
workImagePullSpec:
description: |-

View File

@@ -193,6 +193,9 @@ type ClusterClaimConfiguration struct {
// Custom suffixes for reserved ClusterClaims.
// +optional
// +kubebuilder:validation:MaxItems=10
// +kubebuilder:validation:items:MinLength=1
// +kubebuilder:validation:items:MaxLength=64
ReservedClusterClaimSuffixes []string `json:"reservedClusterClaimSuffixes,omitempty"`
}
@@ -296,6 +299,14 @@ type WorkAgentConfiguration struct {
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(s|m|h))+$"
AppliedManifestWorkEvictionGracePeriod *metav1.Duration `json:"appliedManifestWorkEvictionGracePeriod,omitempty"`
// StatusSyncInterval is the interval for the work agent to check the status of ManifestWorks.
// Larger value means less frequent status sync and less api calls to the managed cluster, vice versa.
// The value(x) should be: 5s <= x <= 1h.
// +optional
// +kubebuilder:validation:Type=string
// +kubebuilder:validation:Pattern="^([0-9]+(s|m|h))+$"
StatusSyncInterval *metav1.Duration `json:"statusSyncInterval,omitempty"`
}
const (

View File

@@ -780,6 +780,11 @@ func (in *WorkAgentConfiguration) DeepCopyInto(out *WorkAgentConfiguration) {
*out = new(metav1.Duration)
**out = **in
}
if in.StatusSyncInterval != nil {
in, out := &in.StatusSyncInterval, &out.StatusSyncInterval
*out = new(metav1.Duration)
**out = **in
}
return
}

View File

@@ -348,6 +348,7 @@ var map_WorkAgentConfiguration = map[string]string{
"kubeAPIQPS": "KubeAPIQPS indicates the maximum QPS while talking with apiserver of hub cluster from the spoke cluster. If it is set empty, use the default value: 50",
"kubeAPIBurst": "KubeAPIBurst indicates the maximum burst of the throttle while talking with apiserver of hub cluster from the spoke cluster. If it is set empty, use the default value: 100",
"appliedManifestWorkEvictionGracePeriod": "AppliedManifestWorkEvictionGracePeriod is the eviction grace period the work agent will wait before evicting the AppliedManifestWorks, whose corresponding ManifestWorks are missing on the hub cluster, from the managed cluster. If not present, the default value of the work agent will be used.",
"statusSyncInterval": "StatusSyncInterval is the interval for the work agent to check the status of ManifestWorks. Larger value means less frequent status sync and less api calls to the managed cluster, vice versa. The value(x) should be: 5s <= x <= 1h.",
}
func (WorkAgentConfiguration) SwaggerDoc() map[string]string {

View File

@@ -61,6 +61,17 @@ spec:
description: Spec reperesents the desired ManifestWork payload and Placement
reference to be reconciled
properties:
cascadeDeletionPolicy:
default: Background
description: |-
CascadeDeletionPolicy decides the manifestWorkReplicaSet is deleted before/after the related manifestWorks are gone.
Acceptable values are:
'Background'- the manifestWorkReplicaSet is deleted without waiting for the related manifestWorks to be gone.
'Foreground'- the manifestWorkReplicaSet is deleted until the related manifestWorks are gone.
enum:
- Background
- Foreground
type: string
manifestWorkTemplate:
description: ManifestWorkTemplate is the ManifestWorkSpec that will
be used to generate a per-cluster ManifestWork
@@ -581,6 +592,7 @@ spec:
minItems: 1
type: array
required:
- cascadeDeletionPolicy
- placementRefs
type: object
status:

View File

@@ -63,6 +63,16 @@ type ManifestWorkReplicaSetSpec struct {
// +kubebuilder:validation:MinItems=1
// +required
PlacementRefs []LocalPlacementReference `json:"placementRefs"`
// CascadeDeletionPolicy decides the manifestWorkReplicaSet is deleted before/after the related manifestWorks are gone.
// Acceptable values are:
// 'Background'- the manifestWorkReplicaSet is deleted without waiting for the related manifestWorks to be gone.
// 'Foreground'- the manifestWorkReplicaSet is deleted until the related manifestWorks are gone.
// +kubebuilder:default=Background
// +kubebuilder:validation:Enum=Background;Foreground
// +kubebuilder:validation:Required
// +optional
CascadeDeletionPolicy CascadeDeletionPolicy `json:"cascadeDeletionPolicy,omitempty"`
}
// ManifestWorkReplicaSetStatus defines the observed state of ManifestWorkReplicaSet
@@ -172,3 +182,14 @@ const (
// Reason: AsExpected, NotAsExpected or Processing
ManifestWorkReplicaSetConditionManifestworkApplied string = "ManifestworkApplied"
)
// CascadeDeletionPolicy decides the manifestWorkReplicaSet is deleted before/after the related manifestWorks are gone.
type CascadeDeletionPolicy string
const (
// Foreground decides the manifestWorkReplicaSet is deleted until the related manifestWorks are gone.
Foreground CascadeDeletionPolicy = "Foreground"
// Background decides the manifestWorkReplicaSet is deleted without waiting for the related manifestWorks to be gone.
Background CascadeDeletionPolicy = "Background"
)

View File

@@ -39,9 +39,10 @@ func (ManifestWorkReplicaSetList) SwaggerDoc() map[string]string {
}
var map_ManifestWorkReplicaSetSpec = map[string]string{
"": "ManifestWorkReplicaSetSpec defines the desired state of ManifestWorkReplicaSet",
"manifestWorkTemplate": "ManifestWorkTemplate is the ManifestWorkSpec that will be used to generate a per-cluster ManifestWork",
"placementRefs": "PacementRefs is a list of the names of the Placement resource, from which a PlacementDecision will be found and used to distribute the ManifestWork.",
"": "ManifestWorkReplicaSetSpec defines the desired state of ManifestWorkReplicaSet",
"manifestWorkTemplate": "ManifestWorkTemplate is the ManifestWorkSpec that will be used to generate a per-cluster ManifestWork",
"placementRefs": "PacementRefs is a list of the names of the Placement resource, from which a PlacementDecision will be found and used to distribute the ManifestWork.",
"cascadeDeletionPolicy": "CascadeDeletionPolicy decides the manifestWorkReplicaSet is deleted before/after the related manifestWorks are gone. Acceptable values are: 'Background'- the manifestWorkReplicaSet is deleted without waiting for the related manifestWorks to be gone. 'Foreground'- the manifestWorkReplicaSet is deleted until the related manifestWorks are gone.",
}
func (ManifestWorkReplicaSetSpec) SwaggerDoc() map[string]string {