From 211d62e5bf42ff6cedd9ea48d4210a9e81babf59 Mon Sep 17 00:00:00 2001 From: Nolan Brubaker Date: Tue, 12 Mar 2024 15:37:15 -0400 Subject: [PATCH] : Replace library-go with PR branch for testing Signed-off-by: Nolan Brubaker --- go.mod | 2 + go.sum | 4 +- .../library-go/pkg/cloudprovider/OWNERS | 6 -- .../library-go/pkg/cloudprovider/external.go | 62 ------------- .../pkg/operator/certrotation/annotations.go | 2 +- .../pkg/operator/certrotation/target.go | 18 ++-- .../cloudprovider/observe_cloudprovider.go | 93 +------------------ vendor/modules.txt | 4 +- 8 files changed, 18 insertions(+), 173 deletions(-) delete mode 100644 vendor/github.com/openshift/library-go/pkg/cloudprovider/OWNERS delete mode 100644 vendor/github.com/openshift/library-go/pkg/cloudprovider/external.go diff --git a/go.mod b/go.mod index 21f074467c..70e3cb5b8e 100644 --- a/go.mod +++ b/go.mod @@ -125,3 +125,5 @@ require ( sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect sigs.k8s.io/yaml v1.3.0 // indirect ) + +replace github.com/openshift/library-go => github.com/nrb/library-go v0.0.0-20240312193121-4c6510d16cf1 diff --git a/go.sum b/go.sum index c5d0fd51b6..a96bfd5812 100644 --- a/go.sum +++ b/go.sum @@ -153,6 +153,8 @@ github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9G github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/nrb/library-go v0.0.0-20240312193121-4c6510d16cf1 h1:mH1Jhclg3BYiq4HiwiQhan19m3SwQhdH39kUvECuGjI= +github.com/nrb/library-go v0.0.0-20240312193121-4c6510d16cf1/go.mod h1:ePlaOqUiPplRc++6aYdMe+2FmXb2xTNS9Nz5laG2YmI= github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= @@ -163,8 +165,6 @@ github.com/openshift/build-machinery-go v0.0.0-20230228230858-4cd708338479 h1:IU github.com/openshift/build-machinery-go v0.0.0-20230228230858-4cd708338479/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= github.com/openshift/client-go v0.0.0-20231218155125-ff7d9f9bf415 h1:wfnn3E0Z62bB3wYM5eO1AZ9EYZpFd7M1p4PclcIyVv0= github.com/openshift/client-go v0.0.0-20231218155125-ff7d9f9bf415/go.mod h1:5W+xoimHjRdZ0dI/yeQR0ANRNLK9mPmXMzUWPAIPADo= -github.com/openshift/library-go v0.0.0-20240305144041-18ee8279b4e3 h1:9ReQNVTyhFwcMfLROKhpmry74ge+urWixmR/EMQajhY= -github.com/openshift/library-go v0.0.0-20240305144041-18ee8279b4e3/go.mod h1:ePlaOqUiPplRc++6aYdMe+2FmXb2xTNS9Nz5laG2YmI= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= diff --git a/vendor/github.com/openshift/library-go/pkg/cloudprovider/OWNERS b/vendor/github.com/openshift/library-go/pkg/cloudprovider/OWNERS deleted file mode 100644 index 39f49831bb..0000000000 --- a/vendor/github.com/openshift/library-go/pkg/cloudprovider/OWNERS +++ /dev/null @@ -1,6 +0,0 @@ -reviewers: - - JoelSpeed - - elmiko -approvers: - - JoelSpeed - - elmiko diff --git a/vendor/github.com/openshift/library-go/pkg/cloudprovider/external.go b/vendor/github.com/openshift/library-go/pkg/cloudprovider/external.go deleted file mode 100644 index 9af2688154..0000000000 --- a/vendor/github.com/openshift/library-go/pkg/cloudprovider/external.go +++ /dev/null @@ -1,62 +0,0 @@ -package cloudprovider - -import ( - "fmt" - - configv1 "github.com/openshift/api/config/v1" -) - -var ( - // ExternalCloudProviderFeature is the name of the external cloud provider feature gate. - // This is used to flag to operators that the cluster should be using the external cloud-controller-manager - // rather than the in-tree cloud controller loops. - ExternalCloudProviderFeature = configv1.FeatureGateExternalCloudProvider - - // ExternalCloudProviderFeatureAzure is the name of the external cloud provider feature gate for Azure. - ExternalCloudProviderFeatureAzure = configv1.FeatureGateExternalCloudProviderAzure - - // ExternalCloudProviderFeatureGCP is the name of the external cloud provider feature gate for GCP. - ExternalCloudProviderFeatureGCP = configv1.FeatureGateExternalCloudProviderGCP - - // ExternalCloudProviderFeatureExternal is the name of the external cloud provider feature gate for External platform. - ExternalCloudProviderFeatureExternal = configv1.FeatureGateExternalCloudProviderExternal -) - -// IsCloudProviderExternal is used to check whether external cloud provider settings should be used in a component. -// It checks whether the ExternalCloudProvider feature gate is enabled and whether the ExternalCloudProvider feature -// has been implemented for the platform. -func IsCloudProviderExternal(platformStatus *configv1.PlatformStatus) (bool, error) { - if platformStatus == nil { - return false, fmt.Errorf("platformStatus is required") - } - switch platformStatus.Type { - case configv1.AlibabaCloudPlatformType, - configv1.AWSPlatformType, - configv1.AzurePlatformType, - configv1.GCPPlatformType, - configv1.IBMCloudPlatformType, - configv1.KubevirtPlatformType, - configv1.NutanixPlatformType, - configv1.OpenStackPlatformType, - configv1.PowerVSPlatformType, - configv1.VSpherePlatformType: - return true, nil - case configv1.ExternalPlatformType: - return isExternalPlatformCCMEnabled(platformStatus) - default: - // Platforms that do not have external cloud providers implemented - return false, nil - } -} - -func isExternalPlatformCCMEnabled(platformStatus *configv1.PlatformStatus) (bool, error) { - if platformStatus == nil || platformStatus.External == nil { - return false, nil - } - - if platformStatus.External.CloudControllerManager.State == configv1.CloudControllerManagerExternal { - return true, nil - } - - return false, nil -} diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/annotations.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/annotations.go index bbf929861c..5ce9fa2934 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/annotations.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/annotations.go @@ -33,7 +33,7 @@ func (a AdditionalAnnotations) EnsureTLSMetadataUpdate(meta *metav1.ObjectMeta) modified = true } if len(a.AutoRegenerateAfterOfflineExpiry) > 0 && meta.Annotations[AutoRegenerateAfterOfflineExpiryAnnotation] != a.AutoRegenerateAfterOfflineExpiry { - meta.Annotations[AutoRegenerateAfterOfflineExpiryAnnotation] = a.Description + meta.Annotations[AutoRegenerateAfterOfflineExpiryAnnotation] = a.AutoRegenerateAfterOfflineExpiry modified = true } return modified diff --git a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target.go b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target.go index f7e37f4c81..9d8aacf7ed 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/certrotation/target.go @@ -74,7 +74,7 @@ type TargetCertCreator interface { // NewCertificate creates a new key-cert pair with the given signer. NewCertificate(signer *crypto.CA, validity time.Duration) (*crypto.TLSCertificateConfig, error) // NeedNewTargetCertKeyPair decides whether a new cert-key pair is needed. It returns a non-empty reason if it is the case. - NeedNewTargetCertKeyPair(currentSecretAnnotations map[string]string, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string + NeedNewTargetCertKeyPair(currentCertSecret *corev1.Secret, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string // SetAnnotations gives an option to override or set additional annotations SetAnnotations(cert *crypto.TLSCertificateConfig, annotations map[string]string) map[string]string } @@ -117,7 +117,7 @@ func (c RotatedSelfSignedCertKeySecret) EnsureTargetCertKeyPair(ctx context.Cont targetCertKeyPairSecret = actualTargetCertKeyPairSecret } - if reason := c.CertCreator.NeedNewTargetCertKeyPair(targetCertKeyPairSecret.Annotations, signingCertKeyPair, caBundleCerts, c.Refresh, c.RefreshOnlyWhenExpired); len(reason) > 0 { + if reason := c.CertCreator.NeedNewTargetCertKeyPair(targetCertKeyPairSecret, signingCertKeyPair, caBundleCerts, c.Refresh, c.RefreshOnlyWhenExpired); len(reason) > 0 { c.EventRecorder.Eventf("TargetUpdateRequired", "%q in %q requires a new target cert/key pair: %v", c.Name, c.Namespace, reason) if err := setTargetCertKeyPairSecret(targetCertKeyPairSecret, c.Validity, signingCertKeyPair, c.CertCreator, c.AdditionalAnnotations); err != nil { return nil, err @@ -252,8 +252,8 @@ func (r *ClientRotation) NewCertificate(signer *crypto.CA, validity time.Duratio return signer.MakeClientCertificateForDuration(r.UserInfo, validity) } -func (r *ClientRotation) NeedNewTargetCertKeyPair(annotations map[string]string, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string { - return needNewTargetCertKeyPair(annotations, signer, caBundleCerts, refresh, refreshOnlyWhenExpired) +func (r *ClientRotation) NeedNewTargetCertKeyPair(currentCertSecret *corev1.Secret, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string { + return needNewTargetCertKeyPair(currentCertSecret.Annotations, signer, caBundleCerts, refresh, refreshOnlyWhenExpired) } func (r *ClientRotation) SetAnnotations(cert *crypto.TLSCertificateConfig, annotations map[string]string) map[string]string { @@ -277,13 +277,13 @@ func (r *ServingRotation) RecheckChannel() <-chan struct{} { return r.HostnamesChanged } -func (r *ServingRotation) NeedNewTargetCertKeyPair(annotations map[string]string, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string { - reason := needNewTargetCertKeyPair(annotations, signer, caBundleCerts, refresh, refreshOnlyWhenExpired) +func (r *ServingRotation) NeedNewTargetCertKeyPair(currentCertSecret *corev1.Secret, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string { + reason := needNewTargetCertKeyPair(currentCertSecret.Annotations, signer, caBundleCerts, refresh, refreshOnlyWhenExpired) if len(reason) > 0 { return reason } - return r.missingHostnames(annotations) + return r.missingHostnames(currentCertSecret.Annotations) } func (r *ServingRotation) missingHostnames(annotations map[string]string) string { @@ -323,8 +323,8 @@ func (r *SignerRotation) NewCertificate(signer *crypto.CA, validity time.Duratio return crypto.MakeCAConfigForDuration(signerName, validity, signer) } -func (r *SignerRotation) NeedNewTargetCertKeyPair(annotations map[string]string, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string { - return needNewTargetCertKeyPair(annotations, signer, caBundleCerts, refresh, refreshOnlyWhenExpired) +func (r *SignerRotation) NeedNewTargetCertKeyPair(currentCertSecret *corev1.Secret, signer *crypto.CA, caBundleCerts []*x509.Certificate, refresh time.Duration, refreshOnlyWhenExpired bool) string { + return needNewTargetCertKeyPair(currentCertSecret.Annotations, signer, caBundleCerts, refresh, refreshOnlyWhenExpired) } func (r *SignerRotation) SetAnnotations(cert *crypto.TLSCertificateConfig, annotations map[string]string) map[string]string { diff --git a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/cloudprovider/observe_cloudprovider.go b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/cloudprovider/observe_cloudprovider.go index 8ee88e31ce..c0c3dcf55b 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/configobserver/cloudprovider/observe_cloudprovider.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/configobserver/cloudprovider/observe_cloudprovider.go @@ -1,17 +1,11 @@ package cloudprovider import ( - "fmt" - - "k8s.io/apimachinery/pkg/api/equality" "k8s.io/apimachinery/pkg/api/errors" - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/util/sets" corelisterv1 "k8s.io/client-go/listers/core/v1" configv1 "github.com/openshift/api/config/v1" configlistersv1 "github.com/openshift/client-go/config/listers/config/v1" - "github.com/openshift/library-go/pkg/cloudprovider" "github.com/openshift/library-go/pkg/operator/configobserver" "github.com/openshift/library-go/pkg/operator/events" "github.com/openshift/library-go/pkg/operator/resourcesynccontroller" @@ -33,12 +27,10 @@ type InfrastructureLister interface { // NewCloudProviderObserver returns a new cloudprovider observer for syncing cloud provider specific // information to controller-manager and api-server. -func NewCloudProviderObserver(targetNamespaceName string, skipCloudProviderExternal bool, cloudProviderNamePath, cloudProviderConfigPath []string) configobserver.ObserveConfigFunc { +func NewCloudProviderObserver(targetNamespaceName string, skipCloudProviderExternal bool) configobserver.ObserveConfigFunc { cloudObserver := &cloudProviderObserver{ targetNamespaceName: targetNamespaceName, skipCloudProviderExternal: skipCloudProviderExternal, - cloudProviderNamePath: cloudProviderNamePath, - cloudProviderConfigPath: cloudProviderConfigPath, } return cloudObserver.ObserveCloudProviderNames } @@ -46,14 +38,12 @@ func NewCloudProviderObserver(targetNamespaceName string, skipCloudProviderExter type cloudProviderObserver struct { targetNamespaceName string skipCloudProviderExternal bool - cloudProviderNamePath []string - cloudProviderConfigPath []string } // ObserveCloudProviderNames observes the cloud provider from the global cluster infrastructure resource. func (c *cloudProviderObserver) ObserveCloudProviderNames(genericListers configobserver.Listers, recorder events.Recorder, existingConfig map[string]interface{}) (ret map[string]interface{}, _ []error) { defer func() { - ret = configobserver.Pruned(ret, c.cloudProviderConfigPath, c.cloudProviderNamePath) + ret = configobserver.Pruned(ret) }() listers := genericListers.(InfrastructureLister) @@ -69,36 +59,14 @@ func (c *cloudProviderObserver) ObserveCloudProviderNames(genericListers configo return existingConfig, append(errs, err) } - external, err := cloudprovider.IsCloudProviderExternal(infrastructure.Status.PlatformStatus) - if err != nil { - recorder.Warningf("ObserveCloudProviderNames", "Could not determine external cloud provider state: %v", err) - return existingConfig, append(errs, err) - } - - // Still using in-tree cloud provider, fall back to setting provider information based on platform type. - cloudProvider := GetPlatformName(infrastructure.Status.Platform, recorder) - if external { - if !c.skipCloudProviderExternal { - if err := unstructured.SetNestedStringSlice(observedConfig, []string{"external"}, c.cloudProviderNamePath...); err != nil { - errs = append(errs, err) - } - } - } else if len(cloudProvider) > 0 { - if err := unstructured.SetNestedStringSlice(observedConfig, []string{cloudProvider}, c.cloudProviderNamePath...); err != nil { - errs = append(errs, err) - } - } - sourceCloudConfigMap := infrastructure.Spec.CloudConfig.Name sourceCloudConfigNamespace := configNamespace - sourceCloudConfigKey := infrastructure.Spec.CloudConfig.Key // If a managed cloud-provider config is available, it should be used instead of the default. If the configmap is not // found, the default values should be used. if _, err = listers.ConfigMapLister().ConfigMaps(machineSpecifiedConfigNamespace).Get(machineSpecifiedConfig); err == nil { sourceCloudConfigMap = machineSpecifiedConfig sourceCloudConfigNamespace = machineSpecifiedConfigNamespace - sourceCloudConfigKey = "cloud.conf" } else if !errors.IsNotFound(err) { return existingConfig, append(errs, err) } @@ -108,12 +76,6 @@ func (c *cloudProviderObserver) ObserveCloudProviderNames(genericListers configo Name: sourceCloudConfigMap, } - // we set cloudprovider configmap values only for some cloud providers. - validCloudProviders := sets.NewString("aws", "azure", "gce", "vsphere") - if !validCloudProviders.Has(cloudProvider) { - sourceCloudConfigMap = "" - } - if len(sourceCloudConfigMap) == 0 { sourceLocation = resourcesynccontroller.ResourceLocation{} } @@ -131,56 +93,5 @@ func (c *cloudProviderObserver) ObserveCloudProviderNames(genericListers configo return observedConfig, errs } - staticCloudConfFile := fmt.Sprintf(cloudProviderConfFilePath, sourceCloudConfigKey) - - if err := unstructured.SetNestedStringSlice(observedConfig, []string{staticCloudConfFile}, c.cloudProviderConfigPath...); err != nil { - recorder.Warningf("ObserveCloudProviderNames", "Failed setting cloud-config : %v", err) - return existingConfig, append(errs, err) - } - - existingCloudConfig, _, err := unstructured.NestedStringSlice(existingConfig, c.cloudProviderConfigPath...) - if err != nil { - errs = append(errs, err) - // keep going on read error from existing config - } - - if !equality.Semantic.DeepEqual(existingCloudConfig, []string{staticCloudConfFile}) { - recorder.Eventf("ObserveCloudProviderNamesChanges", "CloudProvider config file changed to %s", staticCloudConfFile) - } - return observedConfig, errs } - -// GetPlatformName returns the platform name as required by flags such as `cloud-provider`. -// If no in-tree cloud provider exists for a platform, an empty value will be returned. -func GetPlatformName(platformType configv1.PlatformType, recorder events.Recorder) string { - cloudProvider := "" - switch platformType { - case "": - recorder.Warningf("ObserveCloudProvidersFailed", "Required status.platform field is not set in infrastructures.%s/cluster", configv1.GroupName) - case configv1.AWSPlatformType: - cloudProvider = "aws" - case configv1.AzurePlatformType: - cloudProvider = "azure" - case configv1.VSpherePlatformType: - cloudProvider = "vsphere" - case configv1.BareMetalPlatformType: - case configv1.GCPPlatformType: - cloudProvider = "gce" - case configv1.LibvirtPlatformType: - case configv1.OpenStackPlatformType: - case configv1.IBMCloudPlatformType: - case configv1.NonePlatformType: - case configv1.NutanixPlatformType: - case configv1.OvirtPlatformType: - case configv1.KubevirtPlatformType: - case configv1.AlibabaCloudPlatformType: - case configv1.PowerVSPlatformType: - case configv1.ExternalPlatformType: - default: - // the new doc on the infrastructure fields requires that we treat an unrecognized thing the same bare metal. - // TODO find a way to indicate to the user that we didn't honor their choice - recorder.Warningf("ObserveCloudProvidersFailed", fmt.Sprintf("No recognized cloud provider platform found in infrastructures.%s/cluster.status.platform", configv1.GroupName)) - } - return cloudProvider -} diff --git a/vendor/modules.txt b/vendor/modules.txt index 755cda49bb..2ecd30a3b0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -334,12 +334,11 @@ github.com/openshift/client-go/operatorcontrolplane/informers/externalversions/i github.com/openshift/client-go/operatorcontrolplane/informers/externalversions/operatorcontrolplane github.com/openshift/client-go/operatorcontrolplane/informers/externalversions/operatorcontrolplane/v1alpha1 github.com/openshift/client-go/operatorcontrolplane/listers/operatorcontrolplane/v1alpha1 -# github.com/openshift/library-go v0.0.0-20240305144041-18ee8279b4e3 +# github.com/openshift/library-go v0.0.0-20240305144041-18ee8279b4e3 => github.com/nrb/library-go v0.0.0-20240312193121-4c6510d16cf1 ## explicit; go 1.21 github.com/openshift/library-go/pkg/assets github.com/openshift/library-go/pkg/authorization/hardcodedauthorizer github.com/openshift/library-go/pkg/certs -github.com/openshift/library-go/pkg/cloudprovider github.com/openshift/library-go/pkg/config/client github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers github.com/openshift/library-go/pkg/config/clusterstatus @@ -1467,3 +1466,4 @@ sigs.k8s.io/structured-merge-diff/v4/value # sigs.k8s.io/yaml v1.3.0 ## explicit; go 1.12 sigs.k8s.io/yaml +# github.com/openshift/library-go => github.com/nrb/library-go v0.0.0-20240312193121-4c6510d16cf1