From 35d3ec55693e2717febb72b4525b29026cfc5cd4 Mon Sep 17 00:00:00 2001 From: raaizik <132667934+raaizik@users.noreply.github.com> Date: Wed, 3 Jul 2024 22:18:07 +0300 Subject: [PATCH] Reverts deprecated ClusterClaims for odf-info Signed-off-by: raaizik <132667934+raaizik@users.noreply.github.com> --- config/rbac/role.yaml | 10 + .../ocsinitialization_controller.go | 57 ++- .../ocsinitialization_controller_test.go | 7 + controllers/storagecluster/odfinfoconfig.go | 13 +- .../storagecluster/odfinfoconfig_test.go | 4 +- .../storagecluster_controller_test.go | 5 + controllers/util/k8sutil.go | 17 + deploy/csv-templates/ocs-operator.csv.yaml.in | 10 + .../ocs-operator.clusterserviceversion.yaml | 10 + go.mod | 1 + go.sum | 2 + main.go | 2 + vendor/modules.txt | 3 + vendor/open-cluster-management.io/api/LICENSE | 201 +++++++++++ ...uster-management.io_clusterclaims.crd.yaml | 54 +++ ...anagement.io_addonplacementscores.crd.yaml | 153 ++++++++ .../api/cluster/v1alpha1/doc.go | 7 + .../api/cluster/v1alpha1/register.go | 40 +++ .../api/cluster/v1alpha1/types.go | 61 ++++ .../v1alpha1/types_addonplacementscore.go | 75 ++++ .../cluster/v1alpha1/types_rolloutstrategy.go | 148 ++++++++ .../cluster/v1alpha1/zz_generated.deepcopy.go | 335 ++++++++++++++++++ .../zz_generated.swagger_doc_generated.go | 147 ++++++++ 23 files changed, 1354 insertions(+), 8 deletions(-) create mode 100644 vendor/open-cluster-management.io/api/LICENSE create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_02_clusters.open-cluster-management.io_clusterclaims.crd.yaml create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_05_clusters.open-cluster-management.io_addonplacementscores.crd.yaml create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/doc.go create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/register.go create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/types_addonplacementscore.go create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/types_rolloutstrategy.go create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.deepcopy.go create mode 100644 vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go diff --git a/config/rbac/role.yaml b/config/rbac/role.yaml index 9f01922b25..6e53fc9d26 100644 --- a/config/rbac/role.yaml +++ b/config/rbac/role.yaml @@ -93,6 +93,16 @@ rules: - list - update - watch +- apiGroups: + - cluster.open-cluster-management.io + resources: + - clusterclaims + verbs: + - create + - get + - list + - update + - watch - apiGroups: - config.openshift.io resources: diff --git a/controllers/ocsinitialization/ocsinitialization_controller.go b/controllers/ocsinitialization/ocsinitialization_controller.go index f4b4dfda18..7bb3cea49f 100644 --- a/controllers/ocsinitialization/ocsinitialization_controller.go +++ b/controllers/ocsinitialization/ocsinitialization_controller.go @@ -15,6 +15,7 @@ import ( ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1" "github.com/red-hat-storage/ocs-operator/v4/controllers/defaults" "github.com/red-hat-storage/ocs-operator/v4/controllers/platform" + "github.com/red-hat-storage/ocs-operator/v4/controllers/storagecluster" "github.com/red-hat-storage/ocs-operator/v4/controllers/util" "github.com/red-hat-storage/ocs-operator/v4/templates" rookCephv1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1" @@ -28,6 +29,7 @@ import ( "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/klog/v2" "k8s.io/utils/ptr" + "open-cluster-management.io/api/cluster/v1alpha1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/builder" "sigs.k8s.io/controller-runtime/pkg/client" @@ -45,6 +47,7 @@ const ( random30CharacterString = "KP7TThmSTZegSGmHuPKLnSaaAHSG3RSgqw6akBj0oVk" PrometheusOperatorDeploymentName = "prometheus-operator" PrometheusOperatorCSVNamePrefix = "odf-prometheus-operator" + ClusterClaimCrdName = "clusterclaims.cluster.open-cluster-management.io" ) // InitNamespacedName returns a NamespacedName for the singleton instance that @@ -66,6 +69,7 @@ type OCSInitializationReconciler struct { SecurityClient secv1client.SecurityV1Interface OperatorNamespace string clusters *util.Clusters + availableCrds map[string]bool } // +kubebuilder:rbac:groups=ocs.openshift.io,resources=*,verbs=get;list;watch;create;update;patch;delete @@ -74,6 +78,7 @@ type OCSInitializationReconciler struct { // +kubebuilder:rbac:groups="monitoring.coreos.com",resources={alertmanagers,prometheuses},verbs=get;list;watch;create;update;patch;delete // +kubebuilder:rbac:groups="monitoring.coreos.com",resources=servicemonitors,verbs=get;list;watch;update;patch;create;delete // +kubebuilder:rbac:groups=operators.coreos.com,resources=clusterserviceversions,verbs=get;list;watch;delete;update;patch +// +kubebuilder:rbac:groups=cluster.open-cluster-management.io,resources=clusterclaims,verbs=get;list;watch;create;update // Reconcile reads that state of the cluster for a OCSInitialization object and makes changes based on the state read // and what is in the OCSInitialization.Spec @@ -142,6 +147,11 @@ func (r *OCSInitializationReconciler) Reconcile(ctx context.Context, request rec } } + r.availableCrds, err = util.MapCRDAvailability(r.ctx, r.Client, r.Log, ClusterClaimCrdName) + if err != nil { + return reconcile.Result{}, err + } + r.clusters, err = util.GetClusters(ctx, r.Client) if err != nil { r.Log.Error(err, "Failed to get clusters") @@ -169,6 +179,12 @@ func (r *OCSInitializationReconciler) Reconcile(ctx context.Context, request rec return reconcile.Result{}, err } + err = r.ensureClusterClaimExists() + if err != nil { + r.Log.Error(err, "Failed to ensure odf-info namespacedname ClusterClaim") + return reconcile.Result{}, err + } + err = r.ensureRookCephOperatorConfigExists(instance) if err != nil { r.Log.Error(err, "Failed to ensure rook-ceph-operator-config ConfigMap") @@ -252,7 +268,8 @@ func (r *OCSInitializationReconciler) SetupWithManager(mgr ctrl.Manager) error { return strings.HasPrefix(client.GetName(), PrometheusOperatorCSVNamePrefix) }, ) - return ctrl.NewControllerManagedBy(mgr). + + ocsInitializationController := ctrl.NewControllerManagedBy(mgr). For(&ocsv1.OCSInitialization{}, builder.WithPredicates(predicate.GenerationChangedPredicate{})). Owns(&corev1.Service{}). Owns(&corev1.Secret{}). @@ -333,8 +350,42 @@ func (r *OCSInitializationReconciler) SetupWithManager(mgr ctrl.Manager) error { }, ), builder.WithPredicates(prometheusPredicate), - ). - Complete(r) + ) + return ocsInitializationController.Complete(r) +} + +func (r *OCSInitializationReconciler) ensureClusterClaimExists() error { + if !r.availableCrds[ClusterClaimCrdName] && len(r.clusters.GetStorageClusters()) < 1 { + return nil + } + operatorNamespace, err := util.GetOperatorNamespace() + if err != nil { + r.Log.Error(err, "failed to get operator's namespace. retrying again") + return err + } + + OdfInfoNamespacedName := types.NamespacedName{ + Namespace: operatorNamespace, + Name: storagecluster.OdfInfoConfigMapName, + }.String() + + cc := &v1alpha1.ClusterClaim{ + ObjectMeta: metav1.ObjectMeta{ + Name: util.OdfInfoNamespacedNameClaimName, + }, + } + + _, err = controllerutil.CreateOrUpdate(r.ctx, r.Client, cc, func() error { + cc.Spec.Value = OdfInfoNamespacedName + return nil + }) + if err != nil { + r.Log.Error(err, "failed to create or update clusterclaim", "ClusterClaim", util.OdfInfoNamespacedNameClaimName) + return err + } + r.Log.Info("Created or updated clusterclaim", "ClusterClaim", cc.Name) + + return err } // ensureRookCephOperatorConfigExists ensures that the rook-ceph-operator-config cm exists diff --git a/controllers/ocsinitialization/ocsinitialization_controller_test.go b/controllers/ocsinitialization/ocsinitialization_controller_test.go index ca83968f23..f8272c89bf 100644 --- a/controllers/ocsinitialization/ocsinitialization_controller_test.go +++ b/controllers/ocsinitialization/ocsinitialization_controller_test.go @@ -17,6 +17,7 @@ import ( "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" + extensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" @@ -113,6 +114,12 @@ func createFakeScheme(t *testing.T) *runtime.Scheme { if err != nil { assert.Fail(t, "failed to add v1alpha1 scheme") } + + err = extensionsv1.AddToScheme(scheme) + if err != nil { + assert.Fail(t, "failed to add extensionsv1 scheme") + } + return scheme } diff --git a/controllers/storagecluster/odfinfoconfig.go b/controllers/storagecluster/odfinfoconfig.go index 2c48b2eb24..9e70860b9c 100644 --- a/controllers/storagecluster/odfinfoconfig.go +++ b/controllers/storagecluster/odfinfoconfig.go @@ -2,6 +2,7 @@ package storagecluster import ( "fmt" + "open-cluster-management.io/api/cluster/v1alpha1" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "strings" "sync" @@ -26,7 +27,7 @@ const ( rookCephMonSecretName = "rook-ceph-mon" fsidKey = "fsid" ocsOperatorNamePrefix = "ocs-operator" - odfInfoConfigMapName = "odf-info" + OdfInfoConfigMapName = "odf-info" odfInfoMapKind = "ConfigMap" ) @@ -46,7 +47,7 @@ func (obj *odfInfoConfig) ensureCreated(r *StorageClusterReconciler, storageClus odfInfoConfigMap := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: odfInfoConfigMapName, + Name: OdfInfoConfigMapName, Namespace: operatorNamespace, }, } @@ -91,7 +92,7 @@ func (obj *odfInfoConfig) ensureDeleted(r *StorageClusterReconciler, storageClus return reconcile.Result{}, err } odfInfoConfigMap := &corev1.ConfigMap{} - odfInfoConfigMap.Name = odfInfoConfigMapName + odfInfoConfigMap.Name = OdfInfoConfigMapName odfInfoConfigMap.Namespace = operatorNamespace if err = r.Client.Get(r.ctx, client.ObjectKeyFromObject(odfInfoConfigMap), odfInfoConfigMap); err != nil { if errors.IsNotFound(err) { @@ -114,6 +115,12 @@ func (obj *odfInfoConfig) ensureDeleted(r *StorageClusterReconciler, storageClus r.Log.Error(err, "Failed to delete odf-info config map.", "ConfigMap", client.ObjectKeyFromObject(odfInfoConfigMap)) return reconcile.Result{}, fmt.Errorf("failed to delete odf-info %v: %v", odfInfoConfigMap.Name, err) } + cc := &v1alpha1.ClusterClaim{} + cc.Name = util.OdfInfoNamespacedNameClaimName + if err = r.Client.Delete(r.ctx, cc); client.IgnoreNotFound(err) != nil { + r.Log.Error(err, "Failed to delete odf-info cluster claim.", "ClusterClaim", client.ObjectKeyFromObject(cc)) + return reconcile.Result{}, fmt.Errorf("failed to delete odf-info cluster claim %v: %v", cc.Name, err) + } } return reconcile.Result{}, nil } diff --git a/controllers/storagecluster/odfinfoconfig_test.go b/controllers/storagecluster/odfinfoconfig_test.go index 68ce89026c..964ef501e6 100644 --- a/controllers/storagecluster/odfinfoconfig_test.go +++ b/controllers/storagecluster/odfinfoconfig_test.go @@ -83,7 +83,7 @@ func TestOdfInfoConfig(t *testing.T) { configMap := &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ - Name: odfInfoConfigMapName, + Name: OdfInfoConfigMapName, Namespace: namespace, }, } @@ -127,7 +127,7 @@ func TestOdfInfoConfig(t *testing.T) { } // get the output err = r.Client.Get(r.ctx, client.ObjectKeyFromObject(configMap), configMap) - assert.NilError(t, err, "expected to find configmap %q: %+v", odfInfoConfigMapName, err) + assert.NilError(t, err, "expected to find configmap %q: %+v", OdfInfoConfigMapName, err) // compare with the expected results odfInfoDataOfStorageClusterKey := v1alpha1.OdfInfoData{} diff --git a/controllers/storagecluster/storagecluster_controller_test.go b/controllers/storagecluster/storagecluster_controller_test.go index 46c710e26d..0e664a59e2 100644 --- a/controllers/storagecluster/storagecluster_controller_test.go +++ b/controllers/storagecluster/storagecluster_controller_test.go @@ -4,6 +4,7 @@ import ( "context" "fmt" "net" + openv1alpha1 "open-cluster-management.io/api/cluster/v1alpha1" "os" "regexp" "testing" @@ -1249,6 +1250,10 @@ func createFakeScheme(t *testing.T) *runtime.Scheme { assert.Fail(t, "unable to add opv1a1 to scheme") } + err = openv1alpha1.AddToScheme(scheme) + if err != nil { + assert.Fail(t, "unable to add openv1alpha1 to scheme") + } return scheme } diff --git a/controllers/util/k8sutil.go b/controllers/util/k8sutil.go index 01a68536c8..71c1c08270 100644 --- a/controllers/util/k8sutil.go +++ b/controllers/util/k8sutil.go @@ -11,6 +11,7 @@ import ( ocsv1 "github.com/red-hat-storage/ocs-operator/api/v4/v1" corev1 "k8s.io/api/core/v1" storagev1 "k8s.io/api/storage/v1" + apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -42,6 +43,8 @@ const ( // This is the name for the OwnerUID FieldIndex OwnerUIDIndexName = "ownerUID" + + OdfInfoNamespacedNameClaimName = "odfinfo.odf.openshift.io" ) // GetWatchNamespace returns the namespace the operator should be watching for changes @@ -149,3 +152,17 @@ func GenerateNameForNonResilientCephBlockPoolSC(initData *ocsv1.StorageCluster) } return fmt.Sprintf("%s-ceph-non-resilient-rbd", initData.Name) } + +func MapCRDAvailability(ctx context.Context, clnt client.Client, log logr.Logger, crdNames ...string) (map[string]bool, error) { + crdExist := map[string]bool{} + for _, crdName := range crdNames { + crd := &apiextensionsv1.CustomResourceDefinition{} + crd.Name = crdName + if err := clnt.Get(ctx, client.ObjectKeyFromObject(crd), crd); client.IgnoreNotFound(err) != nil { + log.Error(err, fmt.Sprintf("Error getting CRD for %s", crdName)) + return nil, fmt.Errorf("error getting CRD, %v", err) + } + crdExist[crdName] = crd.UID != "" + } + return crdExist, nil +} diff --git a/deploy/csv-templates/ocs-operator.csv.yaml.in b/deploy/csv-templates/ocs-operator.csv.yaml.in index 0be47ececd..f47187d796 100644 --- a/deploy/csv-templates/ocs-operator.csv.yaml.in +++ b/deploy/csv-templates/ocs-operator.csv.yaml.in @@ -264,6 +264,16 @@ spec: - list - update - watch + - apiGroups: + - cluster.open-cluster-management.io + resources: + - clusterclaims + verbs: + - create + - get + - list + - update + - watch - apiGroups: - config.openshift.io resources: diff --git a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml index 3e0765bb70..e498be7820 100644 --- a/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml +++ b/deploy/ocs-operator/manifests/ocs-operator.clusterserviceversion.yaml @@ -273,6 +273,16 @@ spec: - list - update - watch + - apiGroups: + - cluster.open-cluster-management.io + resources: + - clusterclaims + verbs: + - create + - get + - list + - update + - watch - apiGroups: - config.openshift.io resources: diff --git a/go.mod b/go.mod index 86e386fad9..96b366e343 100644 --- a/go.mod +++ b/go.mod @@ -45,6 +45,7 @@ require ( k8s.io/client-go v0.30.3 k8s.io/klog/v2 v2.130.1 k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 + open-cluster-management.io/api v0.13.0 sigs.k8s.io/controller-runtime v0.18.4 sigs.k8s.io/yaml v1.4.0 ) diff --git a/go.sum b/go.sum index a630141ea6..0fbd922f59 100644 --- a/go.sum +++ b/go.sum @@ -1682,6 +1682,8 @@ k8s.io/utils v0.0.0-20221107191617-1a15be271d1d/go.mod h1:OLgZIPagt7ERELqWJFomSt k8s.io/utils v0.0.0-20221128185143-99ec85e7a448/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 h1:pUdcCO1Lk/tbT5ztQWOBi5HBgbBP1J8+AsQnQCKsi8A= k8s.io/utils v0.0.0-20240711033017-18e509b52bc8/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +open-cluster-management.io/api v0.13.0 h1:dlcJEZlNlE0DmSDctK2s7iWKg9l+Tgb0V78Z040nMuk= +open-cluster-management.io/api v0.13.0/go.mod h1:CuCPEzXDvOyxBB0H1d1eSeajbHqaeGEKq9c63vQc63w= 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/main.go b/main.go index 4782f7417d..aaa4154f57 100644 --- a/main.go +++ b/main.go @@ -51,6 +51,7 @@ import ( clientgoscheme "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "k8s.io/client-go/util/retry" + clusterv1alpha1 "open-cluster-management.io/api/cluster/v1alpha1" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/cache" apiclient "sigs.k8s.io/controller-runtime/pkg/client" @@ -90,6 +91,7 @@ func init() { utilruntime.Must(routev1.AddToScheme(scheme)) utilruntime.Must(quotav1.AddToScheme(scheme)) utilruntime.Must(ocsv1alpha1.AddToScheme(scheme)) + utilruntime.Must(clusterv1alpha1.AddToScheme(scheme)) utilruntime.Must(operatorsv1alpha1.AddToScheme(scheme)) utilruntime.Must(nadscheme.AddToScheme(scheme)) utilruntime.Must(ocsclientv1a1.AddToScheme(scheme)) diff --git a/vendor/modules.txt b/vendor/modules.txt index c1320bec73..d727c6b11e 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -933,6 +933,9 @@ k8s.io/utils/pointer k8s.io/utils/ptr k8s.io/utils/strings/slices k8s.io/utils/trace +# open-cluster-management.io/api v0.13.0 +## explicit; go 1.21 +open-cluster-management.io/api/cluster/v1alpha1 # sigs.k8s.io/container-object-storage-interface-api v0.1.0 ## explicit; go 1.18 sigs.k8s.io/container-object-storage-interface-api/apis diff --git a/vendor/open-cluster-management.io/api/LICENSE b/vendor/open-cluster-management.io/api/LICENSE new file mode 100644 index 0000000000..261eeb9e9f --- /dev/null +++ b/vendor/open-cluster-management.io/api/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_02_clusters.open-cluster-management.io_clusterclaims.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_02_clusters.open-cluster-management.io_clusterclaims.crd.yaml new file mode 100644 index 0000000000..5355bb16d7 --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_02_clusters.open-cluster-management.io_clusterclaims.crd.yaml @@ -0,0 +1,54 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: clusterclaims.cluster.open-cluster-management.io +spec: + group: cluster.open-cluster-management.io + names: + kind: ClusterClaim + listKind: ClusterClaimList + plural: clusterclaims + singular: clusterclaim + preserveUnknownFields: false + scope: Cluster + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: "ClusterClaim represents cluster information that a managed cluster + claims ClusterClaims with well known names include, 1. id.k8s.io, it contains + a unique identifier for the cluster. 2. clusterset.k8s.io, it contains an + identifier that relates the cluster to the ClusterSet in which it belongs. + \n ClusterClaims created on a managed cluster will be collected and saved + into the status of the corresponding ManagedCluster on hub." + 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 the ClusterClaim. + properties: + value: + description: Value is a claim-dependent string + maxLength: 1024 + minLength: 1 + type: string + type: object + type: object + served: true + storage: true +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_05_clusters.open-cluster-management.io_addonplacementscores.crd.yaml b/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_05_clusters.open-cluster-management.io_addonplacementscores.crd.yaml new file mode 100644 index 0000000000..1cfba5564a --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/0000_05_clusters.open-cluster-management.io_addonplacementscores.crd.yaml @@ -0,0 +1,153 @@ +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + name: addonplacementscores.cluster.open-cluster-management.io +spec: + group: cluster.open-cluster-management.io + names: + kind: AddOnPlacementScore + listKind: AddOnPlacementScoreList + plural: addonplacementscores + singular: addonplacementscore + preserveUnknownFields: false + scope: Namespaced + versions: + - name: v1alpha1 + schema: + openAPIV3Schema: + description: AddOnPlacementScore represents a bundle of scores of one managed + cluster, which could be used by placement. AddOnPlacementScore is a namespace + scoped resource. The namespace of the resource is the cluster namespace. + 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 + status: + description: Status represents the status of the AddOnPlacementScore. + properties: + conditions: + description: Conditions contain the different condition statuses for + this AddOnPlacementScore. + 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 + x-kubernetes-list-map-keys: + - type + x-kubernetes-list-type: map + scores: + description: Scores contain a list of score name and value of this + managed cluster. + items: + description: AddOnPlacementScoreItem represents the score name and + value. + properties: + name: + description: Name is the name of the score + type: string + value: + description: Value is the value of the score. The score range + is from -100 to 100. + format: int32 + maximum: 100 + minimum: -100 + type: integer + required: + - name + - value + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + validUntil: + description: ValidUntil defines the valid time of the scores. After + this time, the scores are considered to be invalid by placement. + nil means never expire. The controller owning this resource should + keep the scores up-to-date. + format: date-time + type: string + 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/v1alpha1/doc.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/doc.go new file mode 100644 index 0000000000..93f37581ca --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/doc.go @@ -0,0 +1,7 @@ +// Package v1alpha1 contains API Schema definitions for the cluster v1alpha1 API group +// +k8s:deepcopy-gen=package,register +// +k8s:openapi-gen=true + +// +kubebuilder:validation:Optional +// +groupName=cluster.open-cluster-management.io +package v1alpha1 diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/register.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/register.go new file mode 100644 index 0000000000..36b73ce2ff --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/register.go @@ -0,0 +1,40 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +var ( + GroupName = "cluster.open-cluster-management.io" + GroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"} + schemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + // Install is a function which adds this version to a scheme + Install = schemeBuilder.AddToScheme + + // SchemeGroupVersion generated code relies on this name + // Deprecated + SchemeGroupVersion = GroupVersion + // AddToScheme exists solely to keep the old generators creating valid code + // DEPRECATED + AddToScheme = schemeBuilder.AddToScheme +) + +// Resource generated code relies on this being here, but it logically belongs to the group +// DEPRECATED +func Resource(resource string) schema.GroupResource { + return schema.GroupResource{Group: GroupName, Resource: resource} +} + +// Adds the list of known types to api.Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(GroupVersion, + &AddOnPlacementScore{}, + &AddOnPlacementScoreList{}, + &ClusterClaim{}, + &ClusterClaimList{}, + ) + metav1.AddToGroupVersion(scheme, GroupVersion) + return nil +} diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go new file mode 100644 index 0000000000..6cb57bc3b4 --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types.go @@ -0,0 +1,61 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +genclient:nonNamespaced +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope="Cluster" + +// ClusterClaim represents cluster information that a managed cluster claims +// ClusterClaims with well known names include, +// 1. id.k8s.io, it contains a unique identifier for the cluster. +// 2. clusterset.k8s.io, it contains an identifier that relates the cluster +// to the ClusterSet in which it belongs. +// +// ClusterClaims created on a managed cluster will be collected and saved into +// the status of the corresponding ManagedCluster on hub. +type ClusterClaim struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec defines the attributes of the ClusterClaim. + Spec ClusterClaimSpec `json:"spec,omitempty"` +} + +type ClusterClaimSpec struct { + // Value is a claim-dependent string + // +kubebuilder:validation:MaxLength=1024 + // +kubebuilder:validation:MinLength=1 + Value string `json:"value,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ClusterClaimList is a collection of ClusterClaim. +type ClusterClaimList 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 ClusterClaim. + Items []ClusterClaim `json:"items"` +} + +// ReservedClusterClaimNames includes a list of reserved names for ClusterNames. +// When exposing ClusterClaims created on managed cluster, the registration agent gives high +// priority to the reserved ClusterClaims. +var ReservedClusterClaimNames = [...]string{ + // unique identifier for the cluster + "id.k8s.io", + // kubernetes version + "kubeversion.open-cluster-management.io", + // platform the managed cluster is running on, like AWS, GCE, and Equinix Metal + "platform.open-cluster-management.io", + // product name, like OpenShift, Anthos, EKS and GKE + "product.open-cluster-management.io", +} diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_addonplacementscore.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_addonplacementscore.go new file mode 100644 index 0000000000..1ce73580bd --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_addonplacementscore.go @@ -0,0 +1,75 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:resource:scope="Namespaced" +// +kubebuilder:subresource:status + +// AddOnPlacementScore represents a bundle of scores of one managed cluster, which could be used by placement. +// AddOnPlacementScore is a namespace scoped resource. The namespace of the resource is the cluster namespace. +type AddOnPlacementScore struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Status represents the status of the AddOnPlacementScore. + // +optional + Status AddOnPlacementScoreStatus `json:"status,omitempty"` +} + +// AddOnPlacementScoreStatus represents the current status of AddOnPlacementScore. +type AddOnPlacementScoreStatus struct { + // Conditions contain the different condition statuses for this AddOnPlacementScore. + // +patchMergeKey=type + // +patchStrategy=merge + // +listType=map + // +listMapKey=type + // +optional + Conditions []metav1.Condition `json:"conditions,omitempty"` + + // Scores contain a list of score name and value of this managed cluster. + // +listType=map + // +listMapKey=name + // +optional + Scores []AddOnPlacementScoreItem `json:"scores,omitempty"` + + // ValidUntil defines the valid time of the scores. + // After this time, the scores are considered to be invalid by placement. nil means never expire. + // The controller owning this resource should keep the scores up-to-date. + // +kubebuilder:validation:Type=string + // +kubebuilder:validation:Format=date-time + // +optional + ValidUntil *metav1.Time `json:"validUntil"` +} + +// AddOnPlacementScoreItem represents the score name and value. +type AddOnPlacementScoreItem struct { + // Name is the name of the score + // +kubebuilder:validation:Required + // +required + Name string `json:"name"` + + // Value is the value of the score. The score range is from -100 to 100. + // +kubebuilder:validation:Required + // +kubebuilder:validation:Minimum:=-100 + // +kubebuilder:validation:Maximum:=100 + // +required + Value int32 `json:"value"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// AddOnPlacementScoreList is a collection of AddOnPlacementScore. +type AddOnPlacementScoreList 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 AddOnPlacementScore + Items []AddOnPlacementScore `json:"items"` +} 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 new file mode 100644 index 0000000000..2c863bb50e --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/types_rolloutstrategy.go @@ -0,0 +1,148 @@ +package v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" +) + +// +k8s:deepcopy-gen=true + +// RolloutStrategy API used by workload applier APIs to define how the workload will be applied to +// the selected clusters by the Placement and DecisionStrategy. + +type RolloutType string + +const ( + //All means apply the workload to all clusters in the decision groups at once. + All RolloutType = "All" + //Progressive means apply the workload to the selected clusters progressively per cluster. + Progressive RolloutType = "Progressive" + //ProgressivePerGroup means apply the workload to the selected clusters progressively per group. + ProgressivePerGroup RolloutType = "ProgressivePerGroup" +) + +// Rollout strategy to apply workload to the selected clusters by Placement and DecisionStrategy. +type RolloutStrategy struct { + // 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 and haven't breached the MaxFailures configuration. + // 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 and haven't breached the MaxFailures configuration. + + // +kubebuilder:validation:Enum=All;Progressive;ProgressivePerGroup + // +kubebuilder:default:=All + // +optional + Type RolloutType `json:"type,omitempty"` + + // All defines required fields for RolloutStrategy type All + // +optional + All *RolloutAll `json:"all,omitempty"` + + // Progressive defines required fields for RolloutStrategy type Progressive + // +optional + Progressive *RolloutProgressive `json:"progressive,omitempty"` + + // ProgressivePerGroup defines required fields for RolloutStrategy type ProgressivePerGroup + // +optional + ProgressivePerGroup *RolloutProgressivePerGroup `json:"progressivePerGroup,omitempty"` +} + +// Timeout to consider while applying the workload. +type RolloutConfig struct { + // MinSuccessTime is a "soak" time. In other words, the minimum amount of time the workload + // applier controller will wait from the start of each rollout before proceeding (assuming a + // successful state has been reached and MaxFailures wasn't breached). + // MinSuccessTime is only considered for rollout types Progressive and ProgressivePerGroup. + // The default value is 0 meaning the workload applier proceeds immediately after a successful + // state is reached. + // MinSuccessTime must be defined in [0-9h]|[0-9m]|[0-9s] format examples; 2h , 90m , 360s + // +kubebuilder:default:="0" + // +optional + MinSuccessTime metav1.Duration `json:"minSuccessTime,omitempty"` + // ProgressDeadline defines how long workload applier controller will wait for the workload to + // reach a successful state in the cluster. + // If the workload does not reach a successful state after ProgressDeadline, will stop waiting + // and workload will be treated as "timeout" and be counted into MaxFailures. Once the MaxFailures + // is breached, the rollout will stop. + // ProgressDeadline default value is "None", meaning the workload applier will wait for a + // successful state indefinitely. + // ProgressDeadline must be defined in [0-9h]|[0-9m]|[0-9s] format examples; 2h , 90m , 360s + // +kubebuilder:validation:Pattern="^(([0-9])+[h|m|s])|None$" + // +kubebuilder:default:="None" + // +optional + ProgressDeadline string `json:"progressDeadline,omitempty"` + // MaxFailures is a percentage or number of clusters in the current rollout that can fail before + // proceeding to the next rollout. Fail means the cluster has a failed status or timeout status + // (does not reach successful status after ProgressDeadline). + // Once the MaxFailures is breached, the rollout will stop. + // MaxFailures is only considered for rollout types Progressive and ProgressivePerGroup. For + // Progressive, this is considered over the total number of clusters. For ProgressivePerGroup, + // this is considered according to the size of the current group. For both Progressive and + // ProgressivePerGroup, the MaxFailures does not apply for MandatoryDecisionGroups, which tolerate + // no failures. + // Default is that no failures are tolerated. + // +kubebuilder:validation:Pattern="^((100|[0-9]{1,2})%|[0-9]+)$" + // +kubebuilder:validation:XIntOrString + // +kubebuilder:default=0 + // +optional + MaxFailures intstr.IntOrString `json:"maxFailures,omitempty"` +} + +// MandatoryDecisionGroup set the decision group name or group index. +// GroupName is considered first to select the decisionGroups then GroupIndex. +type MandatoryDecisionGroup struct { + // GroupName of the decision group should match the placementDecisions label value with label key + // cluster.open-cluster-management.io/decision-group-name + // +optional + GroupName string `json:"groupName,omitempty"` + + // GroupIndex of the decision group should match the placementDecisions label value with label key + // cluster.open-cluster-management.io/decision-group-index + // +optional + GroupIndex int32 `json:"groupIndex,omitempty"` +} + +// MandatoryDecisionGroups +type MandatoryDecisionGroups struct { + // 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 + // +optional + MandatoryDecisionGroups []MandatoryDecisionGroup `json:"mandatoryDecisionGroups,omitempty"` +} + +// RolloutAll is a RolloutStrategy Type +type RolloutAll struct { + // +optional + RolloutConfig `json:",inline"` +} + +// RolloutProgressivePerGroup is a RolloutStrategy Type +type RolloutProgressivePerGroup struct { + // +optional + RolloutConfig `json:",inline"` + + // +optional + MandatoryDecisionGroups `json:",inline"` +} + +// RolloutProgressive is a RolloutStrategy Type +type RolloutProgressive struct { + // +optional + RolloutConfig `json:",inline"` + + // +optional + 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]+)$" + // +kubebuilder:validation:XIntOrString + // +optional + MaxConcurrency intstr.IntOrString `json:"maxConcurrency,omitempty"` +} 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 new file mode 100644 index 0000000000..e40f74e4d2 --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.deepcopy.go @@ -0,0 +1,335 @@ +//go:build !ignore_autogenerated +// +build !ignore_autogenerated + +// Code generated by deepcopy-gen. DO NOT EDIT. + +package v1alpha1 + +import ( + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddOnPlacementScore) DeepCopyInto(out *AddOnPlacementScore) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnPlacementScore. +func (in *AddOnPlacementScore) DeepCopy() *AddOnPlacementScore { + if in == nil { + return nil + } + out := new(AddOnPlacementScore) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AddOnPlacementScore) 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 *AddOnPlacementScoreItem) DeepCopyInto(out *AddOnPlacementScoreItem) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnPlacementScoreItem. +func (in *AddOnPlacementScoreItem) DeepCopy() *AddOnPlacementScoreItem { + if in == nil { + return nil + } + out := new(AddOnPlacementScoreItem) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *AddOnPlacementScoreList) DeepCopyInto(out *AddOnPlacementScoreList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]AddOnPlacementScore, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnPlacementScoreList. +func (in *AddOnPlacementScoreList) DeepCopy() *AddOnPlacementScoreList { + if in == nil { + return nil + } + out := new(AddOnPlacementScoreList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *AddOnPlacementScoreList) 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 *AddOnPlacementScoreStatus) DeepCopyInto(out *AddOnPlacementScoreStatus) { + *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]) + } + } + if in.Scores != nil { + in, out := &in.Scores, &out.Scores + *out = make([]AddOnPlacementScoreItem, len(*in)) + copy(*out, *in) + } + if in.ValidUntil != nil { + in, out := &in.ValidUntil, &out.ValidUntil + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AddOnPlacementScoreStatus. +func (in *AddOnPlacementScoreStatus) DeepCopy() *AddOnPlacementScoreStatus { + if in == nil { + return nil + } + out := new(AddOnPlacementScoreStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ClusterClaim) DeepCopyInto(out *ClusterClaim) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaim. +func (in *ClusterClaim) DeepCopy() *ClusterClaim { + if in == nil { + return nil + } + out := new(ClusterClaim) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterClaim) 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 *ClusterClaimList) DeepCopyInto(out *ClusterClaimList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]ClusterClaim, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaimList. +func (in *ClusterClaimList) DeepCopy() *ClusterClaimList { + if in == nil { + return nil + } + out := new(ClusterClaimList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *ClusterClaimList) 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 *ClusterClaimSpec) DeepCopyInto(out *ClusterClaimSpec) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ClusterClaimSpec. +func (in *ClusterClaimSpec) DeepCopy() *ClusterClaimSpec { + if in == nil { + return nil + } + out := new(ClusterClaimSpec) + 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 + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MandatoryDecisionGroup. +func (in *MandatoryDecisionGroup) DeepCopy() *MandatoryDecisionGroup { + if in == nil { + return nil + } + out := new(MandatoryDecisionGroup) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *MandatoryDecisionGroups) DeepCopyInto(out *MandatoryDecisionGroups) { + *out = *in + if in.MandatoryDecisionGroups != nil { + in, out := &in.MandatoryDecisionGroups, &out.MandatoryDecisionGroups + *out = make([]MandatoryDecisionGroup, len(*in)) + copy(*out, *in) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MandatoryDecisionGroups. +func (in *MandatoryDecisionGroups) DeepCopy() *MandatoryDecisionGroups { + if in == nil { + return nil + } + out := new(MandatoryDecisionGroups) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutAll) DeepCopyInto(out *RolloutAll) { + *out = *in + out.RolloutConfig = in.RolloutConfig + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutAll. +func (in *RolloutAll) DeepCopy() *RolloutAll { + if in == nil { + return nil + } + out := new(RolloutAll) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutConfig) DeepCopyInto(out *RolloutConfig) { + *out = *in + out.MinSuccessTime = in.MinSuccessTime + out.MaxFailures = in.MaxFailures + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutConfig. +func (in *RolloutConfig) DeepCopy() *RolloutConfig { + if in == nil { + return nil + } + out := new(RolloutConfig) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutProgressive) DeepCopyInto(out *RolloutProgressive) { + *out = *in + out.RolloutConfig = in.RolloutConfig + in.MandatoryDecisionGroups.DeepCopyInto(&out.MandatoryDecisionGroups) + out.MaxConcurrency = in.MaxConcurrency + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutProgressive. +func (in *RolloutProgressive) DeepCopy() *RolloutProgressive { + if in == nil { + return nil + } + out := new(RolloutProgressive) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RolloutProgressivePerGroup) DeepCopyInto(out *RolloutProgressivePerGroup) { + *out = *in + out.RolloutConfig = in.RolloutConfig + in.MandatoryDecisionGroups.DeepCopyInto(&out.MandatoryDecisionGroups) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutProgressivePerGroup. +func (in *RolloutProgressivePerGroup) DeepCopy() *RolloutProgressivePerGroup { + if in == nil { + return nil + } + out := new(RolloutProgressivePerGroup) + 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 + if in.All != nil { + in, out := &in.All, &out.All + *out = new(RolloutAll) + **out = **in + } + if in.Progressive != nil { + in, out := &in.Progressive, &out.Progressive + *out = new(RolloutProgressive) + (*in).DeepCopyInto(*out) + } + if in.ProgressivePerGroup != nil { + in, out := &in.ProgressivePerGroup, &out.ProgressivePerGroup + *out = new(RolloutProgressivePerGroup) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RolloutStrategy. +func (in *RolloutStrategy) DeepCopy() *RolloutStrategy { + if in == nil { + return nil + } + out := new(RolloutStrategy) + in.DeepCopyInto(out) + return out +} diff --git a/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go b/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go new file mode 100644 index 0000000000..64c51d2466 --- /dev/null +++ b/vendor/open-cluster-management.io/api/cluster/v1alpha1/zz_generated.swagger_doc_generated.go @@ -0,0 +1,147 @@ +package v1alpha1 + +// This file contains a collection of methods that can be used from go-restful to +// generate Swagger API documentation for its models. Please read this PR for more +// information on the implementation: https://github.com/emicklei/go-restful/pull/215 +// +// TODOs are ignored from the parser (e.g. TODO(andronat):... || TODO:...) if and only if +// they are on one line! For multiple line or blocks that you want to ignore use ---. +// Any context after a --- is ignored. +// +// Those methods can be generated by using hack/update-swagger-docs.sh + +// AUTO-GENERATED FUNCTIONS START HERE +var map_ClusterClaim = map[string]string{ + "": "ClusterClaim represents cluster information that a managed cluster claims ClusterClaims with well known names include,\n 1. id.k8s.io, it contains a unique identifier for the cluster.\n 2. clusterset.k8s.io, it contains an identifier that relates the cluster\n to the ClusterSet in which it belongs.\n\nClusterClaims created on a managed cluster will be collected and saved into the status of the corresponding ManagedCluster on hub.", + "spec": "Spec defines the attributes of the ClusterClaim.", +} + +func (ClusterClaim) SwaggerDoc() map[string]string { + return map_ClusterClaim +} + +var map_ClusterClaimList = map[string]string{ + "": "ClusterClaimList is a collection of ClusterClaim.", + "metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "items": "Items is a list of ClusterClaim.", +} + +func (ClusterClaimList) SwaggerDoc() map[string]string { + return map_ClusterClaimList +} + +var map_ClusterClaimSpec = map[string]string{ + "value": "Value is a claim-dependent string", +} + +func (ClusterClaimSpec) SwaggerDoc() map[string]string { + return map_ClusterClaimSpec +} + +var map_AddOnPlacementScore = map[string]string{ + "": "AddOnPlacementScore represents a bundle of scores of one managed cluster, which could be used by placement. AddOnPlacementScore is a namespace scoped resource. The namespace of the resource is the cluster namespace.", + "status": "Status represents the status of the AddOnPlacementScore.", +} + +func (AddOnPlacementScore) SwaggerDoc() map[string]string { + return map_AddOnPlacementScore +} + +var map_AddOnPlacementScoreItem = map[string]string{ + "": "AddOnPlacementScoreItem represents the score name and value.", + "name": "Name is the name of the score", + "value": "Value is the value of the score. The score range is from -100 to 100.", +} + +func (AddOnPlacementScoreItem) SwaggerDoc() map[string]string { + return map_AddOnPlacementScoreItem +} + +var map_AddOnPlacementScoreList = map[string]string{ + "": "AddOnPlacementScoreList is a collection of AddOnPlacementScore.", + "metadata": "Standard list metadata. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#types-kinds", + "items": "Items is a list of AddOnPlacementScore", +} + +func (AddOnPlacementScoreList) SwaggerDoc() map[string]string { + return map_AddOnPlacementScoreList +} + +var map_AddOnPlacementScoreStatus = map[string]string{ + "": "AddOnPlacementScoreStatus represents the current status of AddOnPlacementScore.", + "conditions": "Conditions contain the different condition statuses for this AddOnPlacementScore.", + "scores": "Scores contain a list of score name and value of this managed cluster.", + "validUntil": "ValidUntil defines the valid time of the scores. After this time, the scores are considered to be invalid by placement. nil means never expire. The controller owning this resource should keep the scores up-to-date.", +} + +func (AddOnPlacementScoreStatus) SwaggerDoc() map[string]string { + return map_AddOnPlacementScoreStatus +} + +var map_MandatoryDecisionGroup = map[string]string{ + "": "MandatoryDecisionGroup set the decision group name or group index. GroupName is considered first to select the decisionGroups then GroupIndex.", + "groupName": "GroupName of the decision group should match the placementDecisions label value with label key cluster.open-cluster-management.io/decision-group-name", + "groupIndex": "GroupIndex of the decision group should match the placementDecisions label value with label key cluster.open-cluster-management.io/decision-group-index", +} + +func (MandatoryDecisionGroup) SwaggerDoc() map[string]string { + return map_MandatoryDecisionGroup +} + +var map_MandatoryDecisionGroups = map[string]string{ + "": "MandatoryDecisionGroups", + "mandatoryDecisionGroups": "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", +} + +func (MandatoryDecisionGroups) SwaggerDoc() map[string]string { + return map_MandatoryDecisionGroups +} + +var map_RolloutAll = map[string]string{ + "": "RolloutAll is a RolloutStrategy Type", +} + +func (RolloutAll) SwaggerDoc() map[string]string { + return map_RolloutAll +} + +var map_RolloutConfig = map[string]string{ + "": "Timeout to consider while applying the workload.", + "minSuccessTime": "MinSuccessTime is a \"soak\" time. In other words, the minimum amount of time the workload applier controller will wait from the start of each rollout before proceeding (assuming a successful state has been reached and MaxFailures wasn't breached). MinSuccessTime is only considered for rollout types Progressive and ProgressivePerGroup. The default value is 0 meaning the workload applier proceeds immediately after a successful state is reached. MinSuccessTime must be defined in [0-9h]|[0-9m]|[0-9s] format examples; 2h , 90m , 360s", + "progressDeadline": "ProgressDeadline defines how long workload applier controller will wait for the workload to reach a successful state in the cluster. If the workload does not reach a successful state after ProgressDeadline, will stop waiting and workload will be treated as \"timeout\" and be counted into MaxFailures. Once the MaxFailures is breached, the rollout will stop. ProgressDeadline default value is \"None\", meaning the workload applier will wait for a successful state indefinitely. ProgressDeadline must be defined in [0-9h]|[0-9m]|[0-9s] format examples; 2h , 90m , 360s", + "maxFailures": "MaxFailures is a percentage or number of clusters in the current rollout that can fail before proceeding to the next rollout. Fail means the cluster has a failed status or timeout status (does not reach successful status after ProgressDeadline). Once the MaxFailures is breached, the rollout will stop. MaxFailures is only considered for rollout types Progressive and ProgressivePerGroup. For Progressive, this is considered over the total number of clusters. For ProgressivePerGroup, this is considered according to the size of the current group. For both Progressive and ProgressivePerGroup, the MaxFailures does not apply for MandatoryDecisionGroups, which tolerate no failures. Default is that no failures are tolerated.", +} + +func (RolloutConfig) SwaggerDoc() map[string]string { + return map_RolloutConfig +} + +var map_RolloutProgressive = map[string]string{ + "": "RolloutProgressive is a RolloutStrategy Type", + "maxConcurrency": "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.", +} + +func (RolloutProgressive) SwaggerDoc() map[string]string { + return map_RolloutProgressive +} + +var map_RolloutProgressivePerGroup = map[string]string{ + "": "RolloutProgressivePerGroup is a RolloutStrategy Type", +} + +func (RolloutProgressivePerGroup) SwaggerDoc() map[string]string { + return map_RolloutProgressivePerGroup +} + +var map_RolloutStrategy = map[string]string{ + "": "Rollout strategy to apply workload to the selected clusters by Placement and DecisionStrategy.", + "all": "All defines required fields for RolloutStrategy type All", + "progressive": "Progressive defines required fields for RolloutStrategy type Progressive", + "progressivePerGroup": "ProgressivePerGroup defines required fields for RolloutStrategy type ProgressivePerGroup", +} + +func (RolloutStrategy) SwaggerDoc() map[string]string { + return map_RolloutStrategy +} + +// AUTO-GENERATED FUNCTIONS END HERE