From d5f1abad74a1cd4e2ab1dfd699ec028ad53a9280 Mon Sep 17 00:00:00 2001 From: zhujian Date: Tue, 5 Sep 2023 08:25:37 +0000 Subject: [PATCH] add a helper func for setting agent install namespace from addon deployment config Signed-off-by: zhujian --- cmd/example/helloworld/main.go | 5 + go.mod | 2 +- go.sum | 4 +- pkg/utils/namespace.go | 110 +++++ pkg/utils/namespace_test.go | 216 ++++++++++ test/e2e/helloworld_test.go | 149 ++++++- vendor/modules.txt | 2 +- ...agement.io_addondeploymentconfigs.crd.yaml | 7 + .../v1alpha1/types_addondeploymentconfig.go | 7 + .../zz_generated.swagger_doc_generated.go | 9 +- .../typed/cluster/v1beta1/cluster_client.go | 10 - .../v1beta1/fake/fake_cluster_client.go | 8 - .../v1beta1/fake/fake_managedclusterset.go | 117 ------ .../fake/fake_managedclustersetbinding.go | 126 ------ .../cluster/v1beta1/generated_expansion.go | 4 - .../cluster/v1beta1/managedclusterset.go | 168 -------- .../v1beta1/managedclustersetbinding.go | 179 -------- .../cluster/v1beta1/interface.go | 14 - .../cluster/v1beta1/managedclusterset.go | 73 ---- .../v1beta1/managedclustersetbinding.go | 74 ---- .../informers/externalversions/generic.go | 4 - .../cluster/v1beta1/expansion_generated.go | 12 - .../cluster/v1beta1/managedclusterset.go | 52 --- .../v1beta1/managedclustersetbinding.go | 83 ---- .../api/cluster/v1/types.go | 6 + .../api/cluster/v1alpha1/helpers.go | 382 ++++++++++++++++++ .../cluster/v1alpha1/types_rolloutstrategy.go | 10 +- .../cluster/v1alpha1/zz_generated.deepcopy.go | 55 +++ ...-management.io_managedclustersets.crd.yaml | 207 ---------- ...ment.io_managedclustersetbindings.crd.yaml | 136 ------- ...-cluster-management.io_placements.crd.yaml | 2 - .../api/cluster/v1beta1/helpers.go | 311 ++++++++------ .../api/cluster/v1beta1/register.go | 4 - .../v1beta1/types_managedclusterset.go | 99 ----- .../v1beta1/types_managedclustersetbinding.go | 65 --- .../api/cluster/v1beta1/types_placement.go | 1 - .../cluster/v1beta1/zz_generated.deepcopy.go | 255 ++---------- .../zz_generated.swagger_doc_generated.go | 86 ---- ...-management.io_managedclustersets.crd.yaml | 189 +-------- ...ment.io_managedclustersetbindings.crd.yaml | 107 +---- .../api/work/v1/types.go | 22 +- ...gement.io_manifestworkreplicasets.crd.yaml | 176 +++++++- .../v1alpha1/types_manifestworkreplicaset.go | 34 +- .../work/v1alpha1/zz_generated.deepcopy.go | 27 +- .../zz_generated.swagger_doc_generated.go | 18 +- 45 files changed, 1436 insertions(+), 2191 deletions(-) create mode 100644 pkg/utils/namespace.go create mode 100644 pkg/utils/namespace_test.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclusterset.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclustersetbinding.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclusterset.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclustersetbinding.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclusterset.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclustersetbinding.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclusterset.go delete mode 100644 vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclustersetbinding.go create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/helpers.go delete mode 100644 vendor/open-cluster-management.io/api/cluster/v1beta1/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml delete mode 100644 vendor/open-cluster-management.io/api/cluster/v1beta1/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml delete mode 100644 vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclusterset.go delete mode 100644 vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclustersetbinding.go diff --git a/cmd/example/helloworld/main.go b/cmd/example/helloworld/main.go index 91520a4db..dc2a498ec 100644 --- a/cmd/example/helloworld/main.go +++ b/cmd/example/helloworld/main.go @@ -93,6 +93,11 @@ func runController(ctx context.Context, kubeConfig *rest.Config) error { utilrand.String(5), ) + // Set agent install namespace from addon deployment config if it exists + registrationOption.AgentInstallNamespace = utils.AgentInstallNamespaceFromDeploymentConfig( + addonfactory.NewAddOnDeploymentConfigGetter(addonClient).Get, + ) + agentAddon, err := addonfactory.NewAgentAddonFactory(helloworld.AddonName, helloworld.FS, "manifests/templates"). WithConfigGVRs(utils.AddOnDeploymentConfigGVR). WithGetValuesFuncs( diff --git a/go.mod b/go.mod index 725c1092e..34a70c5fc 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( k8s.io/component-base v0.26.7 k8s.io/klog/v2 v2.80.1 k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 - open-cluster-management.io/api v0.11.1-0.20230731134013-26e75df27f50 + open-cluster-management.io/api v0.11.1-0.20230905055724-cf1ead467a83 sigs.k8s.io/controller-runtime v0.14.4 ) diff --git a/go.sum b/go.sum index 67af566f6..869664fd0 100644 --- a/go.sum +++ b/go.sum @@ -819,8 +819,8 @@ k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280 h1:+70TFaan3hfJzs+7VK2o+O k8s.io/kube-openapi v0.0.0-20221012153701-172d655c2280/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -open-cluster-management.io/api v0.11.1-0.20230731134013-26e75df27f50 h1:njvnCHeYMQvBWjKW97xa2r3A0/tN8H0FI9kL4AeCqVs= -open-cluster-management.io/api v0.11.1-0.20230731134013-26e75df27f50/go.mod h1:WgKUCJ7+Bf40DsOmH1Gdkpyj3joco+QLzrlM6Ak39zE= +open-cluster-management.io/api v0.11.1-0.20230905055724-cf1ead467a83 h1:3zbT3sT/tEAQbpjIk6uRiTQGknQ3kQlfd11ElVuXyyQ= +open-cluster-management.io/api v0.11.1-0.20230905055724-cf1ead467a83/go.mod h1:nsQ/G5JpfjQUg7dHpblyywWC6BRqklNaF6fIswVCHyY= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/pkg/utils/namespace.go b/pkg/utils/namespace.go new file mode 100644 index 000000000..b26fe7a36 --- /dev/null +++ b/pkg/utils/namespace.go @@ -0,0 +1,110 @@ +package utils + +import ( + "context" + "fmt" + + "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" + "k8s.io/apimachinery/pkg/runtime" + utilruntime "k8s.io/apimachinery/pkg/util/runtime" + "k8s.io/klog/v2" + addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" +) + +func AgentInstallNamespaceFromDeploymentConfig( + adcgetter func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error), +) func(*addonapiv1alpha1.ManagedClusterAddOn) string { + return func(addon *addonapiv1alpha1.ManagedClusterAddOn) string { + if addon == nil { + utilruntime.HandleError(fmt.Errorf("failed to get addon template, addon is nil")) + return "" + } + + config, err := GetDesiredAddOnDeploymentConfig(addon, adcgetter) + if err != nil { + utilruntime.HandleError(fmt.Errorf("failed to get addon %s template: %v", addon.Name, err)) + return "" + } + if config == nil { + return "" + } + + return config.Spec.AgentInstallNamespace + } +} + +// GetDesiredAddOnDeployment returns the desired template of the addon +func GetDesiredAddOnDeploymentConfig( + addon *addonapiv1alpha1.ManagedClusterAddOn, + adcgetter func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error), +) (*addonapiv1alpha1.AddOnDeploymentConfig, error) { + + ok, configRef := GetAddonConfigRef(addon.Status.ConfigReferences, + AddOnDeploymentConfigGVR.Group, AddOnDeploymentConfigGVR.Resource) + if !ok { + klog.InfoS("Addon deployment config in status is empty", "addonName", addon.Name) + return nil, nil + } + + desiredConfig := configRef.DesiredConfig + if desiredConfig == nil || len(desiredConfig.SpecHash) == 0 { + klog.InfoS("Addon deployment config spec hash is empty", "addonName", addon.Name) + return nil, fmt.Errorf("addon %s deployment config desired spec hash is empty", addon.Name) + } + + adc, err := adcgetter(context.TODO(), desiredConfig.Namespace, desiredConfig.Name) + if err != nil { + return nil, err + } + + specHash, err := GetAddOnDeploymentConfigSpecHash(adc) + if err != nil { + return nil, err + } + if specHash != desiredConfig.SpecHash { + return nil, fmt.Errorf("addon %s deployment config spec hash %s is not equal to desired spec hash %s", + addon.Name, specHash, desiredConfig.SpecHash) + } + return adc.DeepCopy(), nil +} + +// GetAddOnDeploymentConfigSpecHash returns the sha256 hash of the spec field of the addon deployment config +func GetAddOnDeploymentConfigSpecHash(config *addonapiv1alpha1.AddOnDeploymentConfig) (string, error) { + if config == nil { + return "", fmt.Errorf("addon deployment config is nil") + } + uadc, err := runtime.DefaultUnstructuredConverter.ToUnstructured(config) + if err != nil { + return "", err + } + return GetSpecHash(&unstructured.Unstructured{ + Object: uadc, + }) +} + +// GetAddOnTemplateSpecHash returns the sha256 hash of the spec field of the addon template +func GetAddOnTemplateSpecHash(template *addonapiv1alpha1.AddOnTemplate) (string, error) { + if template == nil { + return "", fmt.Errorf("addon template is nil") + } + uat, err := runtime.DefaultUnstructuredConverter.ToUnstructured(template) + if err != nil { + return "", err + } + return GetSpecHash(&unstructured.Unstructured{ + Object: uat, + }) +} + +// GetAddonConfigRef returns the first addon config ref for the given config type +func GetAddonConfigRef( + configReferences []addonapiv1alpha1.ConfigReference, + group, resource string) (bool, addonapiv1alpha1.ConfigReference) { + + for _, config := range configReferences { + if config.Group == group && config.Resource == resource { + return true, config + } + } + return false, addonapiv1alpha1.ConfigReference{} +} diff --git a/pkg/utils/namespace_test.go b/pkg/utils/namespace_test.go new file mode 100644 index 000000000..6108b7e5f --- /dev/null +++ b/pkg/utils/namespace_test.go @@ -0,0 +1,216 @@ +package utils + +import ( + "context" + "testing" + + "github.com/stretchr/testify/assert" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + addonapiv1alpha1 "open-cluster-management.io/api/addon/v1alpha1" +) + +func TestAgentInstallNamespaceFromDeploymentConfig(t *testing.T) { + + cases := []struct { + name string + getter func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error) + mca *addonapiv1alpha1.ManagedClusterAddOn + expected string + }{ + { + name: "addon is nil", + getter: func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error) { + return &addonapiv1alpha1.AddOnDeploymentConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + }, + Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{}, + }, nil + }, + mca: nil, + expected: "", + }, + { + name: "addon no deployment config reference", + getter: func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error) { + return &addonapiv1alpha1.AddOnDeploymentConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + }, + Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{}, + }, nil + }, + mca: &addonapiv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + Namespace: "cluster1", + }, + Status: addonapiv1alpha1.ManagedClusterAddOnStatus{ + ConfigReferences: []addonapiv1alpha1.ConfigReference{}, + }, + }, + expected: "", + }, + { + name: "addon deployment config reference spec hash empty", + getter: func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error) { + return &addonapiv1alpha1.AddOnDeploymentConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + }, + Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{}, + }, nil + }, + mca: &addonapiv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + Namespace: "cluster1", + }, + Status: addonapiv1alpha1.ManagedClusterAddOnStatus{ + ConfigReferences: []addonapiv1alpha1.ConfigReference{ + { + ConfigGroupResource: addonapiv1alpha1.ConfigGroupResource{ + Group: "addon.open-cluster-management.io", + Resource: "addondeploymentconfigs", + }, + ConfigReferent: addonapiv1alpha1.ConfigReferent{ + Name: "test1", + }, + }, + }, + }, + }, + expected: "", + }, + { + name: "addon deployment config reference spec hash not match", + getter: func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error) { + return &addonapiv1alpha1.AddOnDeploymentConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + }, + Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{ + AgentInstallNamespace: "testns", + }, + }, nil + }, + mca: &addonapiv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + Namespace: "cluster1", + }, + Status: addonapiv1alpha1.ManagedClusterAddOnStatus{ + ConfigReferences: []addonapiv1alpha1.ConfigReference{ + { + ConfigGroupResource: addonapiv1alpha1.ConfigGroupResource{ + Group: "addon.open-cluster-management.io", + Resource: "addondeploymentconfigs", + }, + ConfigReferent: addonapiv1alpha1.ConfigReferent{ + Name: "test1", + }, + DesiredConfig: &addonapiv1alpha1.ConfigSpecHash{ + SpecHash: "wronghash", + }, + }, + }, + }, + }, + expected: "", + }, + { + name: "addon deployment config reference spec hash match", + getter: func(ctx context.Context, namespace, name string) (*addonapiv1alpha1.AddOnDeploymentConfig, error) { + return &addonapiv1alpha1.AddOnDeploymentConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + }, + Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{ + AgentInstallNamespace: "testns", + }, + }, nil + }, + mca: &addonapiv1alpha1.ManagedClusterAddOn{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + Namespace: "cluster1", + }, + Status: addonapiv1alpha1.ManagedClusterAddOnStatus{ + ConfigReferences: []addonapiv1alpha1.ConfigReference{ + { + ConfigGroupResource: addonapiv1alpha1.ConfigGroupResource{ + Group: "addon.open-cluster-management.io", + Resource: "addondeploymentconfigs", + }, + ConfigReferent: addonapiv1alpha1.ConfigReferent{ + Name: "test1", + }, + DesiredConfig: &addonapiv1alpha1.ConfigSpecHash{ + SpecHash: "f97b3f6af1f786ec6f3273e2d6fc8717e45cb7bc9797ba7533663a7de84a5538", + }, + }, + }, + }, + }, + expected: "testns", + }, + } + + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + nsFunc := AgentInstallNamespaceFromDeploymentConfig(c.getter) + ns := nsFunc(c.mca) + assert.Equal(t, c.expected, ns, "should be equal") + }) + } +} + +func TestGetAddOnTemplateSpecHash(t *testing.T) { + cases := []struct { + name string + at *addonapiv1alpha1.AddOnTemplate + expected string + expectedErr string + }{ + { + name: "addon template is nil", + at: nil, + expected: "", + expectedErr: "addon template is nil", + }, + { + name: "addon template spec is nil", + at: &addonapiv1alpha1.AddOnTemplate{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + }, + Spec: addonapiv1alpha1.AddOnTemplateSpec{}, + }, + expected: "aa3e489402ac2e99c4aef0ddc8cc2fdf1d3b6c34c7b8d040dc3fae5db60478cb", + }, + { + name: "addon template spec is not nil", + at: &addonapiv1alpha1.AddOnTemplate{ + ObjectMeta: metav1.ObjectMeta{ + Name: "test1", + }, + Spec: addonapiv1alpha1.AddOnTemplateSpec{ + AddonName: "test1", + }, + }, + expected: "00730aa8aa1826c9a3cfd8d6858b45e1e16bcdade5cc57070ea8089c6764285e", + }, + } + + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + hash, err := GetAddOnTemplateSpecHash(c.at) + if c.expectedErr != "" { + assert.Equal(t, c.expectedErr, err.Error(), "should be equal") + } else { + assert.Nil(t, err, "should be nil") + } + assert.Equal(t, c.expected, hash, "should be equal") + }) + } +} diff --git a/test/e2e/helloworld_test.go b/test/e2e/helloworld_test.go index 6d94f4904..6a956686c 100644 --- a/test/e2e/helloworld_test.go +++ b/test/e2e/helloworld_test.go @@ -22,10 +22,11 @@ const ( ) const ( - addonName = "helloworld" - deployConfigName = "deploy-config" - deployImageOverrideConfigName = "image-override-deploy-config" - deployProxyConfigName = "proxy-deploy-config" + addonName = "helloworld" + deployConfigName = "deploy-config" + deployImageOverrideConfigName = "image-override-deploy-config" + deployProxyConfigName = "proxy-deploy-config" + deployAgentInstallNamespaceConfigName = "agent-install-namespace-deploy-config" ) var ( @@ -44,6 +45,8 @@ var ( HTTPProxy: "http://127.0.0.1:3128", NoProxy: "example.com", } + + agentInstallNamespaceConfig = "test-ns" ) var _ = ginkgo.Describe("install/uninstall helloworld addons", func() { @@ -280,6 +283,104 @@ var _ = ginkgo.Describe("install/uninstall helloworld addons", func() { err = hubAddOnClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Delete(context.Background(), addonName, metav1.DeleteOptions{}) gomega.Expect(err).ToNot(gomega.HaveOccurred()) }) + + ginkgo.It("addon registraion agent install namespace should work", func() { + ginkgo.By("Make sure addon is available") + gomega.Eventually(func() error { + addon, err := hubAddOnClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Get(context.Background(), addonName, metav1.GetOptions{}) + if err != nil { + return err + } + + if !meta.IsStatusConditionTrue(addon.Status.Conditions, "ManifestApplied") { + return fmt.Errorf("addon should be applied to spoke, but get condition %v", addon.Status.Conditions) + } + + if !meta.IsStatusConditionTrue(addon.Status.Conditions, "Available") { + return fmt.Errorf("addon should be available on spoke, but get condition %v", addon.Status.Conditions) + } + + return nil + }, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred()) + + ginkgo.By("Make sure addon is functioning") + configmap := &corev1.ConfigMap{ + ObjectMeta: metav1.ObjectMeta{ + Name: fmt.Sprintf("config-%s", rand.String(6)), + Namespace: managedClusterName, + }, + Data: map[string]string{ + "key1": rand.String(6), + "key2": rand.String(6), + }, + } + + _, err := hubKubeClient.CoreV1().ConfigMaps(managedClusterName).Create(context.Background(), configmap, metav1.CreateOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + + gomega.Eventually(func() error { + copyiedConfig, err := hubKubeClient.CoreV1().ConfigMaps("default").Get(context.Background(), configmap.Name, metav1.GetOptions{}) + if err != nil { + return err + } + + if !apiequality.Semantic.DeepEqual(copyiedConfig.Data, configmap.Data) { + return fmt.Errorf("expected configmap is not correct, %v", copyiedConfig.Data) + } + + return nil + }, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred()) + + ginkgo.By("Prepare a AddOnDeploymentConfig for addon agent install namespace") + gomega.Eventually(func() error { + return prepareAgentInstallNamespaceAddOnDeploymentConfig(managedClusterName) + }, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred()) + + ginkgo.By("Add the configs to ManagedClusterAddOn") + gomega.Eventually(func() error { + addon, err := hubAddOnClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Get( + context.Background(), addonName, metav1.GetOptions{}) + if err != nil { + return err + } + newAddon := addon.DeepCopy() + newAddon.Spec.Configs = []addonapiv1alpha1.AddOnConfig{ + { + ConfigGroupResource: addonapiv1alpha1.ConfigGroupResource{ + Group: "addon.open-cluster-management.io", + Resource: "addondeploymentconfigs", + }, + ConfigReferent: addonapiv1alpha1.ConfigReferent{ + Namespace: managedClusterName, + Name: deployAgentInstallNamespaceConfigName, + }, + }, + } + _, err = hubAddOnClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Update( + context.Background(), newAddon, metav1.UpdateOptions{}) + if err != nil { + return err + } + return nil + }, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred()) + + ginkgo.By("Make sure addon is configured") + gomega.Eventually(func() error { + _, err := hubKubeClient.CoreV1().Secrets(agentInstallNamespaceConfig).Get( + context.Background(), "helloworld-hub-kubeconfig", metav1.GetOptions{}) + if err != nil { + return err + } + + _, err = hubKubeClient.AppsV1().Deployments(agentInstallNamespaceConfig).Get( + context.Background(), "helloworld-agent", metav1.GetOptions{}) + return err + }, eventuallyTimeout, eventuallyInterval).ShouldNot(gomega.HaveOccurred()) + + ginkgo.By("Remove addon") + err = hubAddOnClient.AddonV1alpha1().ManagedClusterAddOns(managedClusterName).Delete(context.Background(), addonName, metav1.DeleteOptions{}) + gomega.Expect(err).ToNot(gomega.HaveOccurred()) + }) }) func prepareAddOnDeploymentConfig(namespace string) error { @@ -307,11 +408,7 @@ func prepareAddOnDeploymentConfig(namespace string) error { return nil } - if err != nil { - return err - } - - return nil + return err } func prepareImageOverrideAddOnDeploymentConfig(namespace string) error { @@ -337,11 +434,7 @@ func prepareImageOverrideAddOnDeploymentConfig(namespace string) error { return nil } - if err != nil { - return err - } - - return nil + return err } func prepareProxyConfigAddOnDeploymentConfig(namespace string) error { @@ -366,9 +459,31 @@ func prepareProxyConfigAddOnDeploymentConfig(namespace string) error { return nil } - if err != nil { - return err + return err +} + +func prepareAgentInstallNamespaceAddOnDeploymentConfig(namespace string) error { + _, err := hubAddOnClient.AddonV1alpha1().AddOnDeploymentConfigs(namespace).Get( + context.Background(), deployAgentInstallNamespaceConfigName, metav1.GetOptions{}) + if errors.IsNotFound(err) { + if _, err := hubAddOnClient.AddonV1alpha1().AddOnDeploymentConfigs(managedClusterName).Create( + context.Background(), + &addonapiv1alpha1.AddOnDeploymentConfig{ + ObjectMeta: metav1.ObjectMeta{ + Name: deployAgentInstallNamespaceConfigName, + Namespace: namespace, + }, + Spec: addonapiv1alpha1.AddOnDeploymentConfigSpec{ + AgentInstallNamespace: agentInstallNamespaceConfig, + }, + }, + metav1.CreateOptions{}, + ); err != nil { + return err + } + + return nil } - return nil + return err } diff --git a/vendor/modules.txt b/vendor/modules.txt index fc62d2f6d..d2a9aaa74 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1226,7 +1226,7 @@ k8s.io/utils/path k8s.io/utils/pointer k8s.io/utils/strings/slices k8s.io/utils/trace -# open-cluster-management.io/api v0.11.1-0.20230731134013-26e75df27f50 +# open-cluster-management.io/api v0.11.1-0.20230905055724-cf1ead467a83 ## explicit; go 1.19 open-cluster-management.io/api/addon/v1alpha1 open-cluster-management.io/api/client/addon/clientset/versioned diff --git a/vendor/open-cluster-management.io/api/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml b/vendor/open-cluster-management.io/api/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml index e50c2437e..69709fbd5 100644 --- a/vendor/open-cluster-management.io/api/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml +++ b/vendor/open-cluster-management.io/api/addon/v1alpha1/0000_02_addon.open-cluster-management.io_addondeploymentconfigs.crd.yaml @@ -33,6 +33,13 @@ spec: spec: description: spec represents a desired configuration for an add-on. properties: + agentInstallNamespace: + default: open-cluster-management-agent-addon + description: AgentInstallNamespace is the namespace where the add-on + agent should be installed on the managed cluster. + maxLength: 63 + pattern: ^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + type: string customizedVariables: description: CustomizedVariables is a list of name-value variables for the current add-on deployment. The add-on implementation can diff --git a/vendor/open-cluster-management.io/api/addon/v1alpha1/types_addondeploymentconfig.go b/vendor/open-cluster-management.io/api/addon/v1alpha1/types_addondeploymentconfig.go index f2fe2c5e2..b72ac3a4c 100644 --- a/vendor/open-cluster-management.io/api/addon/v1alpha1/types_addondeploymentconfig.go +++ b/vendor/open-cluster-management.io/api/addon/v1alpha1/types_addondeploymentconfig.go @@ -50,6 +50,13 @@ type AddOnDeploymentConfigSpec struct { // Empty means no proxy settings is available. // +optional ProxyConfig ProxyConfig `json:"proxyConfig,omitempty"` + + // AgentInstallNamespace is the namespace where the add-on agent should be installed on the managed cluster. + // +optional + // +kubebuilder:default=open-cluster-management-agent-addon + // +kubebuilder:validation:MaxLength=63 + // +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?$ + AgentInstallNamespace string `json:"agentInstallNamespace,omitempty"` } // CustomizedVariable represents a customized variable for add-on deployment. diff --git a/vendor/open-cluster-management.io/api/addon/v1alpha1/zz_generated.swagger_doc_generated.go b/vendor/open-cluster-management.io/api/addon/v1alpha1/zz_generated.swagger_doc_generated.go index fd7b2c2b0..2d004eecc 100644 --- a/vendor/open-cluster-management.io/api/addon/v1alpha1/zz_generated.swagger_doc_generated.go +++ b/vendor/open-cluster-management.io/api/addon/v1alpha1/zz_generated.swagger_doc_generated.go @@ -31,10 +31,11 @@ func (AddOnDeploymentConfigList) SwaggerDoc() map[string]string { } var map_AddOnDeploymentConfigSpec = map[string]string{ - "customizedVariables": "CustomizedVariables is a list of name-value variables for the current add-on deployment. The add-on implementation can use these variables to render its add-on deployment. The default is an empty list.", - "nodePlacement": "NodePlacement enables explicit control over the scheduling of the add-on agents on the managed cluster. All add-on agent pods are expected to comply with this node placement. If the placement is nil, the placement is not specified, it will be omitted. If the placement is an empty object, the placement will match all nodes and tolerate nothing.", - "registries": "Registries describes how to override images used by the addon agent on the managed cluster. the following example will override image \"quay.io/open-cluster-management/addon-agent\" to \"quay.io/ocm/addon-agent\" when deploying the addon agent\n\nregistries:\n - source: quay.io/open-cluster-management/addon-agent\n mirror: quay.io/ocm/addon-agent", - "proxyConfig": "ProxyConfig holds proxy settings for add-on agent on the managed cluster. Empty means no proxy settings is available.", + "customizedVariables": "CustomizedVariables is a list of name-value variables for the current add-on deployment. The add-on implementation can use these variables to render its add-on deployment. The default is an empty list.", + "nodePlacement": "NodePlacement enables explicit control over the scheduling of the add-on agents on the managed cluster. All add-on agent pods are expected to comply with this node placement. If the placement is nil, the placement is not specified, it will be omitted. If the placement is an empty object, the placement will match all nodes and tolerate nothing.", + "registries": "Registries describes how to override images used by the addon agent on the managed cluster. the following example will override image \"quay.io/open-cluster-management/addon-agent\" to \"quay.io/ocm/addon-agent\" when deploying the addon agent\n\nregistries:\n - source: quay.io/open-cluster-management/addon-agent\n mirror: quay.io/ocm/addon-agent", + "proxyConfig": "ProxyConfig holds proxy settings for add-on agent on the managed cluster. Empty means no proxy settings is available.", + "agentInstallNamespace": "AgentInstallNamespace is the namespace where the add-on agent should be installed on the managed cluster.", } func (AddOnDeploymentConfigSpec) SwaggerDoc() map[string]string { diff --git a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/cluster_client.go b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/cluster_client.go index 552027b3d..42dae5bdd 100644 --- a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/cluster_client.go +++ b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/cluster_client.go @@ -12,8 +12,6 @@ import ( type ClusterV1beta1Interface interface { RESTClient() rest.Interface - ManagedClusterSetsGetter - ManagedClusterSetBindingsGetter PlacementsGetter PlacementDecisionsGetter } @@ -23,14 +21,6 @@ type ClusterV1beta1Client struct { restClient rest.Interface } -func (c *ClusterV1beta1Client) ManagedClusterSets() ManagedClusterSetInterface { - return newManagedClusterSets(c) -} - -func (c *ClusterV1beta1Client) ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingInterface { - return newManagedClusterSetBindings(c, namespace) -} - func (c *ClusterV1beta1Client) Placements(namespace string) PlacementInterface { return newPlacements(c, namespace) } diff --git a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_cluster_client.go b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_cluster_client.go index 5bd66bb8e..d96dad67f 100644 --- a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_cluster_client.go +++ b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_cluster_client.go @@ -12,14 +12,6 @@ type FakeClusterV1beta1 struct { *testing.Fake } -func (c *FakeClusterV1beta1) ManagedClusterSets() v1beta1.ManagedClusterSetInterface { - return &FakeManagedClusterSets{c} -} - -func (c *FakeClusterV1beta1) ManagedClusterSetBindings(namespace string) v1beta1.ManagedClusterSetBindingInterface { - return &FakeManagedClusterSetBindings{c, namespace} -} - func (c *FakeClusterV1beta1) Placements(namespace string) v1beta1.PlacementInterface { return &FakePlacements{c, namespace} } diff --git a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclusterset.go b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclusterset.go deleted file mode 100644 index 35ddbfed9..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclusterset.go +++ /dev/null @@ -1,117 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// FakeManagedClusterSets implements ManagedClusterSetInterface -type FakeManagedClusterSets struct { - Fake *FakeClusterV1beta1 -} - -var managedclustersetsResource = schema.GroupVersionResource{Group: "cluster.open-cluster-management.io", Version: "v1beta1", Resource: "managedclustersets"} - -var managedclustersetsKind = schema.GroupVersionKind{Group: "cluster.open-cluster-management.io", Version: "v1beta1", Kind: "ManagedClusterSet"} - -// Get takes name of the managedClusterSet, and returns the corresponding managedClusterSet object, and an error if there is any. -func (c *FakeManagedClusterSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ManagedClusterSet, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootGetAction(managedclustersetsResource, name), &v1beta1.ManagedClusterSet{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSet), err -} - -// List takes label and field selectors, and returns the list of ManagedClusterSets that match those selectors. -func (c *FakeManagedClusterSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ManagedClusterSetList, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootListAction(managedclustersetsResource, managedclustersetsKind, opts), &v1beta1.ManagedClusterSetList{}) - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.ManagedClusterSetList{ListMeta: obj.(*v1beta1.ManagedClusterSetList).ListMeta} - for _, item := range obj.(*v1beta1.ManagedClusterSetList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested managedClusterSets. -func (c *FakeManagedClusterSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewRootWatchAction(managedclustersetsResource, opts)) -} - -// Create takes the representation of a managedClusterSet and creates it. Returns the server's representation of the managedClusterSet, and an error, if there is any. -func (c *FakeManagedClusterSets) Create(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.CreateOptions) (result *v1beta1.ManagedClusterSet, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootCreateAction(managedclustersetsResource, managedClusterSet), &v1beta1.ManagedClusterSet{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSet), err -} - -// Update takes the representation of a managedClusterSet and updates it. Returns the server's representation of the managedClusterSet, and an error, if there is any. -func (c *FakeManagedClusterSets) Update(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterSet, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateAction(managedclustersetsResource, managedClusterSet), &v1beta1.ManagedClusterSet{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSet), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeManagedClusterSets) UpdateStatus(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.UpdateOptions) (*v1beta1.ManagedClusterSet, error) { - obj, err := c.Fake. - Invokes(testing.NewRootUpdateSubresourceAction(managedclustersetsResource, "status", managedClusterSet), &v1beta1.ManagedClusterSet{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSet), err -} - -// Delete takes name of the managedClusterSet and deletes it. Returns an error if one occurs. -func (c *FakeManagedClusterSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewRootDeleteActionWithOptions(managedclustersetsResource, name, opts), &v1beta1.ManagedClusterSet{}) - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeManagedClusterSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewRootDeleteCollectionAction(managedclustersetsResource, listOpts) - - _, err := c.Fake.Invokes(action, &v1beta1.ManagedClusterSetList{}) - return err -} - -// Patch applies the patch and returns the patched managedClusterSet. -func (c *FakeManagedClusterSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterSet, err error) { - obj, err := c.Fake. - Invokes(testing.NewRootPatchSubresourceAction(managedclustersetsResource, name, pt, data, subresources...), &v1beta1.ManagedClusterSet{}) - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSet), err -} diff --git a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclustersetbinding.go b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclustersetbinding.go deleted file mode 100644 index 7b1cf5929..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/fake/fake_managedclustersetbinding.go +++ /dev/null @@ -1,126 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -package fake - -import ( - "context" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - labels "k8s.io/apimachinery/pkg/labels" - schema "k8s.io/apimachinery/pkg/runtime/schema" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - testing "k8s.io/client-go/testing" - v1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// FakeManagedClusterSetBindings implements ManagedClusterSetBindingInterface -type FakeManagedClusterSetBindings struct { - Fake *FakeClusterV1beta1 - ns string -} - -var managedclustersetbindingsResource = schema.GroupVersionResource{Group: "cluster.open-cluster-management.io", Version: "v1beta1", Resource: "managedclustersetbindings"} - -var managedclustersetbindingsKind = schema.GroupVersionKind{Group: "cluster.open-cluster-management.io", Version: "v1beta1", Kind: "ManagedClusterSetBinding"} - -// Get takes name of the managedClusterSetBinding, and returns the corresponding managedClusterSetBinding object, and an error if there is any. -func (c *FakeManagedClusterSetBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ManagedClusterSetBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewGetAction(managedclustersetbindingsResource, c.ns, name), &v1beta1.ManagedClusterSetBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSetBinding), err -} - -// List takes label and field selectors, and returns the list of ManagedClusterSetBindings that match those selectors. -func (c *FakeManagedClusterSetBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ManagedClusterSetBindingList, err error) { - obj, err := c.Fake. - Invokes(testing.NewListAction(managedclustersetbindingsResource, managedclustersetbindingsKind, c.ns, opts), &v1beta1.ManagedClusterSetBindingList{}) - - if obj == nil { - return nil, err - } - - label, _, _ := testing.ExtractFromListOptions(opts) - if label == nil { - label = labels.Everything() - } - list := &v1beta1.ManagedClusterSetBindingList{ListMeta: obj.(*v1beta1.ManagedClusterSetBindingList).ListMeta} - for _, item := range obj.(*v1beta1.ManagedClusterSetBindingList).Items { - if label.Matches(labels.Set(item.Labels)) { - list.Items = append(list.Items, item) - } - } - return list, err -} - -// Watch returns a watch.Interface that watches the requested managedClusterSetBindings. -func (c *FakeManagedClusterSetBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - return c.Fake. - InvokesWatch(testing.NewWatchAction(managedclustersetbindingsResource, c.ns, opts)) - -} - -// Create takes the representation of a managedClusterSetBinding and creates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any. -func (c *FakeManagedClusterSetBindings) Create(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.CreateOptions) (result *v1beta1.ManagedClusterSetBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewCreateAction(managedclustersetbindingsResource, c.ns, managedClusterSetBinding), &v1beta1.ManagedClusterSetBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSetBinding), err -} - -// Update takes the representation of a managedClusterSetBinding and updates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any. -func (c *FakeManagedClusterSetBindings) Update(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterSetBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateAction(managedclustersetbindingsResource, c.ns, managedClusterSetBinding), &v1beta1.ManagedClusterSetBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSetBinding), err -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *FakeManagedClusterSetBindings) UpdateStatus(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.UpdateOptions) (*v1beta1.ManagedClusterSetBinding, error) { - obj, err := c.Fake. - Invokes(testing.NewUpdateSubresourceAction(managedclustersetbindingsResource, "status", c.ns, managedClusterSetBinding), &v1beta1.ManagedClusterSetBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSetBinding), err -} - -// Delete takes name of the managedClusterSetBinding and deletes it. Returns an error if one occurs. -func (c *FakeManagedClusterSetBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - _, err := c.Fake. - Invokes(testing.NewDeleteActionWithOptions(managedclustersetbindingsResource, c.ns, name, opts), &v1beta1.ManagedClusterSetBinding{}) - - return err -} - -// DeleteCollection deletes a collection of objects. -func (c *FakeManagedClusterSetBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - action := testing.NewDeleteCollectionAction(managedclustersetbindingsResource, c.ns, listOpts) - - _, err := c.Fake.Invokes(action, &v1beta1.ManagedClusterSetBindingList{}) - return err -} - -// Patch applies the patch and returns the patched managedClusterSetBinding. -func (c *FakeManagedClusterSetBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterSetBinding, err error) { - obj, err := c.Fake. - Invokes(testing.NewPatchSubresourceAction(managedclustersetbindingsResource, c.ns, name, pt, data, subresources...), &v1beta1.ManagedClusterSetBinding{}) - - if obj == nil { - return nil, err - } - return obj.(*v1beta1.ManagedClusterSetBinding), err -} diff --git a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/generated_expansion.go b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/generated_expansion.go index a514c2160..701affa7d 100644 --- a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/generated_expansion.go +++ b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/generated_expansion.go @@ -2,10 +2,6 @@ package v1beta1 -type ManagedClusterSetExpansion interface{} - -type ManagedClusterSetBindingExpansion interface{} - type PlacementExpansion interface{} type PlacementDecisionExpansion interface{} diff --git a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclusterset.go b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclusterset.go deleted file mode 100644 index 55fafd650..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclusterset.go +++ /dev/null @@ -1,168 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "context" - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - scheme "open-cluster-management.io/api/client/cluster/clientset/versioned/scheme" - v1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// ManagedClusterSetsGetter has a method to return a ManagedClusterSetInterface. -// A group's client should implement this interface. -type ManagedClusterSetsGetter interface { - ManagedClusterSets() ManagedClusterSetInterface -} - -// ManagedClusterSetInterface has methods to work with ManagedClusterSet resources. -type ManagedClusterSetInterface interface { - Create(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.CreateOptions) (*v1beta1.ManagedClusterSet, error) - Update(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.UpdateOptions) (*v1beta1.ManagedClusterSet, error) - UpdateStatus(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.UpdateOptions) (*v1beta1.ManagedClusterSet, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.ManagedClusterSet, error) - List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ManagedClusterSetList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterSet, err error) - ManagedClusterSetExpansion -} - -// managedClusterSets implements ManagedClusterSetInterface -type managedClusterSets struct { - client rest.Interface -} - -// newManagedClusterSets returns a ManagedClusterSets -func newManagedClusterSets(c *ClusterV1beta1Client) *managedClusterSets { - return &managedClusterSets{ - client: c.RESTClient(), - } -} - -// Get takes name of the managedClusterSet, and returns the corresponding managedClusterSet object, and an error if there is any. -func (c *managedClusterSets) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ManagedClusterSet, err error) { - result = &v1beta1.ManagedClusterSet{} - err = c.client.Get(). - Resource("managedclustersets"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ManagedClusterSets that match those selectors. -func (c *managedClusterSets) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ManagedClusterSetList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.ManagedClusterSetList{} - err = c.client.Get(). - Resource("managedclustersets"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested managedClusterSets. -func (c *managedClusterSets) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Resource("managedclustersets"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a managedClusterSet and creates it. Returns the server's representation of the managedClusterSet, and an error, if there is any. -func (c *managedClusterSets) Create(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.CreateOptions) (result *v1beta1.ManagedClusterSet, err error) { - result = &v1beta1.ManagedClusterSet{} - err = c.client.Post(). - Resource("managedclustersets"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(managedClusterSet). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a managedClusterSet and updates it. Returns the server's representation of the managedClusterSet, and an error, if there is any. -func (c *managedClusterSets) Update(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterSet, err error) { - result = &v1beta1.ManagedClusterSet{} - err = c.client.Put(). - Resource("managedclustersets"). - Name(managedClusterSet.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(managedClusterSet). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *managedClusterSets) UpdateStatus(ctx context.Context, managedClusterSet *v1beta1.ManagedClusterSet, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterSet, err error) { - result = &v1beta1.ManagedClusterSet{} - err = c.client.Put(). - Resource("managedclustersets"). - Name(managedClusterSet.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(managedClusterSet). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the managedClusterSet and deletes it. Returns an error if one occurs. -func (c *managedClusterSets) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Resource("managedclustersets"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *managedClusterSets) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Resource("managedclustersets"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched managedClusterSet. -func (c *managedClusterSets) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterSet, err error) { - result = &v1beta1.ManagedClusterSet{} - err = c.client.Patch(pt). - Resource("managedclustersets"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclustersetbinding.go b/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclustersetbinding.go deleted file mode 100644 index 9f81b120f..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/clientset/versioned/typed/cluster/v1beta1/managedclustersetbinding.go +++ /dev/null @@ -1,179 +0,0 @@ -// Code generated by client-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "context" - "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - types "k8s.io/apimachinery/pkg/types" - watch "k8s.io/apimachinery/pkg/watch" - rest "k8s.io/client-go/rest" - scheme "open-cluster-management.io/api/client/cluster/clientset/versioned/scheme" - v1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// ManagedClusterSetBindingsGetter has a method to return a ManagedClusterSetBindingInterface. -// A group's client should implement this interface. -type ManagedClusterSetBindingsGetter interface { - ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingInterface -} - -// ManagedClusterSetBindingInterface has methods to work with ManagedClusterSetBinding resources. -type ManagedClusterSetBindingInterface interface { - Create(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.CreateOptions) (*v1beta1.ManagedClusterSetBinding, error) - Update(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.UpdateOptions) (*v1beta1.ManagedClusterSetBinding, error) - UpdateStatus(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.UpdateOptions) (*v1beta1.ManagedClusterSetBinding, error) - Delete(ctx context.Context, name string, opts v1.DeleteOptions) error - DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error - Get(ctx context.Context, name string, opts v1.GetOptions) (*v1beta1.ManagedClusterSetBinding, error) - List(ctx context.Context, opts v1.ListOptions) (*v1beta1.ManagedClusterSetBindingList, error) - Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) - Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterSetBinding, err error) - ManagedClusterSetBindingExpansion -} - -// managedClusterSetBindings implements ManagedClusterSetBindingInterface -type managedClusterSetBindings struct { - client rest.Interface - ns string -} - -// newManagedClusterSetBindings returns a ManagedClusterSetBindings -func newManagedClusterSetBindings(c *ClusterV1beta1Client, namespace string) *managedClusterSetBindings { - return &managedClusterSetBindings{ - client: c.RESTClient(), - ns: namespace, - } -} - -// Get takes name of the managedClusterSetBinding, and returns the corresponding managedClusterSetBinding object, and an error if there is any. -func (c *managedClusterSetBindings) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1beta1.ManagedClusterSetBinding, err error) { - result = &v1beta1.ManagedClusterSetBinding{} - err = c.client.Get(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - Name(name). - VersionedParams(&options, scheme.ParameterCodec). - Do(ctx). - Into(result) - return -} - -// List takes label and field selectors, and returns the list of ManagedClusterSetBindings that match those selectors. -func (c *managedClusterSetBindings) List(ctx context.Context, opts v1.ListOptions) (result *v1beta1.ManagedClusterSetBindingList, err error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - result = &v1beta1.ManagedClusterSetBindingList{} - err = c.client.Get(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Do(ctx). - Into(result) - return -} - -// Watch returns a watch.Interface that watches the requested managedClusterSetBindings. -func (c *managedClusterSetBindings) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { - var timeout time.Duration - if opts.TimeoutSeconds != nil { - timeout = time.Duration(*opts.TimeoutSeconds) * time.Second - } - opts.Watch = true - return c.client.Get(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Timeout(timeout). - Watch(ctx) -} - -// Create takes the representation of a managedClusterSetBinding and creates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any. -func (c *managedClusterSetBindings) Create(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.CreateOptions) (result *v1beta1.ManagedClusterSetBinding, err error) { - result = &v1beta1.ManagedClusterSetBinding{} - err = c.client.Post(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(managedClusterSetBinding). - Do(ctx). - Into(result) - return -} - -// Update takes the representation of a managedClusterSetBinding and updates it. Returns the server's representation of the managedClusterSetBinding, and an error, if there is any. -func (c *managedClusterSetBindings) Update(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterSetBinding, err error) { - result = &v1beta1.ManagedClusterSetBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - Name(managedClusterSetBinding.Name). - VersionedParams(&opts, scheme.ParameterCodec). - Body(managedClusterSetBinding). - Do(ctx). - Into(result) - return -} - -// UpdateStatus was generated because the type contains a Status member. -// Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). -func (c *managedClusterSetBindings) UpdateStatus(ctx context.Context, managedClusterSetBinding *v1beta1.ManagedClusterSetBinding, opts v1.UpdateOptions) (result *v1beta1.ManagedClusterSetBinding, err error) { - result = &v1beta1.ManagedClusterSetBinding{} - err = c.client.Put(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - Name(managedClusterSetBinding.Name). - SubResource("status"). - VersionedParams(&opts, scheme.ParameterCodec). - Body(managedClusterSetBinding). - Do(ctx). - Into(result) - return -} - -// Delete takes name of the managedClusterSetBinding and deletes it. Returns an error if one occurs. -func (c *managedClusterSetBindings) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error { - return c.client.Delete(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - Name(name). - Body(&opts). - Do(ctx). - Error() -} - -// DeleteCollection deletes a collection of objects. -func (c *managedClusterSetBindings) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error { - var timeout time.Duration - if listOpts.TimeoutSeconds != nil { - timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second - } - return c.client.Delete(). - Namespace(c.ns). - Resource("managedclustersetbindings"). - VersionedParams(&listOpts, scheme.ParameterCodec). - Timeout(timeout). - Body(&opts). - Do(ctx). - Error() -} - -// Patch applies the patch and returns the patched managedClusterSetBinding. -func (c *managedClusterSetBindings) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1beta1.ManagedClusterSetBinding, err error) { - result = &v1beta1.ManagedClusterSetBinding{} - err = c.client.Patch(pt). - Namespace(c.ns). - Resource("managedclustersetbindings"). - Name(name). - SubResource(subresources...). - VersionedParams(&opts, scheme.ParameterCodec). - Body(data). - Do(ctx). - Into(result) - return -} diff --git a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/interface.go b/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/interface.go index 24ee82fb5..e64212692 100644 --- a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/interface.go +++ b/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/interface.go @@ -8,10 +8,6 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { - // ManagedClusterSets returns a ManagedClusterSetInformer. - ManagedClusterSets() ManagedClusterSetInformer - // ManagedClusterSetBindings returns a ManagedClusterSetBindingInformer. - ManagedClusterSetBindings() ManagedClusterSetBindingInformer // Placements returns a PlacementInformer. Placements() PlacementInformer // PlacementDecisions returns a PlacementDecisionInformer. @@ -29,16 +25,6 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } -// ManagedClusterSets returns a ManagedClusterSetInformer. -func (v *version) ManagedClusterSets() ManagedClusterSetInformer { - return &managedClusterSetInformer{factory: v.factory, tweakListOptions: v.tweakListOptions} -} - -// ManagedClusterSetBindings returns a ManagedClusterSetBindingInformer. -func (v *version) ManagedClusterSetBindings() ManagedClusterSetBindingInformer { - return &managedClusterSetBindingInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} -} - // Placements returns a PlacementInformer. func (v *version) Placements() PlacementInformer { return &placementInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclusterset.go b/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclusterset.go deleted file mode 100644 index 237b058dc..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclusterset.go +++ /dev/null @@ -1,73 +0,0 @@ -// Code generated by informer-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "context" - time "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" - versioned "open-cluster-management.io/api/client/cluster/clientset/versioned" - internalinterfaces "open-cluster-management.io/api/client/cluster/informers/externalversions/internalinterfaces" - v1beta1 "open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1" - clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// ManagedClusterSetInformer provides access to a shared informer and lister for -// ManagedClusterSets. -type ManagedClusterSetInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1beta1.ManagedClusterSetLister -} - -type managedClusterSetInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc -} - -// NewManagedClusterSetInformer constructs a new informer for ManagedClusterSet type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewManagedClusterSetInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredManagedClusterSetInformer(client, resyncPeriod, indexers, nil) -} - -// NewFilteredManagedClusterSetInformer constructs a new informer for ManagedClusterSet type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredManagedClusterSetInformer(client versioned.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ClusterV1beta1().ManagedClusterSets().List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ClusterV1beta1().ManagedClusterSets().Watch(context.TODO(), options) - }, - }, - &clusterv1beta1.ManagedClusterSet{}, - resyncPeriod, - indexers, - ) -} - -func (f *managedClusterSetInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredManagedClusterSetInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *managedClusterSetInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&clusterv1beta1.ManagedClusterSet{}, f.defaultInformer) -} - -func (f *managedClusterSetInformer) Lister() v1beta1.ManagedClusterSetLister { - return v1beta1.NewManagedClusterSetLister(f.Informer().GetIndexer()) -} diff --git a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclustersetbinding.go b/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclustersetbinding.go deleted file mode 100644 index b552b5a30..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/cluster/v1beta1/managedclustersetbinding.go +++ /dev/null @@ -1,74 +0,0 @@ -// Code generated by informer-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "context" - time "time" - - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" - runtime "k8s.io/apimachinery/pkg/runtime" - watch "k8s.io/apimachinery/pkg/watch" - cache "k8s.io/client-go/tools/cache" - versioned "open-cluster-management.io/api/client/cluster/clientset/versioned" - internalinterfaces "open-cluster-management.io/api/client/cluster/informers/externalversions/internalinterfaces" - v1beta1 "open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1" - clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// ManagedClusterSetBindingInformer provides access to a shared informer and lister for -// ManagedClusterSetBindings. -type ManagedClusterSetBindingInformer interface { - Informer() cache.SharedIndexInformer - Lister() v1beta1.ManagedClusterSetBindingLister -} - -type managedClusterSetBindingInformer struct { - factory internalinterfaces.SharedInformerFactory - tweakListOptions internalinterfaces.TweakListOptionsFunc - namespace string -} - -// NewManagedClusterSetBindingInformer constructs a new informer for ManagedClusterSetBinding type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewManagedClusterSetBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { - return NewFilteredManagedClusterSetBindingInformer(client, namespace, resyncPeriod, indexers, nil) -} - -// NewFilteredManagedClusterSetBindingInformer constructs a new informer for ManagedClusterSetBinding type. -// Always prefer using an informer factory to get a shared informer instead of getting an independent -// one. This reduces memory footprint and number of connections to the server. -func NewFilteredManagedClusterSetBindingInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { - return cache.NewSharedIndexInformer( - &cache.ListWatch{ - ListFunc: func(options v1.ListOptions) (runtime.Object, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ClusterV1beta1().ManagedClusterSetBindings(namespace).List(context.TODO(), options) - }, - WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { - if tweakListOptions != nil { - tweakListOptions(&options) - } - return client.ClusterV1beta1().ManagedClusterSetBindings(namespace).Watch(context.TODO(), options) - }, - }, - &clusterv1beta1.ManagedClusterSetBinding{}, - resyncPeriod, - indexers, - ) -} - -func (f *managedClusterSetBindingInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { - return NewFilteredManagedClusterSetBindingInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) -} - -func (f *managedClusterSetBindingInformer) Informer() cache.SharedIndexInformer { - return f.factory.InformerFor(&clusterv1beta1.ManagedClusterSetBinding{}, f.defaultInformer) -} - -func (f *managedClusterSetBindingInformer) Lister() v1beta1.ManagedClusterSetBindingLister { - return v1beta1.NewManagedClusterSetBindingLister(f.Informer().GetIndexer()) -} diff --git a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/generic.go b/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/generic.go index 6956a771d..a6ccc7332 100644 --- a/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/generic.go +++ b/vendor/open-cluster-management.io/api/client/cluster/informers/externalversions/generic.go @@ -50,10 +50,6 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1alpha1().ClusterClaims().Informer()}, nil // Group=cluster.open-cluster-management.io, Version=v1beta1 - case v1beta1.SchemeGroupVersion.WithResource("managedclustersets"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1beta1().ManagedClusterSets().Informer()}, nil - case v1beta1.SchemeGroupVersion.WithResource("managedclustersetbindings"): - return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1beta1().ManagedClusterSetBindings().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("placements"): return &genericInformer{resource: resource.GroupResource(), informer: f.Cluster().V1beta1().Placements().Informer()}, nil case v1beta1.SchemeGroupVersion.WithResource("placementdecisions"): diff --git a/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/expansion_generated.go b/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/expansion_generated.go index c90981a28..376343dc2 100644 --- a/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/expansion_generated.go +++ b/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/expansion_generated.go @@ -2,18 +2,6 @@ package v1beta1 -// ManagedClusterSetListerExpansion allows custom methods to be added to -// ManagedClusterSetLister. -type ManagedClusterSetListerExpansion interface{} - -// ManagedClusterSetBindingListerExpansion allows custom methods to be added to -// ManagedClusterSetBindingLister. -type ManagedClusterSetBindingListerExpansion interface{} - -// ManagedClusterSetBindingNamespaceListerExpansion allows custom methods to be added to -// ManagedClusterSetBindingNamespaceLister. -type ManagedClusterSetBindingNamespaceListerExpansion interface{} - // PlacementListerExpansion allows custom methods to be added to // PlacementLister. type PlacementListerExpansion interface{} diff --git a/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclusterset.go b/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclusterset.go deleted file mode 100644 index 331aa59b4..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclusterset.go +++ /dev/null @@ -1,52 +0,0 @@ -// Code generated by lister-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" - v1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// ManagedClusterSetLister helps list ManagedClusterSets. -// All objects returned here must be treated as read-only. -type ManagedClusterSetLister interface { - // List lists all ManagedClusterSets in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.ManagedClusterSet, err error) - // Get retrieves the ManagedClusterSet from the index for a given name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1beta1.ManagedClusterSet, error) - ManagedClusterSetListerExpansion -} - -// managedClusterSetLister implements the ManagedClusterSetLister interface. -type managedClusterSetLister struct { - indexer cache.Indexer -} - -// NewManagedClusterSetLister returns a new ManagedClusterSetLister. -func NewManagedClusterSetLister(indexer cache.Indexer) ManagedClusterSetLister { - return &managedClusterSetLister{indexer: indexer} -} - -// List lists all ManagedClusterSets in the indexer. -func (s *managedClusterSetLister) List(selector labels.Selector) (ret []*v1beta1.ManagedClusterSet, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.ManagedClusterSet)) - }) - return ret, err -} - -// Get retrieves the ManagedClusterSet from the index for a given name. -func (s *managedClusterSetLister) Get(name string) (*v1beta1.ManagedClusterSet, error) { - obj, exists, err := s.indexer.GetByKey(name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("managedclusterset"), name) - } - return obj.(*v1beta1.ManagedClusterSet), nil -} diff --git a/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclustersetbinding.go b/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclustersetbinding.go deleted file mode 100644 index f7a1e301c..000000000 --- a/vendor/open-cluster-management.io/api/client/cluster/listers/cluster/v1beta1/managedclustersetbinding.go +++ /dev/null @@ -1,83 +0,0 @@ -// Code generated by lister-gen. DO NOT EDIT. - -package v1beta1 - -import ( - "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/labels" - "k8s.io/client-go/tools/cache" - v1beta1 "open-cluster-management.io/api/cluster/v1beta1" -) - -// ManagedClusterSetBindingLister helps list ManagedClusterSetBindings. -// All objects returned here must be treated as read-only. -type ManagedClusterSetBindingLister interface { - // List lists all ManagedClusterSetBindings in the indexer. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.ManagedClusterSetBinding, err error) - // ManagedClusterSetBindings returns an object that can list and get ManagedClusterSetBindings. - ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingNamespaceLister - ManagedClusterSetBindingListerExpansion -} - -// managedClusterSetBindingLister implements the ManagedClusterSetBindingLister interface. -type managedClusterSetBindingLister struct { - indexer cache.Indexer -} - -// NewManagedClusterSetBindingLister returns a new ManagedClusterSetBindingLister. -func NewManagedClusterSetBindingLister(indexer cache.Indexer) ManagedClusterSetBindingLister { - return &managedClusterSetBindingLister{indexer: indexer} -} - -// List lists all ManagedClusterSetBindings in the indexer. -func (s *managedClusterSetBindingLister) List(selector labels.Selector) (ret []*v1beta1.ManagedClusterSetBinding, err error) { - err = cache.ListAll(s.indexer, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.ManagedClusterSetBinding)) - }) - return ret, err -} - -// ManagedClusterSetBindings returns an object that can list and get ManagedClusterSetBindings. -func (s *managedClusterSetBindingLister) ManagedClusterSetBindings(namespace string) ManagedClusterSetBindingNamespaceLister { - return managedClusterSetBindingNamespaceLister{indexer: s.indexer, namespace: namespace} -} - -// ManagedClusterSetBindingNamespaceLister helps list and get ManagedClusterSetBindings. -// All objects returned here must be treated as read-only. -type ManagedClusterSetBindingNamespaceLister interface { - // List lists all ManagedClusterSetBindings in the indexer for a given namespace. - // Objects returned here must be treated as read-only. - List(selector labels.Selector) (ret []*v1beta1.ManagedClusterSetBinding, err error) - // Get retrieves the ManagedClusterSetBinding from the indexer for a given namespace and name. - // Objects returned here must be treated as read-only. - Get(name string) (*v1beta1.ManagedClusterSetBinding, error) - ManagedClusterSetBindingNamespaceListerExpansion -} - -// managedClusterSetBindingNamespaceLister implements the ManagedClusterSetBindingNamespaceLister -// interface. -type managedClusterSetBindingNamespaceLister struct { - indexer cache.Indexer - namespace string -} - -// List lists all ManagedClusterSetBindings in the indexer for a given namespace. -func (s managedClusterSetBindingNamespaceLister) List(selector labels.Selector) (ret []*v1beta1.ManagedClusterSetBinding, err error) { - err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) { - ret = append(ret, m.(*v1beta1.ManagedClusterSetBinding)) - }) - return ret, err -} - -// Get retrieves the ManagedClusterSetBinding from the indexer for a given namespace and name. -func (s managedClusterSetBindingNamespaceLister) Get(name string) (*v1beta1.ManagedClusterSetBinding, error) { - obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name) - if err != nil { - return nil, err - } - if !exists { - return nil, errors.NewNotFound(v1beta1.Resource("managedclustersetbinding"), name) - } - return obj.(*v1beta1.ManagedClusterSetBinding), nil -} diff --git a/vendor/open-cluster-management.io/api/cluster/v1/types.go b/vendor/open-cluster-management.io/api/cluster/v1/types.go index aadca53a2..499ca72d1 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1/types.go +++ b/vendor/open-cluster-management.io/api/cluster/v1/types.go @@ -251,3 +251,9 @@ const ( // Note: Image registries configured in the addonDeploymentConfig will take precedence over this annotation. ClusterImageRegistriesAnnotationKey = "open-cluster-management.io/image-registries" ) + +const ( + // ManagedClusterFinalizer is the name of the finalizer added to ManagedCluster, it is to ensure that resources + // relating to the ManagedCluster is removed when the ManagedCluster is deleted. + ManagedClusterFinalizer = "cluster.open-cluster-management.io/api-resource-cleanup" +) diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/helpers.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/helpers.go new file mode 100644 index 000000000..d70865825 --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/helpers.go @@ -0,0 +1,382 @@ +package v1alpha1 + +import ( + "fmt" + "math" + "regexp" + "sort" + "strconv" + "strings" + "time" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" + "k8s.io/utils/clock" + clusterv1beta1 "open-cluster-management.io/api/cluster/v1beta1" +) + +var RolloutClock = clock.Clock(clock.RealClock{}) +var maxTimeDuration = time.Duration(math.MaxInt64) + +// RolloutStatus represents the status of a rollout operation. +type RolloutStatus int + +const ( + // ToApply indicates that the resource's desired status has not been applied yet. + ToApply RolloutStatus = iota + // Progressing indicates that the resource's desired status is applied and last applied status is not updated. + Progressing + // Succeeded indicates that the resource's desired status is applied and last applied status is successful. + Succeeded + // Failed indicates that the resource's desired status is applied and last applied status has failed. + Failed + // TimeOut indicates that the rollout status is progressing or failed and the status remains + // for longer than the timeout, resulting in a timeout status. + TimeOut + // Skip indicates that the rollout should be skipped on this cluster. + Skip +) + +// ClusterRolloutStatusFunc defines a function to return the rollout status for a managed cluster. +type ClusterRolloutStatusFunc func(clusterName string) ClusterRolloutStatus + +// ClusterRolloutStatus holds the rollout status information for a cluster. +type ClusterRolloutStatus struct { + // GroupKey represents the cluster group key (optional field). + GroupKey clusterv1beta1.GroupKey + // Status is the required field indicating the rollout status. + Status RolloutStatus + // LastTransitionTime is the last transition time of the rollout status (optional field). + // Used to calculate timeout for progressing and failed status. + LastTransitionTime *metav1.Time + // TimeOutTime is the timeout time when the status is progressing or failed (optional field). + TimeOutTime *metav1.Time +} + +// RolloutResult contains the clusters to be rolled out and the clusters that have timed out. +type RolloutResult struct { + // ClustersToRollout is a map where the key is the cluster name and the value is the ClusterRolloutStatus. + ClustersToRollout map[string]ClusterRolloutStatus + // ClustersTimeOut is a map where the key is the cluster name and the value is the ClusterRolloutStatus. + ClustersTimeOut map[string]ClusterRolloutStatus +} + +// +k8s:deepcopy-gen=false +type RolloutHandler struct { + // placement decision tracker + pdTracker *clusterv1beta1.PlacementDecisionClustersTracker +} + +func NewRolloutHandler(pdTracker *clusterv1beta1.PlacementDecisionClustersTracker) (*RolloutHandler, error) { + if pdTracker == nil { + return nil, fmt.Errorf("invalid placement decision tracker %v", pdTracker) + } + + return &RolloutHandler{pdTracker: pdTracker}, nil +} + +// The input is a duck type RolloutStrategy and a ClusterRolloutStatusFunc to return the rollout status on each managed cluster. +// Return the strategy actual take effect and a list of clusters that need to rollout and that are timeout. +// +// ClustersToRollout: If mandatory decision groups are defined in strategy, will return the clusters to rollout in mandatory decision groups first. +// When all the mandatory decision groups rollout successfully, will return the rest of the clusters that need to rollout. +// +// ClustersTimeOut: If the cluster status is Progressing or Failed, and the status lasts longer than timeout defined in strategy, +// will list them RolloutResult.ClustersTimeOut with status TimeOut. +func (r *RolloutHandler) GetRolloutCluster(rolloutStrategy RolloutStrategy, statusFunc ClusterRolloutStatusFunc) (*RolloutStrategy, RolloutResult, error) { + switch rolloutStrategy.Type { + case All: + return r.getRolloutAllClusters(rolloutStrategy, statusFunc) + case Progressive: + return r.getProgressiveClusters(rolloutStrategy, statusFunc) + case ProgressivePerGroup: + return r.getProgressivePerGroupClusters(rolloutStrategy, statusFunc) + default: + return nil, RolloutResult{}, fmt.Errorf("incorrect rollout strategy type %v", rolloutStrategy.Type) + } +} + +func (r *RolloutHandler) getRolloutAllClusters(rolloutStrategy RolloutStrategy, statusFunc ClusterRolloutStatusFunc) (*RolloutStrategy, RolloutResult, error) { + // Prepare the rollout strategy + strategy := RolloutStrategy{Type: All} + strategy.All = rolloutStrategy.All.DeepCopy() + if strategy.All == nil { + strategy.All = &RolloutAll{} + } + + // Parse timeout for the rollout + failureTimeout, err := parseTimeout(strategy.All.Timeout.Timeout) + if err != nil { + return &strategy, RolloutResult{}, err + } + + // Get all clusters and perform progressive rollout + totalClusterGroups := r.pdTracker.ExistingClusterGroupsBesides() + totalClusters := totalClusterGroups.GetClusters().UnsortedList() + rolloutResult := progressivePerCluster(totalClusterGroups, len(totalClusters), failureTimeout, statusFunc) + + return &strategy, rolloutResult, nil +} + +func (r *RolloutHandler) getProgressiveClusters(rolloutStrategy RolloutStrategy, statusFunc ClusterRolloutStatusFunc) (*RolloutStrategy, RolloutResult, error) { + // Prepare the rollout strategy + strategy := RolloutStrategy{Type: Progressive} + strategy.Progressive = rolloutStrategy.Progressive.DeepCopy() + if strategy.Progressive == nil { + strategy.Progressive = &RolloutProgressive{} + } + + // Upgrade mandatory decision groups first + groupKeys := decisionGroupsToGroupKeys(strategy.Progressive.MandatoryDecisionGroups.MandatoryDecisionGroups) + clusterGroups := r.pdTracker.ExistingClusterGroups(groupKeys...) + + // Perform progressive rollout for mandatory decision groups + rolloutResult := progressivePerGroup(clusterGroups, maxTimeDuration, statusFunc) + if len(rolloutResult.ClustersToRollout) > 0 { + return &strategy, rolloutResult, nil + } + + // Parse timeout for non-mandatory decision groups + failureTimeout, err := parseTimeout(strategy.Progressive.Timeout.Timeout) + if err != nil { + return &strategy, RolloutResult{}, err + } + + // Calculate the length for progressive rollout + totalClusters := r.pdTracker.ExistingClusterGroupsBesides().GetClusters() + length, err := calculateLength(strategy.Progressive.MaxConcurrency, len(totalClusters)) + if err != nil { + return &strategy, RolloutResult{}, err + } + + // Upgrade the remaining clusters + restClusterGroups := r.pdTracker.ExistingClusterGroupsBesides(clusterGroups.GetOrderedGroupKeys()...) + rolloutResult = progressivePerCluster(restClusterGroups, length, failureTimeout, statusFunc) + + return &strategy, rolloutResult, nil +} + +func (r *RolloutHandler) getProgressivePerGroupClusters(rolloutStrategy RolloutStrategy, statusFunc ClusterRolloutStatusFunc) (*RolloutStrategy, RolloutResult, error) { + // Prepare the rollout strategy + strategy := RolloutStrategy{Type: ProgressivePerGroup} + strategy.ProgressivePerGroup = rolloutStrategy.ProgressivePerGroup.DeepCopy() + if strategy.ProgressivePerGroup == nil { + strategy.ProgressivePerGroup = &RolloutProgressivePerGroup{} + } + + // Upgrade mandatory decision groups first + mandatoryDecisionGroups := strategy.ProgressivePerGroup.MandatoryDecisionGroups.MandatoryDecisionGroups + groupKeys := decisionGroupsToGroupKeys(mandatoryDecisionGroups) + clusterGroups := r.pdTracker.ExistingClusterGroups(groupKeys...) + + // Perform progressive rollout per group for mandatory decision groups + rolloutResult := progressivePerGroup(clusterGroups, maxTimeDuration, statusFunc) + if len(rolloutResult.ClustersToRollout) > 0 { + return &strategy, rolloutResult, nil + } + + // Parse timeout for non-mandatory decision groups + failureTimeout, err := parseTimeout(strategy.ProgressivePerGroup.Timeout.Timeout) + if err != nil { + return &strategy, RolloutResult{}, err + } + + // Upgrade the rest of the decision groups + restClusterGroups := r.pdTracker.ExistingClusterGroupsBesides(clusterGroups.GetOrderedGroupKeys()...) + + // Perform progressive rollout per group for the remaining decision groups + rolloutResult = progressivePerGroup(restClusterGroups, failureTimeout, statusFunc) + return &strategy, rolloutResult, nil +} + +func progressivePerCluster(clusterGroupsMap clusterv1beta1.ClusterGroupsMap, length int, timeout time.Duration, statusFunc ClusterRolloutStatusFunc) RolloutResult { + rolloutClusters := map[string]ClusterRolloutStatus{} + timeoutClusters := map[string]ClusterRolloutStatus{} + + if length == 0 { + return RolloutResult{ + ClustersToRollout: rolloutClusters, + ClustersTimeOut: timeoutClusters, + } + } + + clusters := clusterGroupsMap.GetClusters().UnsortedList() + clusterToGroupKey := clusterGroupsMap.ClusterToGroupKey() + + // Sort the clusters in alphabetical order to ensure consistency. + sort.Strings(clusters) + for _, cluster := range clusters { + status := statusFunc(cluster) + if groupKey, exists := clusterToGroupKey[cluster]; exists { + status.GroupKey = groupKey + } + + newStatus, needToRollout := determineRolloutStatusAndContinue(status, timeout) + status.Status = newStatus.Status + status.TimeOutTime = newStatus.TimeOutTime + + if needToRollout { + rolloutClusters[cluster] = status + } + if status.Status == TimeOut { + timeoutClusters[cluster] = status + } + + if len(rolloutClusters)%length == 0 && len(rolloutClusters) > 0 { + return RolloutResult{ + ClustersToRollout: rolloutClusters, + ClustersTimeOut: timeoutClusters, + } + } + } + + return RolloutResult{ + ClustersToRollout: rolloutClusters, + ClustersTimeOut: timeoutClusters, + } +} + +func progressivePerGroup(clusterGroupsMap clusterv1beta1.ClusterGroupsMap, timeout time.Duration, statusFunc ClusterRolloutStatusFunc) RolloutResult { + rolloutClusters := map[string]ClusterRolloutStatus{} + timeoutClusters := map[string]ClusterRolloutStatus{} + + clusterGroupKeys := clusterGroupsMap.GetOrderedGroupKeys() + + for _, key := range clusterGroupKeys { + if subclusters, ok := clusterGroupsMap[key]; ok { + // Iterate through clusters in the group + for _, cluster := range subclusters.UnsortedList() { + status := statusFunc(cluster) + status.GroupKey = key + + newStatus, needToRollout := determineRolloutStatusAndContinue(status, timeout) + status.Status = newStatus.Status + status.TimeOutTime = newStatus.TimeOutTime + + if needToRollout { + rolloutClusters[cluster] = status + } + if status.Status == TimeOut { + timeoutClusters[cluster] = status + } + } + + // Return if there are clusters to rollout + if len(rolloutClusters) > 0 { + return RolloutResult{ + ClustersToRollout: rolloutClusters, + ClustersTimeOut: timeoutClusters, + } + } + } + } + + return RolloutResult{ + ClustersToRollout: rolloutClusters, + ClustersTimeOut: timeoutClusters, + } +} + +// determineRolloutStatusAndContinue checks whether a cluster should continue its rollout based on +// its current status and timeout. The function returns an updated cluster status and a boolean +// indicating whether the rollout should continue. +// +// The timeout parameter is utilized for handling progressing and failed statuses: +// 1. If timeout is set to None (maxTimeDuration), the function will wait until cluster reaching a success status. +// It returns true to include the cluster in the result and halts the rollout of other clusters or groups. +// 2. If timeout is set to 0, the function proceeds with upgrading other clusters without waiting. +// It returns false to skip waiting for the cluster to reach a success status and continues to rollout others. +func determineRolloutStatusAndContinue(status ClusterRolloutStatus, timeout time.Duration) (*ClusterRolloutStatus, bool) { + newStatus := status.DeepCopy() + switch status.Status { + case ToApply: + return newStatus, true + case TimeOut, Succeeded, Skip: + return newStatus, false + case Progressing, Failed: + timeOutTime := getTimeOutTime(status.LastTransitionTime, timeout) + newStatus.TimeOutTime = timeOutTime + + // check if current time is before the timeout time + if RolloutClock.Now().Before(timeOutTime.Time) { + return newStatus, true + } else { + newStatus.Status = TimeOut + return newStatus, false + } + default: + return newStatus, true + } +} + +// get the timeout time +func getTimeOutTime(startTime *metav1.Time, timeout time.Duration) *metav1.Time { + var timeoutTime time.Time + if startTime == nil { + timeoutTime = RolloutClock.Now().Add(timeout) + } else { + timeoutTime = startTime.Add(timeout) + } + return &metav1.Time{Time: timeoutTime} +} + +func calculateLength(maxConcurrency intstr.IntOrString, total int) (int, error) { + length := total + + switch maxConcurrency.Type { + case intstr.Int: + length = maxConcurrency.IntValue() + case intstr.String: + str := maxConcurrency.StrVal + if strings.HasSuffix(str, "%") { + f, err := strconv.ParseFloat(str[:len(str)-1], 64) + if err != nil { + return length, err + } + length = int(math.Ceil(f / 100 * float64(total))) + } else { + return length, fmt.Errorf("%v invalid type: string is not a percentage", maxConcurrency) + } + default: + return length, fmt.Errorf("incorrect MaxConcurrency type %v", maxConcurrency.Type) + } + + if length <= 0 || length > total { + length = total + } + + return length, nil +} + +func parseTimeout(timeoutStr string) (time.Duration, error) { + // Define the regex pattern to match the timeout string + pattern := "^(([0-9])+[h|m|s])|None$" + regex := regexp.MustCompile(pattern) + + if timeoutStr == "None" || timeoutStr == "" { + // If the timeout is "None" or empty, return the maximum duration + return maxTimeDuration, nil + } + + // Check if the timeout string matches the pattern + if !regex.MatchString(timeoutStr) { + return maxTimeDuration, fmt.Errorf("invalid timeout format") + } + + return time.ParseDuration(timeoutStr) +} + +func decisionGroupsToGroupKeys(decisionsGroup []MandatoryDecisionGroup) []clusterv1beta1.GroupKey { + result := []clusterv1beta1.GroupKey{} + for _, d := range decisionsGroup { + gk := clusterv1beta1.GroupKey{} + // GroupName is considered first to select the decisionGroups then GroupIndex. + if d.GroupName != "" { + gk.GroupName = d.GroupName + } else { + gk.GroupIndex = d.GroupIndex + } + result = append(result, gk) + } + return result +} diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_rolloutstrategy.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_rolloutstrategy.go index 74f848738..c9fa38155 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_rolloutstrategy.go +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_rolloutstrategy.go @@ -75,22 +75,22 @@ type MandatoryDecisionGroups struct { // RolloutAll is a RolloutStrategy Type type RolloutAll struct { // +optional - Timeout Timeout `json:",inline"` + Timeout `json:",inline"` } // RolloutProgressivePerGroup is a RolloutStrategy Type type RolloutProgressivePerGroup struct { // +optional - MandatoryDecisionGroups MandatoryDecisionGroups `json:",inline"` + MandatoryDecisionGroups `json:",inline"` // +optional - Timeout Timeout `json:",inline"` + Timeout `json:",inline"` } // RolloutProgressive is a RolloutStrategy Type type RolloutProgressive struct { // +optional - MandatoryDecisionGroups MandatoryDecisionGroups `json:",inline"` + MandatoryDecisionGroups `json:",inline"` // MaxConcurrency is the max number of clusters to deploy workload concurrently. The default value for MaxConcurrency is determined from the clustersPerDecisionGroup defined in the placement->DecisionStrategy. // +kubebuilder:validation:Pattern="^((100|[0-9]{1,2})%|[0-9]+)$" @@ -99,5 +99,5 @@ type RolloutProgressive struct { MaxConcurrency intstr.IntOrString `json:"maxConcurrency,omitempty"` // +optional - Timeout Timeout `json:",inline"` + Timeout `json:",inline"` } diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.deepcopy.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.deepcopy.go index 7aacdaa93..a72d4c816 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.deepcopy.go @@ -194,6 +194,31 @@ func (in *ClusterClaimSpec) DeepCopy() *ClusterClaimSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterRolloutStatus) DeepCopyInto(out *ClusterRolloutStatus) { + *out = *in + out.GroupKey = in.GroupKey + if in.LastTransitionTime != nil { + in, out := &in.LastTransitionTime, &out.LastTransitionTime + *out = (*in).DeepCopy() + } + if in.TimeOutTime != nil { + in, out := &in.TimeOutTime, &out.TimeOutTime + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterRolloutStatus. +func (in *ClusterRolloutStatus) DeepCopy() *ClusterRolloutStatus { + if in == nil { + return nil + } + out := new(ClusterRolloutStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MandatoryDecisionGroup) DeepCopyInto(out *MandatoryDecisionGroup) { *out = *in @@ -285,6 +310,36 @@ func (in *RolloutProgressivePerGroup) DeepCopy() *RolloutProgressivePerGroup { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutResult) DeepCopyInto(out *RolloutResult) { + *out = *in + if in.ClustersToRollout != nil { + in, out := &in.ClustersToRollout, &out.ClustersToRollout + *out = make(map[string]ClusterRolloutStatus, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + if in.ClustersTimeOut != nil { + in, out := &in.ClustersTimeOut, &out.ClustersTimeOut + *out = make(map[string]ClusterRolloutStatus, len(*in)) + for key, val := range *in { + (*out)[key] = *val.DeepCopy() + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutResult. +func (in *RolloutResult) DeepCopy() *RolloutResult { + if in == nil { + return nil + } + out := new(RolloutResult) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RolloutStrategy) DeepCopyInto(out *RolloutStrategy) { *out = *in diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml deleted file mode 100644 index 5ceb4eae9..000000000 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml +++ /dev/null @@ -1,207 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: managedclustersets.cluster.open-cluster-management.io -spec: - group: cluster.open-cluster-management.io - names: - kind: ManagedClusterSet - listKind: ManagedClusterSetList - plural: managedclustersets - shortNames: - - mclset - - mclsets - singular: managedclusterset - preserveUnknownFields: false - scope: Cluster - versions: - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=="ClusterSetEmpty")].status - name: Empty - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta1 - schema: - openAPIV3Schema: - description: "ManagedClusterSet defines a group of ManagedClusters that user's - workload can run on. A workload can be defined to deployed on a ManagedClusterSet, - which mean: 1. The workload can run on any ManagedCluster in the ManagedClusterSet - 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet - 3. The service exposed by the workload can be shared in any ManagedCluster - in the ManagedClusterSet \n In order to assign a ManagedCluster to a certian - ManagedClusterSet, add a label with name `cluster.open-cluster-management.io/clusterset` - on the ManagedCluster to refers to the ManagedClusterSet. User is not allow - to add/remove this label on a ManagedCluster unless they have a RBAC rule - to CREATE on a virtual subresource of managedclustersets/join. In order - to update this label, user must have the permission on both the old and - new ManagedClusterSet." - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - default: - clusterSelector: - selectorType: LegacyClusterSetLabel - description: Spec defines the attributes of the ManagedClusterSet - properties: - clusterSelector: - default: - selectorType: LegacyClusterSetLabel - description: ClusterSelector represents a selector of ManagedClusters - properties: - labelSelector: - description: LabelSelector define the general labelSelector which - clusterset will use to select target managedClusters - properties: - matchExpressions: - description: matchExpressions is a list of label selector - requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. - properties: - key: - description: key is the label key that the selector - applies to. - type: string - operator: - description: operator represents a key's relationship - to a set of values. Valid operators are In, NotIn, - Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. If - the operator is In or NotIn, the values array must - be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced - during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A - single {key,value} in the matchLabels map is equivalent - to an element of matchExpressions, whose key field is "key", - the operator is "In", and the values array contains only - "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - selectorType: - default: LegacyClusterSetLabel - description: SelectorType could only be "LegacyClusterSetLabel" - or "LabelSelector" "LegacyClusterSetLabel" means to use label - "cluster.open-cluster-management.io/clusterset:"" to select target clusters. "LabelSelector" means use - labelSelector to select target managedClusters - enum: - - LegacyClusterSetLabel - - LabelSelector - type: string - type: object - type: object - status: - description: Status represents the current status of the ManagedClusterSet - properties: - conditions: - description: Conditions contains the different condition statuses - for this ManagedClusterSet. - 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, - \n 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\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml deleted file mode 100644 index 359f13f26..000000000 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml +++ /dev/null @@ -1,136 +0,0 @@ -apiVersion: apiextensions.k8s.io/v1 -kind: CustomResourceDefinition -metadata: - name: managedclustersetbindings.cluster.open-cluster-management.io -spec: - group: cluster.open-cluster-management.io - names: - kind: ManagedClusterSetBinding - listKind: ManagedClusterSetBindingList - plural: managedclustersetbindings - shortNames: - - mclsetbinding - - mclsetbindings - singular: managedclustersetbinding - preserveUnknownFields: false - scope: Namespaced - versions: - - name: v1beta1 - schema: - openAPIV3Schema: - description: ManagedClusterSetBinding projects a ManagedClusterSet into a - certain namespace. User is able to create a ManagedClusterSetBinding in - a namespace and bind it to a ManagedClusterSet if they have an RBAC rule - to CREATE on the virtual subresource of managedclustersets/bind. Workloads - created in the same namespace can only be distributed to ManagedClusters - in ManagedClusterSets bound in this namespace by higher level controllers. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: Spec defines the attributes of ManagedClusterSetBinding. - properties: - clusterSet: - description: ClusterSet is the name of the ManagedClusterSet to bind. - It must match the instance name of the ManagedClusterSetBinding - and cannot change once created. User is allowed to set this field - if they have an RBAC rule to CREATE on the virtual subresource of - managedclustersets/bind. - minLength: 1 - type: string - type: object - status: - description: Status represents the current status of the ManagedClusterSetBinding - properties: - conditions: - description: Conditions contains the different condition statuses - for this ManagedClusterSetBinding. - 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, - \n 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\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - maxLength: 32768 - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - minimum: 0 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - maxLength: 1024 - minLength: 1 - pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$ - type: string - status: - description: status of the condition, one of True, False, Unknown. - enum: - - "True" - - "False" - - Unknown - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - maxLength: 316 - pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$ - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true - storage: true - subresources: - status: {} -status: - acceptedNames: - kind: "" - plural: "" - conditions: [] - storedVersions: [] diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml index 3ab95ee7d..f2f9f546e 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml +++ b/vendor/open-cluster-management.io/api/cluster/v1beta1/0000_02_clusters.open-cluster-management.io_placements.crd.yaml @@ -221,8 +221,6 @@ spec: - groupName type: object type: array - required: - - clustersPerDecisionGroup type: object type: object numberOfClusters: diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/helpers.go b/vendor/open-cluster-management.io/api/cluster/v1beta1/helpers.go index 27b5ebdfe..5951ee1c7 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/helpers.go +++ b/vendor/open-cluster-management.io/api/cluster/v1beta1/helpers.go @@ -2,176 +2,261 @@ package v1beta1 import ( "fmt" + "sort" + "strconv" "sync" - "k8s.io/apimachinery/pkg/api/meta" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/util/sets" - v1 "open-cluster-management.io/api/cluster/v1" ) -type ManagedClustersGetter interface { - List(selector labels.Selector) (ret []*v1.ManagedCluster, err error) +type PlacementDecisionGetter interface { + List(selector labels.Selector, namespace string) (ret []*PlacementDecision, err error) } -type ManagedClusterSetsGetter interface { - List(selector labels.Selector) (ret []*ManagedClusterSet, err error) +// +k8s:deepcopy-gen=false +type PlacementDecisionClustersTracker struct { + placement *Placement + placementDecisionGetter PlacementDecisionGetter + existingScheduledClusterGroups ClusterGroupsMap + clusterGroupsIndexToName map[int32]string + clusterGroupsNameToIndex map[string][]int32 + lock sync.RWMutex } -type ManagedClusterSetBindingsGetter interface { - List(namespace string, selector labels.Selector) (ret []*ManagedClusterSetBinding, err error) +// +k8s:deepcopy-gen=false +type GroupKey struct { + GroupName string `json:"groupName,omitempty"` + GroupIndex int32 `json:"groupIndex,omitempty"` } -// GetClustersFromClusterSet return the ManagedClusterSet's managedClusters -func GetClustersFromClusterSet(clusterSet *ManagedClusterSet, - clustersGetter ManagedClustersGetter) ([]*v1.ManagedCluster, error) { - var clusters []*v1.ManagedCluster - - if clusterSet == nil { - return nil, nil +// NewPlacementDecisionClustersTracker initializes a PlacementDecisionClustersTracker +// using existing clusters. Clusters are added to the default cluster group with index 0. +// Set existingScheduledClusters to nil if there are no existing clusters. +func NewPlacementDecisionClustersTracker(placement *Placement, pdl PlacementDecisionGetter, existingScheduledClusters sets.Set[string]) *PlacementDecisionClustersTracker { + pdct := &PlacementDecisionClustersTracker{ + placement: placement, + placementDecisionGetter: pdl, + existingScheduledClusterGroups: ClusterGroupsMap{{GroupIndex: 0}: existingScheduledClusters}, } - clusterSelector, err := BuildClusterSelector(clusterSet) - if err != nil { - return nil, err - } - if clusterSelector == nil { - return nil, fmt.Errorf("failed to build ClusterSelector with clusterSet: %v", clusterSet) - } - clusters, err = clustersGetter.List(clusterSelector) - if err != nil { - return nil, fmt.Errorf("failed to list ManagedClusters: %w", err) + // Generate group name indices for the tracker. + pdct.generateGroupsNameIndex() + return pdct +} + +// NewPlacementDecisionClustersTrackerWithGroups initializes a PlacementDecisionClustersTracker +// using existing cluster groups. Set existingScheduledClusterGroups to nil if no groups exist. +func NewPlacementDecisionClustersTrackerWithGroups(placement *Placement, pdl PlacementDecisionGetter, existingScheduledClusterGroups ClusterGroupsMap) *PlacementDecisionClustersTracker { + pdct := &PlacementDecisionClustersTracker{ + placement: placement, + placementDecisionGetter: pdl, + existingScheduledClusterGroups: existingScheduledClusterGroups, } - return clusters, nil + + // Generate group name indices for the tracker. + pdct.generateGroupsNameIndex() + return pdct } -// GetClusterSetsOfClusterByCluster return the managedClusterSets of a managedCluster -func GetClusterSetsOfCluster(cluster *v1.ManagedCluster, - clusterSetsGetter ManagedClusterSetsGetter) ([]*ManagedClusterSet, error) { - var returnClusterSets []*ManagedClusterSet +// Get updates the tracker's decisionClusters and returns added and deleted cluster names. +func (pdct *PlacementDecisionClustersTracker) Get() (sets.Set[string], sets.Set[string], error) { + pdct.lock.Lock() + defer pdct.lock.Unlock() - if cluster == nil { - return nil, nil + if pdct.placement == nil || pdct.placementDecisionGetter == nil { + return nil, nil, nil } - allClusterSets, err := clusterSetsGetter.List(labels.Everything()) + // Get the generated PlacementDecisions + decisionSelector := labels.SelectorFromSet(labels.Set{ + PlacementLabel: pdct.placement.Name, + }) + decisions, err := pdct.placementDecisionGetter.List(decisionSelector, pdct.placement.Namespace) if err != nil { - return nil, err + return nil, nil, fmt.Errorf("failed to list PlacementDecisions: %w", err) } - for _, clusterSet := range allClusterSets { - clusterSelector, err := BuildClusterSelector(clusterSet) + + // Get the decision cluster names and groups + newScheduledClusters := sets.New[string]() + newScheduledClusterGroups := map[GroupKey]sets.Set[string]{} + for _, d := range decisions { + groupKey, err := parseGroupKeyFromDecision(d) if err != nil { - return nil, err + return nil, nil, err } - if clusterSelector == nil { - return nil, fmt.Errorf("failed to build ClusterSelector with clusterSet: %v", clusterSet) + + if _, exist := newScheduledClusterGroups[groupKey]; !exist { + newScheduledClusterGroups[groupKey] = sets.New[string]() } - if clusterSelector.Matches(labels.Set(cluster.Labels)) { - returnClusterSets = append(returnClusterSets, clusterSet) + + for _, sd := range d.Status.Decisions { + newScheduledClusters.Insert(sd.ClusterName) + newScheduledClusterGroups[groupKey].Insert(sd.ClusterName) } } - return returnClusterSets, nil + + // Compare the difference + existingScheduledClusters := pdct.existingScheduledClusterGroups.GetClusters() + added := newScheduledClusters.Difference(existingScheduledClusters) + deleted := existingScheduledClusters.Difference(newScheduledClusters) + + // Update the existing decision cluster groups + pdct.existingScheduledClusterGroups = newScheduledClusterGroups + pdct.generateGroupsNameIndex() + + return added, deleted, nil } -func BuildClusterSelector(clusterSet *ManagedClusterSet) (labels.Selector, error) { - if clusterSet == nil { - return nil, nil +func (pdct *PlacementDecisionClustersTracker) generateGroupsNameIndex() { + pdct.clusterGroupsIndexToName = map[int32]string{} + pdct.clusterGroupsNameToIndex = map[string][]int32{} + + for groupkey := range pdct.existingScheduledClusterGroups { + // index to name + pdct.clusterGroupsIndexToName[groupkey.GroupIndex] = groupkey.GroupName + // name to index + if index, exist := pdct.clusterGroupsNameToIndex[groupkey.GroupName]; exist { + pdct.clusterGroupsNameToIndex[groupkey.GroupName] = append(index, groupkey.GroupIndex) + } else { + pdct.clusterGroupsNameToIndex[groupkey.GroupName] = []int32{groupkey.GroupIndex} + } } - selectorType := clusterSet.Spec.ClusterSelector.SelectorType - switch selectorType { - case "", LegacyClusterSetLabel: - return labels.SelectorFromSet(labels.Set{ - ClusterSetLabel: clusterSet.Name, - }), nil - case LabelSelector: - return metav1.LabelSelectorAsSelector(clusterSet.Spec.ClusterSelector.LabelSelector) - default: - return nil, fmt.Errorf("selectorType is not right: %s", clusterSet.Spec.ClusterSelector.SelectorType) + // sort index order + for _, index := range pdct.clusterGroupsNameToIndex { + sort.Slice(index, func(i, j int) bool { + return index[i] < index[j] + }) } } -// GetBoundManagedClusterSetBindings returns all bindings that are bounded to clustersets in the given namespace. -func GetBoundManagedClusterSetBindings(namespace string, - clusterSetBindingsGetter ManagedClusterSetBindingsGetter) ([]*ManagedClusterSetBinding, error) { - // get all clusterset bindings under the namespace - bindings, err := clusterSetBindingsGetter.List(namespace, labels.Everything()) - if err != nil { - return nil, err - } +// ExistingClusterGroups returns the tracker's existing decision cluster groups for groups listed in groupKeys. +// Return empty set when groupKeys is empty. +func (pdct *PlacementDecisionClustersTracker) ExistingClusterGroups(groupKeys ...GroupKey) ClusterGroupsMap { + pdct.lock.RLock() + defer pdct.lock.RUnlock() + + resultClusterGroups := make(map[GroupKey]sets.Set[string]) - boundBindings := []*ManagedClusterSetBinding{} - for _, binding := range bindings { - if meta.IsStatusConditionTrue(binding.Status.Conditions, ClusterSetBindingBoundType) { - boundBindings = append(boundBindings, binding) + includeGroupKeys := pdct.fulfillGroupKeys(groupKeys) + for _, groupKey := range includeGroupKeys { + if clusters, found := pdct.existingScheduledClusterGroups[groupKey]; found { + resultClusterGroups[groupKey] = clusters } } - return boundBindings, nil + return resultClusterGroups } -type PlacementDecisionGetter interface { - List(selector labels.Selector, namespace string) (ret []*PlacementDecision, err error) +// ExistingClusterGroupsBesides returns the tracker's existing decision cluster groups except cluster groups listed in groupKeys. +// Return all the clusters when groupKeys is empty. +func (pdct *PlacementDecisionClustersTracker) ExistingClusterGroupsBesides(groupKeys ...GroupKey) ClusterGroupsMap { + pdct.lock.RLock() + defer pdct.lock.RUnlock() + + resultClusterGroups := make(map[GroupKey]sets.Set[string]) + + excludeGroupKeys := pdct.fulfillGroupKeys(groupKeys) + includeGroupKeys := pdct.getGroupKeysBesides(excludeGroupKeys) + for _, groupKey := range includeGroupKeys { + if clusters, found := pdct.existingScheduledClusterGroups[groupKey]; found { + resultClusterGroups[groupKey] = clusters + } + } + + return resultClusterGroups } -// +k8s:deepcopy-gen=false -type PlacementDecisionClustersTracker struct { - placement *Placement - placementDecisionGetter PlacementDecisionGetter - existingScheduledClusters sets.Set[string] - lock sync.RWMutex +// Fulfill the expect groupkeys with group name or group index, the returned groupkeys are ordered by input group name then group index. +// For example, the input is []GroupKey{{GroupName: "group1"}, {GroupIndex: 2}}, +// the returned is []GroupKey{{GroupName: "group1", GroupIndex: 0}, {GroupName: "group1", GroupIndex: 1}, {GroupName: "group2", GroupIndex: 2}} +func (pdct *PlacementDecisionClustersTracker) fulfillGroupKeys(groupKeys []GroupKey) []GroupKey { + fulfilledGroupKeys := []GroupKey{} + for _, gk := range groupKeys { + if gk.GroupName != "" { + if indexes, exist := pdct.clusterGroupsNameToIndex[gk.GroupName]; exist { + for _, groupIndex := range indexes { + fulfilledGroupKeys = append(fulfilledGroupKeys, GroupKey{GroupName: gk.GroupName, GroupIndex: groupIndex}) + } + } + } else { + if groupName, exist := pdct.clusterGroupsIndexToName[gk.GroupIndex]; exist { + fulfilledGroupKeys = append(fulfilledGroupKeys, GroupKey{GroupName: groupName, GroupIndex: gk.GroupIndex}) + } + } + } + return fulfilledGroupKeys } -func NewPlacementDecisionClustersTracker(placement *Placement, pdl PlacementDecisionGetter, existingScheduledClusters sets.Set[string]) *PlacementDecisionClustersTracker { - pdct := &PlacementDecisionClustersTracker{ - placement: placement, - placementDecisionGetter: pdl, - existingScheduledClusters: existingScheduledClusters, +func (pdct *PlacementDecisionClustersTracker) getGroupKeysBesides(groupKeyToExclude []GroupKey) []GroupKey { + groupKey := []GroupKey{} + for i := 0; i < len(pdct.clusterGroupsIndexToName); i++ { + gKey := GroupKey{GroupName: pdct.clusterGroupsIndexToName[int32(i)], GroupIndex: int32(i)} + if !containsGroupKey(groupKeyToExclude, gKey) { + groupKey = append(groupKey, gKey) + } } - return pdct + + return groupKey } -// Get() update the tracker's decisionClusters and return the added and deleted cluster names. -func (pdct *PlacementDecisionClustersTracker) Get() (sets.Set[string], sets.Set[string], error) { - pdct.lock.Lock() - defer pdct.lock.Unlock() +// ClusterGroupsMap is a custom type representing a map of group keys to sets of cluster names. +type ClusterGroupsMap map[GroupKey]sets.Set[string] - if pdct.placement == nil || pdct.placementDecisionGetter == nil { - return nil, nil, nil +// GetOrderedGroupKeys returns an ordered slice of GroupKeys, sorted by group index. +func (g ClusterGroupsMap) GetOrderedGroupKeys() []GroupKey { + groupKeys := []GroupKey{} + for groupKey := range g { + groupKeys = append(groupKeys, groupKey) } - // Get the generated PlacementDecisions - decisionSelector := labels.SelectorFromSet(labels.Set{ - PlacementLabel: pdct.placement.Name, + // sort by group index index + sort.Slice(groupKeys, func(i, j int) bool { + return groupKeys[i].GroupIndex < groupKeys[j].GroupIndex }) - decisions, err := pdct.placementDecisionGetter.List(decisionSelector, pdct.placement.Namespace) - if err != nil { - return nil, nil, fmt.Errorf("failed to list PlacementDecisions: %w", err) - } - // Get the decision cluster names - newScheduledClusters := sets.New[string]() - for _, d := range decisions { - for _, sd := range d.Status.Decisions { - newScheduledClusters.Insert(sd.ClusterName) - } + return groupKeys +} + +// GetClusters returns a set containing all clusters from all group sets. +func (g ClusterGroupsMap) GetClusters() sets.Set[string] { + clusterSet := sets.New[string]() + for _, clusterGroup := range g { + clusterSet = clusterSet.Union(clusterGroup) } + return clusterSet +} - // Compare the difference - added := newScheduledClusters.Difference(pdct.existingScheduledClusters) - deleted := pdct.existingScheduledClusters.Difference(newScheduledClusters) +// ClusterToGroupKey returns a mapping of cluster names to their respective group keys. +func (g ClusterGroupsMap) ClusterToGroupKey() map[string]GroupKey { + clusterToGroupKey := map[string]GroupKey{} - // Update the existing decision cluster names - pdct.existingScheduledClusters = newScheduledClusters + for groupKey, clusterGroup := range g { + for c := range clusterGroup { + clusterToGroupKey[c] = groupKey + } + } - return added, deleted, nil + return clusterToGroupKey } -// Existing() returns the tracker's existing decision cluster names. -func (pdct *PlacementDecisionClustersTracker) Existing() sets.Set[string] { - pdct.lock.RLock() - defer pdct.lock.RUnlock() +// Helper function to check if a groupKey is present in the groupKeys slice. +func containsGroupKey(groupKeys []GroupKey, groupKey GroupKey) bool { + for _, gk := range groupKeys { + if gk == groupKey { + return true + } + } + return false +} - return pdct.existingScheduledClusters +func parseGroupKeyFromDecision(d *PlacementDecision) (GroupKey, error) { + groupName := d.Labels[DecisionGroupNameLabel] + groupIndex := d.Labels[DecisionGroupIndexLabel] + groupIndexNum, err := strconv.Atoi(groupIndex) + if err != nil { + return GroupKey{}, fmt.Errorf("incorrect group index: %w", err) + } + return GroupKey{GroupName: groupName, GroupIndex: int32(groupIndexNum)}, nil } diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/register.go b/vendor/open-cluster-management.io/api/cluster/v1beta1/register.go index 16a33d15b..0f9156d26 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/register.go +++ b/vendor/open-cluster-management.io/api/cluster/v1beta1/register.go @@ -30,10 +30,6 @@ func Resource(resource string) schema.GroupResource { // Adds the list of known types to api.Scheme. func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(GroupVersion, - &ManagedClusterSet{}, - &ManagedClusterSetList{}, - &ManagedClusterSetBinding{}, - &ManagedClusterSetBindingList{}, &Placement{}, &PlacementList{}, &PlacementDecision{}, diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclusterset.go b/vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclusterset.go deleted file mode 100644 index 2bc43f9e0..000000000 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclusterset.go +++ /dev/null @@ -1,99 +0,0 @@ -package v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// LegacyClusterSetLabel LabelKey -const ClusterSetLabel = "cluster.open-cluster-management.io/clusterset" - -// +genclient -// +genclient:nonNamespaced -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:subresource:status -// +kubebuilder:resource:scope="Cluster",shortName={"mclset","mclsets"} -// +kubebuilder:storageversion -// +kubebuilder:printcolumn:name="Empty",type="string",JSONPath=".status.conditions[?(@.type==\"ClusterSetEmpty\")].status" -// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp" - -// ManagedClusterSet defines a group of ManagedClusters that user's workload can run on. -// A workload can be defined to deployed on a ManagedClusterSet, which mean: -// 1. The workload can run on any ManagedCluster in the ManagedClusterSet -// 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet -// 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet -// -// In order to assign a ManagedCluster to a certian ManagedClusterSet, add a label with name -// `cluster.open-cluster-management.io/clusterset` on the ManagedCluster to refers to the ManagedClusterSet. -// User is not allow to add/remove this label on a ManagedCluster unless they have a RBAC rule to CREATE on -// a virtual subresource of managedclustersets/join. In order to update this label, user must have the permission -// on both the old and new ManagedClusterSet. -type ManagedClusterSet struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec defines the attributes of the ManagedClusterSet - // +kubebuilder:default={clusterSelector: {selectorType: LegacyClusterSetLabel}} - Spec ManagedClusterSetSpec `json:"spec"` - - // Status represents the current status of the ManagedClusterSet - // +optional - Status ManagedClusterSetStatus `json:"status,omitempty"` -} - -// ManagedClusterSetSpec describes the attributes of the ManagedClusterSet -type ManagedClusterSetSpec struct { - // ClusterSelector represents a selector of ManagedClusters - // +optional - // +kubebuilder:default:={selectorType: LegacyClusterSetLabel} - ClusterSelector ManagedClusterSelector `json:"clusterSelector,omitempty"` -} - -// ManagedClusterSelector represents a selector of ManagedClusters -type ManagedClusterSelector struct { - // SelectorType could only be "LegacyClusterSetLabel" or "LabelSelector" - // "LegacyClusterSetLabel" means to use label "cluster.open-cluster-management.io/clusterset:"" to select target clusters. - // "LabelSelector" means use labelSelector to select target managedClusters - // +kubebuilder:validation:Enum=LegacyClusterSetLabel;LabelSelector - // +kubebuilder:default:=LegacyClusterSetLabel - // +required - SelectorType SelectorType `json:"selectorType,omitempty"` - - // LabelSelector define the general labelSelector which clusterset will use to select target managedClusters - // +optional - LabelSelector *metav1.LabelSelector `json:"labelSelector,omitempty"` -} - -type SelectorType string - -const ( - // "LegacyClusterSetLabel" means to use label "cluster.open-cluster-management.io/clusterset:"" to select target clusters. - LegacyClusterSetLabel SelectorType = "LegacyClusterSetLabel" - // "LabelSelector" means use labelSelector to select target managedClusters - LabelSelector SelectorType = "LabelSelector" -) - -// ManagedClusterSetStatus represents the current status of the ManagedClusterSet. -type ManagedClusterSetStatus struct { - // Conditions contains the different condition statuses for this ManagedClusterSet. - Conditions []metav1.Condition `json:"conditions"` -} - -const ( - // ManagedClusterSetConditionEmpty means no ManagedCluster is included in the - // ManagedClusterSet. - ManagedClusterSetConditionEmpty string = "ClusterSetEmpty" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ManagedClusterSetList is a collection of ManagedClusterSet. -type ManagedClusterSetList struct { - metav1.TypeMeta `json:",inline"` - // Standard list metadata. - // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - // Items is a list of ManagedClusterSet. - Items []ManagedClusterSet `json:"items"` -} diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclustersetbinding.go b/vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclustersetbinding.go deleted file mode 100644 index fed2c17d1..000000000 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/types_managedclustersetbinding.go +++ /dev/null @@ -1,65 +0,0 @@ -package v1beta1 - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +genclient -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object -// +kubebuilder:subresource:status -// +kubebuilder:resource:scope="Namespaced",shortName={"mclsetbinding","mclsetbindings"} -// +kubebuilder:storageversion - -// ManagedClusterSetBinding projects a ManagedClusterSet into a certain namespace. -// User is able to create a ManagedClusterSetBinding in a namespace and bind it to a -// ManagedClusterSet if they have an RBAC rule to CREATE on the virtual subresource of -// managedclustersets/bind. Workloads created in the same namespace can only be -// distributed to ManagedClusters in ManagedClusterSets bound in this namespace by -// higher level controllers. -type ManagedClusterSetBinding struct { - metav1.TypeMeta `json:",inline"` - metav1.ObjectMeta `json:"metadata,omitempty"` - - // Spec defines the attributes of ManagedClusterSetBinding. - Spec ManagedClusterSetBindingSpec `json:"spec"` - - // Status represents the current status of the ManagedClusterSetBinding - // +optional - Status ManagedClusterSetBindingStatus `json:"status,omitempty"` -} - -// ManagedClusterSetBindingSpec defines the attributes of ManagedClusterSetBinding. -type ManagedClusterSetBindingSpec struct { - // ClusterSet is the name of the ManagedClusterSet to bind. It must match the - // instance name of the ManagedClusterSetBinding and cannot change once created. - // User is allowed to set this field if they have an RBAC rule to CREATE on the - // virtual subresource of managedclustersets/bind. - // +kubebuilder:validation:MinLength=1 - ClusterSet string `json:"clusterSet"` -} - -const ( - // ClusterSetBindingBoundType is a condition type of clustersetbinding representing - // whether the ClusterSetBinding is bound to a clusterset. - ClusterSetBindingBoundType = "Bound" -) - -// ManagedClusterSetBindingStatus represents the current status of the ManagedClusterSetBinding. -type ManagedClusterSetBindingStatus struct { - // Conditions contains the different condition statuses for this ManagedClusterSetBinding. - Conditions []metav1.Condition `json:"conditions"` -} - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -// ManagedClusterSetBindingList is a collection of ManagedClusterSetBinding. -type ManagedClusterSetBindingList struct { - metav1.TypeMeta `json:",inline"` - // Standard list metadata. - // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds - // +optional - metav1.ListMeta `json:"metadata,omitempty"` - - // Items is a list of ManagedClusterSetBinding. - Items []ManagedClusterSetBinding `json:"items"` -} diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/types_placement.go b/vendor/open-cluster-management.io/api/cluster/v1beta1/types_placement.go index 89ebeaecf..9065b597b 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/types_placement.go +++ b/vendor/open-cluster-management.io/api/cluster/v1beta1/types_placement.go @@ -137,7 +137,6 @@ type GroupStrategy struct { // group SHOULD be less than ClustersPerDecisionGroup. Once the number of items exceeds the ClustersPerDecisionGroup, // the decisionGroups will also be be divided into multiple decisionGroups with same GroupName but different GroupIndex. // - // +kubebuilder:validation:Required // +kubebuilder:validation:XIntOrString // +kubebuilder:validation:Pattern=`^((100|[1-9][0-9]{0,1})%|[1-9][0-9]*)$` // +kubebuilder:default:="100%" diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.deepcopy.go b/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.deepcopy.go index d4e9820c8..347b89457 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.deepcopy.go +++ b/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.deepcopy.go @@ -8,6 +8,7 @@ package v1beta1 import ( v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" + sets "k8s.io/apimachinery/pkg/util/sets" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -65,6 +66,38 @@ func (in *ClusterDecision) DeepCopy() *ClusterDecision { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in ClusterGroupsMap) DeepCopyInto(out *ClusterGroupsMap) { + { + in := &in + *out = make(ClusterGroupsMap, len(*in)) + for key, val := range *in { + var outVal map[string]sets.Empty + if val == nil { + (*out)[key] = nil + } else { + in, out := &val, &outVal + *out = make(sets.Set[string], len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + (*out)[key] = outVal + } + return + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterGroupsMap. +func (in ClusterGroupsMap) DeepCopy() ClusterGroupsMap { + if in == nil { + return nil + } + out := new(ClusterGroupsMap) + in.DeepCopyInto(out) + return *out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ClusterPredicate) DeepCopyInto(out *ClusterPredicate) { *out = *in @@ -179,228 +212,6 @@ func (in *GroupStrategy) DeepCopy() *GroupStrategy { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSelector) DeepCopyInto(out *ManagedClusterSelector) { - *out = *in - if in.LabelSelector != nil { - in, out := &in.LabelSelector, &out.LabelSelector - *out = new(v1.LabelSelector) - (*in).DeepCopyInto(*out) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSelector. -func (in *ManagedClusterSelector) DeepCopy() *ManagedClusterSelector { - if in == nil { - return nil - } - out := new(ManagedClusterSelector) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSet) DeepCopyInto(out *ManagedClusterSet) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - in.Spec.DeepCopyInto(&out.Spec) - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSet. -func (in *ManagedClusterSet) DeepCopy() *ManagedClusterSet { - if in == nil { - return nil - } - out := new(ManagedClusterSet) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ManagedClusterSet) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSetBinding) DeepCopyInto(out *ManagedClusterSetBinding) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - in.Status.DeepCopyInto(&out.Status) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetBinding. -func (in *ManagedClusterSetBinding) DeepCopy() *ManagedClusterSetBinding { - if in == nil { - return nil - } - out := new(ManagedClusterSetBinding) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ManagedClusterSetBinding) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSetBindingList) DeepCopyInto(out *ManagedClusterSetBindingList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ManagedClusterSetBinding, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetBindingList. -func (in *ManagedClusterSetBindingList) DeepCopy() *ManagedClusterSetBindingList { - if in == nil { - return nil - } - out := new(ManagedClusterSetBindingList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ManagedClusterSetBindingList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSetBindingSpec) DeepCopyInto(out *ManagedClusterSetBindingSpec) { - *out = *in - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetBindingSpec. -func (in *ManagedClusterSetBindingSpec) DeepCopy() *ManagedClusterSetBindingSpec { - if in == nil { - return nil - } - out := new(ManagedClusterSetBindingSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSetBindingStatus) DeepCopyInto(out *ManagedClusterSetBindingStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetBindingStatus. -func (in *ManagedClusterSetBindingStatus) DeepCopy() *ManagedClusterSetBindingStatus { - if in == nil { - return nil - } - out := new(ManagedClusterSetBindingStatus) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSetList) DeepCopyInto(out *ManagedClusterSetList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]ManagedClusterSet, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetList. -func (in *ManagedClusterSetList) DeepCopy() *ManagedClusterSetList { - if in == nil { - return nil - } - out := new(ManagedClusterSetList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *ManagedClusterSetList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSetSpec) DeepCopyInto(out *ManagedClusterSetSpec) { - *out = *in - in.ClusterSelector.DeepCopyInto(&out.ClusterSelector) - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetSpec. -func (in *ManagedClusterSetSpec) DeepCopy() *ManagedClusterSetSpec { - if in == nil { - return nil - } - out := new(ManagedClusterSetSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *ManagedClusterSetStatus) DeepCopyInto(out *ManagedClusterSetStatus) { - *out = *in - if in.Conditions != nil { - in, out := &in.Conditions, &out.Conditions - *out = make([]v1.Condition, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ManagedClusterSetStatus. -func (in *ManagedClusterSetStatus) DeepCopy() *ManagedClusterSetStatus { - if in == nil { - return nil - } - out := new(ManagedClusterSetStatus) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Placement) DeepCopyInto(out *Placement) { *out = *in diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.swagger_doc_generated.go b/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.swagger_doc_generated.go index 691aa1659..bc134648b 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.swagger_doc_generated.go +++ b/vendor/open-cluster-management.io/api/cluster/v1beta1/zz_generated.swagger_doc_generated.go @@ -11,92 +11,6 @@ package v1beta1 // Those methods can be generated by using hack/update-swagger-docs.sh // AUTO-GENERATED FUNCTIONS START HERE -var map_ManagedClusterSelector = map[string]string{ - "": "ManagedClusterSelector represents a selector of ManagedClusters", - "selectorType": "SelectorType could only be \"LegacyClusterSetLabel\" or \"LabelSelector\" \"LegacyClusterSetLabel\" means to use label \"cluster.open-cluster-management.io/clusterset:\"\" to select target clusters. \"LabelSelector\" means use labelSelector to select target managedClusters", - "labelSelector": "LabelSelector define the general labelSelector which clusterset will use to select target managedClusters", -} - -func (ManagedClusterSelector) SwaggerDoc() map[string]string { - return map_ManagedClusterSelector -} - -var map_ManagedClusterSet = map[string]string{ - "": "ManagedClusterSet defines a group of ManagedClusters that user's workload can run on. A workload can be defined to deployed on a ManagedClusterSet, which mean:\n 1. The workload can run on any ManagedCluster in the ManagedClusterSet\n 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet\n 3. The service exposed by the workload can be shared in any ManagedCluster in the ManagedClusterSet\n\nIn order to assign a ManagedCluster to a certian ManagedClusterSet, add a label with name `cluster.open-cluster-management.io/clusterset` on the ManagedCluster to refers to the ManagedClusterSet. User is not allow to add/remove this label on a ManagedCluster unless they have a RBAC rule to CREATE on a virtual subresource of managedclustersets/join. In order to update this label, user must have the permission on both the old and new ManagedClusterSet.", - "spec": "Spec defines the attributes of the ManagedClusterSet", - "status": "Status represents the current status of the ManagedClusterSet", -} - -func (ManagedClusterSet) SwaggerDoc() map[string]string { - return map_ManagedClusterSet -} - -var map_ManagedClusterSetList = map[string]string{ - "": "ManagedClusterSetList is a collection of ManagedClusterSet.", - "metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", - "items": "Items is a list of ManagedClusterSet.", -} - -func (ManagedClusterSetList) SwaggerDoc() map[string]string { - return map_ManagedClusterSetList -} - -var map_ManagedClusterSetSpec = map[string]string{ - "": "ManagedClusterSetSpec describes the attributes of the ManagedClusterSet", - "clusterSelector": "ClusterSelector represents a selector of ManagedClusters", -} - -func (ManagedClusterSetSpec) SwaggerDoc() map[string]string { - return map_ManagedClusterSetSpec -} - -var map_ManagedClusterSetStatus = map[string]string{ - "": "ManagedClusterSetStatus represents the current status of the ManagedClusterSet.", - "conditions": "Conditions contains the different condition statuses for this ManagedClusterSet.", -} - -func (ManagedClusterSetStatus) SwaggerDoc() map[string]string { - return map_ManagedClusterSetStatus -} - -var map_ManagedClusterSetBinding = map[string]string{ - "": "ManagedClusterSetBinding projects a ManagedClusterSet into a certain namespace. User is able to create a ManagedClusterSetBinding in a namespace and bind it to a ManagedClusterSet if they have an RBAC rule to CREATE on the virtual subresource of managedclustersets/bind. Workloads created in the same namespace can only be distributed to ManagedClusters in ManagedClusterSets bound in this namespace by higher level controllers.", - "spec": "Spec defines the attributes of ManagedClusterSetBinding.", - "status": "Status represents the current status of the ManagedClusterSetBinding", -} - -func (ManagedClusterSetBinding) SwaggerDoc() map[string]string { - return map_ManagedClusterSetBinding -} - -var map_ManagedClusterSetBindingList = map[string]string{ - "": "ManagedClusterSetBindingList is a collection of ManagedClusterSetBinding.", - "metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", - "items": "Items is a list of ManagedClusterSetBinding.", -} - -func (ManagedClusterSetBindingList) SwaggerDoc() map[string]string { - return map_ManagedClusterSetBindingList -} - -var map_ManagedClusterSetBindingSpec = map[string]string{ - "": "ManagedClusterSetBindingSpec defines the attributes of ManagedClusterSetBinding.", - "clusterSet": "ClusterSet is the name of the ManagedClusterSet to bind. It must match the instance name of the ManagedClusterSetBinding and cannot change once created. User is allowed to set this field if they have an RBAC rule to CREATE on the virtual subresource of managedclustersets/bind.", -} - -func (ManagedClusterSetBindingSpec) SwaggerDoc() map[string]string { - return map_ManagedClusterSetBindingSpec -} - -var map_ManagedClusterSetBindingStatus = map[string]string{ - "": "ManagedClusterSetBindingStatus represents the current status of the ManagedClusterSetBinding.", - "conditions": "Conditions contains the different condition statuses for this ManagedClusterSetBinding.", -} - -func (ManagedClusterSetBindingStatus) SwaggerDoc() map[string]string { - return map_ManagedClusterSetBindingStatus -} - var map_AddOnScore = map[string]string{ "": "AddOnScore represents the configuration of the addon score source.", "resourceName": "ResourceName defines the resource name of the AddOnPlacementScore. The placement prioritizer selects AddOnPlacementScore CR by this name.", diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml index c0d11bb93..35109c2e5 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml +++ b/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_00_clusters.open-cluster-management.io_managedclustersets.crd.yaml @@ -22,10 +22,7 @@ spec: - jsonPath: .metadata.creationTimestamp name: Age type: date - deprecated: true - deprecationWarning: cluster.open-cluster-management.io/v1beta1 ManagedClusterSet - is deprecated; use cluster.open-cluster-management.io/v1beta2 ManagedClusterSet - name: v1beta1 + name: v1beta2 schema: openAPIV3Schema: description: "ManagedClusterSet defines a group of ManagedClusters that user's @@ -56,12 +53,12 @@ spec: spec: default: clusterSelector: - selectorType: LegacyClusterSetLabel + selectorType: ExclusiveClusterSetLabel description: Spec defines the attributes of the ManagedClusterSet properties: clusterSelector: default: - selectorType: LegacyClusterSetLabel + selectorType: ExclusiveClusterSetLabel description: ClusterSelector represents a selector of ManagedClusters properties: labelSelector: @@ -111,14 +108,14 @@ spec: type: object x-kubernetes-map-type: atomic selectorType: - default: LegacyClusterSetLabel - description: SelectorType could only be "LegacyClusterSetLabel" - or "LabelSelector" "LegacyClusterSetLabel" means to use label + default: ExclusiveClusterSetLabel + description: SelectorType could only be "ExclusiveClusterSetLabel" + or "LabelSelector" "ExclusiveClusterSetLabel" means to use label "cluster.open-cluster-management.io/clusterset:"" to select target clusters. "LabelSelector" means use labelSelector to select target managedClusters enum: - - LegacyClusterSetLabel + - ExclusiveClusterSetLabel - LabelSelector type: string type: object @@ -199,178 +196,6 @@ spec: type: object type: object served: true - storage: false - subresources: - status: {} - - additionalPrinterColumns: - - jsonPath: .status.conditions[?(@.type=="ClusterSetEmpty")].status - name: Empty - type: string - - jsonPath: .metadata.creationTimestamp - name: Age - type: date - name: v1beta2 - schema: - openAPIV3Schema: - description: "ManagedClusterSet defines a group of ManagedClusters that user's - workload can run on. A workload can be defined to deployed on a ManagedClusterSet, - which mean: 1. The workload can run on any ManagedCluster in the ManagedClusterSet - 2. The workload cannot run on any ManagedCluster outside the ManagedClusterSet - 3. The service exposed by the workload can be shared in any ManagedCluster - in the ManagedClusterSet \n In order to assign a ManagedCluster to a certian - ManagedClusterSet, add a label with name `cluster.open-cluster-management.io/clusterset` - on the ManagedCluster to refers to the ManagedClusterSet. User is not allow - to add/remove this label on a ManagedCluster unless they have a RBAC rule - to CREATE on a virtual subresource of managedclustersets/join. In order - to update this label, user must have the permission on both the old and - new ManagedClusterSet." - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - default: - clusterSelector: - selectorType: ExclusiveClusterSetLabel - description: Spec defines the attributes of the ManagedClusterSet - properties: - clusterSelector: - default: - selectorType: ExclusiveClusterSetLabel - description: ClusterSelector represents a selector of ManagedClusters - properties: - labelSelector: - description: LabelSelector define the general labelSelector which - clusterset will use to select target managedClusters - properties: - matchExpressions: - description: matchExpressions is a list of label selector - requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. - properties: - key: - description: key is the label key that the selector - applies to. - type: string - operator: - description: operator represents a key's relationship - to a set of values. Valid operators are In, NotIn, - Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. If - the operator is In or NotIn, the values array must - be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced - during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A - single {key,value} in the matchLabels map is equivalent - to an element of matchExpressions, whose key field is "key", - the operator is "In", and the values array contains only - "value". The requirements are ANDed. - type: object - type: object - selectorType: - default: ExclusiveClusterSetLabel - description: SelectorType could only be "ExclusiveClusterSetLabel" - or "LabelSelector" "ExclusiveClusterSetLabel" means to use label - "cluster.open-cluster-management.io/clusterset:"" to select target clusters. "LabelSelector" means use - labelSelector to select target managedClusters - enum: - - ExclusiveClusterSetLabel - - LabelSelector - type: string - type: object - type: object - status: - description: Status represents the current status of the ManagedClusterSet - properties: - conditions: - description: Conditions contains the different condition statuses - for this ManagedClusterSet. - 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, - \n 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\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - type: string - status: - description: status of the condition, one of True, False, Unknown. - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true storage: true subresources: status: {} diff --git a/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml index e07e082e2..cfba3ffa1 100644 --- a/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml +++ b/vendor/open-cluster-management.io/api/cluster/v1beta2/0000_01_clusters.open-cluster-management.io_managedclustersetbindings.crd.yaml @@ -15,10 +15,7 @@ spec: preserveUnknownFields: false scope: Namespaced versions: - - deprecated: true - deprecationWarning: cluster.open-cluster-management.io/v1beta1 ManagedClusterSetBinding - is deprecated; use cluster.open-cluster-management.io/v1beta2 ManagedClusterSetBinding - name: v1beta1 + - name: v1beta2 schema: openAPIV3Schema: description: ManagedClusterSetBinding projects a ManagedClusterSet into a @@ -128,108 +125,6 @@ spec: type: object type: object served: true - storage: false - subresources: - status: {} - - name: v1beta2 - schema: - openAPIV3Schema: - description: ManagedClusterSetBinding projects a ManagedClusterSet into a - certain namespace. User is able to create a ManagedClusterSetBinding in - a namespace and bind it to a ManagedClusterSet if they have an RBAC rule - to CREATE on the virtual subresource of managedclustersets/bind. Workloads - created in the same namespace can only be distributed to ManagedClusters - in ManagedClusterSets bound in this namespace by higher level controllers. - properties: - apiVersion: - description: 'APIVersion defines the versioned schema of this representation - of an object. Servers should convert recognized schemas to the latest - internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' - type: string - kind: - description: 'Kind is a string value representing the REST resource this - object represents. Servers may infer this from the endpoint the client - submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' - type: string - metadata: - type: object - spec: - description: Spec defines the attributes of ManagedClusterSetBinding. - properties: - clusterSet: - description: ClusterSet is the name of the ManagedClusterSet to bind. - It must match the instance name of the ManagedClusterSetBinding - and cannot change once created. User is allowed to set this field - if they have an RBAC rule to CREATE on the virtual subresource of - managedclustersets/bind. - minLength: 1 - type: string - type: object - status: - description: Status represents the current status of the ManagedClusterSetBinding - properties: - conditions: - description: Conditions contains the different condition statuses - for this ManagedClusterSetBinding. - 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, - \n 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\"` \n // other fields }" - properties: - lastTransitionTime: - description: lastTransitionTime is the last time the condition - transitioned from one status to another. This should be when - the underlying condition changed. If that is not known, then - using the time when the API field changed is acceptable. - format: date-time - type: string - message: - description: message is a human readable message indicating - details about the transition. This may be an empty string. - type: string - observedGeneration: - description: observedGeneration represents the .metadata.generation - that the condition was set based upon. For instance, if .metadata.generation - is currently 12, but the .status.conditions[x].observedGeneration - is 9, the condition is out of date with respect to the current - state of the instance. - format: int64 - type: integer - reason: - description: reason contains a programmatic identifier indicating - the reason for the condition's last transition. Producers - of specific condition types may define expected values and - meanings for this field, and whether the values are considered - a guaranteed API. The value should be a CamelCase string. - This field may not be empty. - type: string - status: - description: status of the condition, one of True, False, Unknown. - type: string - type: - description: type of condition in CamelCase or in foo.example.com/CamelCase. - --- Many .condition.type values are consistent across resources - like Available, but because arbitrary conditions can be useful - (see .node.status.conditions), the ability to deconflict is - important. The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt) - type: string - required: - - lastTransitionTime - - message - - reason - - status - - type - type: object - type: array - type: object - type: object - served: true storage: true subresources: status: {} diff --git a/vendor/open-cluster-management.io/api/work/v1/types.go b/vendor/open-cluster-management.io/api/work/v1/types.go index c07d3c464..39b8ec2b2 100644 --- a/vendor/open-cluster-management.io/api/work/v1/types.go +++ b/vendor/open-cluster-management.io/api/work/v1/types.go @@ -475,22 +475,28 @@ const ( JsonRaw ValueType = "JsonRaw" ) -// ManifestConditionType represents the condition type of a single -// resource manifest deployed on the managed cluster. -type ManifestConditionType string - const ( // ManifestProgressing represents that the resource is being applied on the managed cluster - ManifestProgressing ManifestConditionType = "Progressing" + ManifestProgressing string = "Progressing" // ManifestApplied represents that the resource object is applied // on the managed cluster. - ManifestApplied ManifestConditionType = "Applied" + ManifestApplied string = "Applied" // ManifestAvailable represents that the resource object exists // on the managed cluster. - ManifestAvailable ManifestConditionType = "Available" + ManifestAvailable string = "Available" // ManifestDegraded represents that the current state of resource object does not // match the desired state for a certain period. - ManifestDegraded ManifestConditionType = "Degraded" + ManifestDegraded string = "Degraded" +) + +const ( + // ManifestWorkFinalizer is the name of the finalizer added to manifestworks. It is used to ensure + // related appliedmanifestwork of a manifestwork are deleted before the manifestwork itself is deleted + ManifestWorkFinalizer = "cluster.open-cluster-management.io/manifest-work-cleanup" + // AppliedManifestWorkFinalizer is the name of the finalizer added to appliedmanifestwork. It is to + // ensure all resource relates to appliedmanifestwork is deleted before appliedmanifestwork itself + // is deleted. + AppliedManifestWorkFinalizer = "cluster.open-cluster-management.io/applied-manifest-work-cleanup" ) // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/vendor/open-cluster-management.io/api/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml b/vendor/open-cluster-management.io/api/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml index 9315f0770..ecd82e555 100644 --- a/vendor/open-cluster-management.io/api/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml +++ b/vendor/open-cluster-management.io/api/work/v1alpha1/0000_00_work.open-cluster-management.io_manifestworkreplicasets.crd.yaml @@ -325,6 +325,139 @@ spec: description: Name of the Placement resource in the current namespace minLength: 1 type: string + rolloutStrategy: + default: + all: + timeout: None + type: All + description: Rollout strategy to apply workload to the selected + clusters by Placement and DecisionStrategy. + properties: + all: + description: All define required fields for RolloutStrategy + type All + properties: + timeout: + default: None + description: Timeout define how long workload applier + controller will wait till workload reach successful + state in the cluster. Timeout default value is None + meaning the workload applier will not proceed apply + workload to other clusters if did not reach the successful + state. Timeout must be defined in [0-9h]|[0-9m]|[0-9s] + format examples; 2h , 90m , 360s + pattern: ^(([0-9])+[h|m|s])|None$ + type: string + type: object + progressive: + description: Progressive define required fields for RolloutStrategy + type Progressive + properties: + mandatoryDecisionGroups: + description: List of the decision groups names or indexes + to apply the workload first and fail if workload did + not reach successful state. GroupName or GroupIndex + must match with the decisionGroups defined in the + placement's decisionStrategy + items: + description: MandatoryDecisionGroup set the decision + group name or group index. GroupName is considered + first to select the decisionGroups then GroupIndex. + properties: + groupIndex: + description: GroupIndex of the decision group + should match the placementDecisions label value + with label key cluster.open-cluster-management.io/decision-group-index + format: int32 + type: integer + groupName: + description: GroupName of the decision group should + match the placementDecisions label value with + label key cluster.open-cluster-management.io/decision-group-name + type: string + type: object + type: array + maxConcurrency: + anyOf: + - type: integer + - type: string + description: MaxConcurrency is the max number of clusters + to deploy workload concurrently. The default value + for MaxConcurrency is determined from the clustersPerDecisionGroup + defined in the placement->DecisionStrategy. + pattern: ^((100|[0-9]{1,2})%|[0-9]+)$ + x-kubernetes-int-or-string: true + timeout: + default: None + description: Timeout define how long workload applier + controller will wait till workload reach successful + state in the cluster. Timeout default value is None + meaning the workload applier will not proceed apply + workload to other clusters if did not reach the successful + state. Timeout must be defined in [0-9h]|[0-9m]|[0-9s] + format examples; 2h , 90m , 360s + pattern: ^(([0-9])+[h|m|s])|None$ + type: string + type: object + progressivePerGroup: + description: ProgressivePerGroup define required fields + for RolloutStrategy type ProgressivePerGroup + properties: + mandatoryDecisionGroups: + description: List of the decision groups names or indexes + to apply the workload first and fail if workload did + not reach successful state. GroupName or GroupIndex + must match with the decisionGroups defined in the + placement's decisionStrategy + items: + description: MandatoryDecisionGroup set the decision + group name or group index. GroupName is considered + first to select the decisionGroups then GroupIndex. + properties: + groupIndex: + description: GroupIndex of the decision group + should match the placementDecisions label value + with label key cluster.open-cluster-management.io/decision-group-index + format: int32 + type: integer + groupName: + description: GroupName of the decision group should + match the placementDecisions label value with + label key cluster.open-cluster-management.io/decision-group-name + type: string + type: object + type: array + timeout: + default: None + description: Timeout define how long workload applier + controller will wait till workload reach successful + state in the cluster. Timeout default value is None + meaning the workload applier will not proceed apply + workload to other clusters if did not reach the successful + state. Timeout must be defined in [0-9h]|[0-9m]|[0-9s] + format examples; 2h , 90m , 360s + pattern: ^(([0-9])+[h|m|s])|None$ + type: string + type: object + type: + default: All + description: Rollout strategy Types are All, Progressive + and ProgressivePerGroup 1) All means apply the workload + to all clusters in the decision groups at once. 2) Progressive + means apply the workload to the selected clusters progressively + per cluster. The workload will not be applied to the next + cluster unless one of the current applied clusters reach + the successful state or timeout. 3) ProgressivePerGroup + means apply the workload to decisionGroup clusters progressively + per group. The workload will not be applied to the next + decisionGroup unless all clusters in the current group + reach the successful state or timeout. + enum: + - All + - Progressive + - ProgressivePerGroup + type: string + type: object required: - name type: object @@ -409,8 +542,49 @@ spec: - type type: object type: array + placementSummary: + description: PlacementRef Summary + items: + description: PlacementSummary provides info regards number of clusters + and clusterGroups selected by the placement refs. + properties: + availableDecisionGroups: + description: availableDecisionGroups shows number of decisionGroups + that have all clusters manifestWorks in available state regards + total number of decisionGroups. ex; 2/4 (2 out of 4) + type: string + name: + description: PlacementRef Name + type: string + summary: + description: Summary totals of resulting ManifestWorks for the + placement + properties: + Applied: + description: 'Applied is the number of ManifestWorks with + condition Applied: true' + type: integer + available: + description: 'Available is the number of ManifestWorks with + condition Available: true' + type: integer + degraded: + description: 'TODO: Degraded is the number of ManifestWorks + with condition Degraded: true' + type: integer + progressing: + description: 'TODO: Progressing is the number of ManifestWorks + with condition Progressing: true' + type: integer + total: + description: Total number of ManifestWorks managed by the + ManifestWorkReplicaSet + type: integer + type: object + type: object + type: array summary: - description: Summary totals of resulting ManifestWorks + description: Summary totals of resulting ManifestWorks for all placements properties: Applied: description: 'Applied is the number of ManifestWorks with condition diff --git a/vendor/open-cluster-management.io/api/work/v1alpha1/types_manifestworkreplicaset.go b/vendor/open-cluster-management.io/api/work/v1alpha1/types_manifestworkreplicaset.go index 09b8c5e75..b68e00897 100644 --- a/vendor/open-cluster-management.io/api/work/v1alpha1/types_manifestworkreplicaset.go +++ b/vendor/open-cluster-management.io/api/work/v1alpha1/types_manifestworkreplicaset.go @@ -17,6 +17,7 @@ limitations under the License. package v1alpha1 import ( + cluster "open-cluster-management.io/api/cluster/v1alpha1" work "open-cluster-management.io/api/work/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -75,8 +76,11 @@ type ManifestWorkReplicaSetStatus struct { // 2. PlacementRefValid Conditions []metav1.Condition `json:"conditions,omitempty"` - // Summary totals of resulting ManifestWorks + // Summary totals of resulting ManifestWorks for all placements Summary ManifestWorkReplicaSetSummary `json:"summary"` + + // PlacementRef Summary + PlacementsSummary []PlacementSummary `json:"placementSummary"` } // localPlacementReference is the name of a Placement resource in current namespace @@ -86,6 +90,23 @@ type LocalPlacementReference struct { // +kubebuilder:validation:Required // +kubebuilder:validation:MinLength=1 Name string `json:"name"` + + // +optional + // +kubebuilder:default={type: All, all: {timeout: None}} + RolloutStrategy cluster.RolloutStrategy `json:"rolloutStrategy"` +} + +// PlacementSummary provides info regards number of clusters and clusterGroups selected by the placement refs. +type PlacementSummary struct { + // PlacementRef Name + Name string `json:"name"` + + // availableDecisionGroups shows number of decisionGroups that have all clusters manifestWorks in available state regards total number of decisionGroups. + // ex; 2/4 (2 out of 4) + AvailableDecisionGroups string `json:"availableDecisionGroups"` + + // Summary totals of resulting ManifestWorks for the placement + Summary ManifestWorkReplicaSetSummary `json:"summary"` } // ManifestWorkReplicaSetSummary provides reference counts of all ManifestWorks that are associated with a @@ -129,12 +150,23 @@ const ( // ReasonNotAsExpected is a reason for ManifestWorkReplicaSetConditionManifestworkApplied condition type representing // the ManifestWorkSet is not applied correctly. ReasonNotAsExpected = "NotAsExpected" + // ReasonProgressing is a reason for ManifestWorkReplicaSetConditionPlacementRolledOut condition type representing. + // The ManifestWorks are progressively applied to the placement clusters. + ReasonProgressing = "Progressing" + // ReasonComplete is a reason for ManifestWorkReplicaSetConditionPlacementRolledOut condition type representing. + // The ManifestWorks are completely applied to the placement clusters. + ReasonComplete = "Complete" // ManifestWorkSetConditionPlacementVerified indicates if Placement is valid // // Reason: AsExpected, PlacementDecisionNotFound, PlacementDecisionEmpty or NotAsExpected ManifestWorkReplicaSetConditionPlacementVerified string = "PlacementVerified" + // ManifestWorkReplicaSetConditionPlacementRolledOut indicates if RollOut Strategy is complete. + // + // Reason: Progressing or Complete. + ManifestWorkReplicaSetConditionPlacementRolledOut string = "PlacementRolledOut" + // ManifestWorkSetConditionManifestworkApplied confirms that a ManifestWork has been created in each cluster defined by PlacementDecision // // Reason: AsExpected, NotAsExpected or Processing diff --git a/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.deepcopy.go b/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.deepcopy.go index a81786dd5..05af3f770 100644 --- a/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.deepcopy.go +++ b/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.deepcopy.go @@ -13,6 +13,7 @@ import ( // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LocalPlacementReference) DeepCopyInto(out *LocalPlacementReference) { *out = *in + in.RolloutStrategy.DeepCopyInto(&out.RolloutStrategy) return } @@ -94,7 +95,9 @@ func (in *ManifestWorkReplicaSetSpec) DeepCopyInto(out *ManifestWorkReplicaSetSp if in.PlacementRefs != nil { in, out := &in.PlacementRefs, &out.PlacementRefs *out = make([]LocalPlacementReference, len(*in)) - copy(*out, *in) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } } return } @@ -120,6 +123,11 @@ func (in *ManifestWorkReplicaSetStatus) DeepCopyInto(out *ManifestWorkReplicaSet } } out.Summary = in.Summary + if in.PlacementsSummary != nil { + in, out := &in.PlacementsSummary, &out.PlacementsSummary + *out = make([]PlacementSummary, len(*in)) + copy(*out, *in) + } return } @@ -148,3 +156,20 @@ func (in *ManifestWorkReplicaSetSummary) DeepCopy() *ManifestWorkReplicaSetSumma in.DeepCopyInto(out) return out } + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *PlacementSummary) DeepCopyInto(out *PlacementSummary) { + *out = *in + out.Summary = in.Summary + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new PlacementSummary. +func (in *PlacementSummary) DeepCopy() *PlacementSummary { + if in == nil { + return nil + } + out := new(PlacementSummary) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.swagger_doc_generated.go b/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.swagger_doc_generated.go index 1eb35b56c..b158386e3 100644 --- a/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.swagger_doc_generated.go +++ b/vendor/open-cluster-management.io/api/work/v1alpha1/zz_generated.swagger_doc_generated.go @@ -49,9 +49,10 @@ func (ManifestWorkReplicaSetSpec) SwaggerDoc() map[string]string { } var map_ManifestWorkReplicaSetStatus = map[string]string{ - "": "ManifestWorkReplicaSetStatus defines the observed state of ManifestWorkReplicaSet", - "conditions": "Conditions contains the different condition statuses for distrbution of ManifestWork resources Valid condition types are: 1. AppliedManifestWorks represents ManifestWorks have been distributed as per placement All, Partial, None, Problem 2. PlacementRefValid", - "summary": "Summary totals of resulting ManifestWorks", + "": "ManifestWorkReplicaSetStatus defines the observed state of ManifestWorkReplicaSet", + "conditions": "Conditions contains the different condition statuses for distrbution of ManifestWork resources Valid condition types are: 1. AppliedManifestWorks represents ManifestWorks have been distributed as per placement All, Partial, None, Problem 2. PlacementRefValid", + "summary": "Summary totals of resulting ManifestWorks for all placements", + "placementSummary": "PlacementRef Summary", } func (ManifestWorkReplicaSetStatus) SwaggerDoc() map[string]string { @@ -69,4 +70,15 @@ func (ManifestWorkReplicaSetSummary) SwaggerDoc() map[string]string { return map_ManifestWorkReplicaSetSummary } +var map_PlacementSummary = map[string]string{ + "": "PlacementSummary provides info regards number of clusters and clusterGroups selected by the placement refs.", + "name": "PlacementRef Name", + "availableDecisionGroups": "availableDecisionGroups shows number of decisionGroups that have all clusters manifestWorks in available state regards total number of decisionGroups. ex; 2/4 (2 out of 4)", + "summary": "Summary totals of resulting ManifestWorks for the placement", +} + +func (PlacementSummary) SwaggerDoc() map[string]string { + return map_PlacementSummary +} + // AUTO-GENERATED FUNCTIONS END HERE