Skip to content

Commit c842190

Browse files
committed
feat: support excluded sync resources
Signed-off-by: KubeKyrie <[email protected]>
1 parent 810c6c4 commit c842190

File tree

7 files changed

+40
-4
lines changed

7 files changed

+40
-4
lines changed

kustomize/crds/cluster.clusterpedia.io_clustersyncresources.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ spec:
3535
syncResources:
3636
items:
3737
properties:
38+
excludedResource:
39+
items:
40+
type: string
41+
type: array
3842
group:
3943
type: string
4044
resources:

kustomize/crds/cluster.clusterpedia.io_pediaclusters.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ spec:
7979
syncResources:
8080
items:
8181
properties:
82+
excludedResource:
83+
items:
84+
type: string
85+
type: array
8286
group:
8387
type: string
8488
resources:

pkg/generated/openapi/zz_generated.openapi.go

+14
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/synchromanager/clustersynchro/cluster_synchro.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,11 @@ type ClusterSynchro struct {
5959
storageResourceVersions map[schema.GroupVersionResource]map[string]interface{}
6060
storageResourceSynchros sync.Map
6161

62-
syncResources atomic.Value // []clusterv1alpha2.ClusterGroupResources
63-
setSyncResourcesCh chan struct{}
64-
resourceNegotiator *ResourceNegotiator
65-
groupResourceStatus atomic.Value // *GroupResourceStatus
62+
syncResources atomic.Value // []clusterv1alpha2.ClusterGroupResources
63+
excludedSyncResources atomic.Value // []clusterv1alpha2.ClusterGroupResources
64+
setSyncResourcesCh chan struct{}
65+
resourceNegotiator *ResourceNegotiator
66+
groupResourceStatus atomic.Value // *GroupResourceStatus
6667

6768
runningCondition atomic.Value // metav1.Condition
6869
healthyCondition atomic.Value // metav1.Condition
@@ -315,6 +316,7 @@ func (s *ClusterSynchro) refreshSyncResources() {
315316
if syncResources == nil {
316317
return
317318
}
319+
318320
groupResourceStatus, storageResourceSyncConfigs := s.resourceNegotiator.NegotiateSyncResources(syncResources)
319321

320322
lastGroupResourceStatus := s.groupResourceStatus.Load().(*GroupResourceStatus)

pkg/synchromanager/clustersynchro/resource_negotiator.go

+4
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,11 @@ func (negotiator *ResourceNegotiator) NegotiateSyncResources(syncResources []clu
8585
var groupResourceStatus = NewGroupResourceStatus()
8686
var storageResourceSyncConfigs = make(map[schema.GroupVersionResource]syncConfig)
8787
for _, groupResources := range syncResources {
88+
excludedResourcesSet := sets.New(groupResources.ExcludedResource...)
8889
for _, resource := range groupResources.Resources {
90+
if excludedResourcesSet.Has(resource) {
91+
continue
92+
}
8993
syncGR := schema.GroupResource{Group: groupResources.Group, Resource: resource}
9094
apiResource, supportedVersions := negotiator.dynamicDiscovery.GetAPIResourceAndVersions(syncGR)
9195
if apiResource == nil || len(supportedVersions) == 0 {

staging/src/github.com/clusterpedia-io/api/cluster/v1alpha2/types.go

+3
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ type ClusterGroupResources struct {
109109
// +kubebuilder:validation:Required
110110
// +kubebuilder:validation:MinItems=1
111111
Resources []string `json:"resources"`
112+
113+
// +optional
114+
ExcludedResource []string `json:"excludedResource"`
112115
}
113116

114117
type ClusterStatus struct {

staging/src/github.com/clusterpedia-io/api/cluster/v1alpha2/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)