diff --git a/cmd/machine-api-operator/start.go b/cmd/machine-api-operator/start.go index c23a3844ac2092c382d3e859a46a5973734fda95..de1d1abdad25ea1959ef7508ef1cd5f53dc9a921 100644 --- a/cmd/machine-api-operator/start.go +++ b/cmd/machine-api-operator/start.go @@ -9,7 +9,6 @@ import ( "strconv" osconfigv1 "github.com/openshift/api/config/v1" - "github.com/openshift/machine-api-operator/pkg/metrics" "github.com/openshift/machine-api-operator/pkg/operator" "github.com/openshift/machine-api-operator/pkg/util" diff --git a/go.mod b/go.mod index aa4aa0af8c963ec0e16ffa57594ef4dcc564287d..c450932567d1c7709fe707d425745b7972d5e2c1 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/onsi/gomega v1.17.0 github.com/openshift/api v0.0.0-20211215120111-7c47a5f63470 github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 - github.com/openshift/library-go v0.0.0-20211214183058-58531ccbde67 + github.com/openshift/library-go v0.0.0-20211220195323-eca2c467c492 github.com/operator-framework/operator-sdk v0.5.1-0.20190301204940-c2efe6f74e7b github.com/prometheus/client_golang v1.11.0 github.com/spf13/cobra v1.2.1 diff --git a/go.sum b/go.sum index 3635dab6adfa6c19445635bba1c1a84d4c655c38..78f1f4a6e005c90ed4ae93a9fa50bff2e4c1d70d 100644 --- a/go.sum +++ b/go.sum @@ -70,6 +70,7 @@ github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbt github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/RangelReale/osincli v0.0.0-20160924135400-fababb0555f2/go.mod h1:XyjUkMA8GN+tOOPXvnbi3XuRxWFvTJntqvTFnjmhzbk= github.com/agnivade/levenshtein v1.0.1/go.mod h1:CURSv5d9Uaml+FovSIICkLbAUZ9S4RqaHDIsdSBg7lM= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= @@ -537,12 +538,11 @@ github.com/openshift/api v0.0.0-20211209135129-c58d9f695577/go.mod h1:DoslCwtqUp github.com/openshift/api v0.0.0-20211215120111-7c47a5f63470 h1:kYVTSbYsfLxSBnK8Z2ZN+qgAdclXAf2mYVDyHDfxTZ0= github.com/openshift/api v0.0.0-20211215120111-7c47a5f63470/go.mod h1:F/eU6jgr6Q2VhMu1mSpMmygxAELd7+BUxs3NHZ25jV4= github.com/openshift/build-machinery-go v0.0.0-20210712174854-1bb7fd1518d3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= -github.com/openshift/build-machinery-go v0.0.0-20210806203541-4ea9b6da3a37/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= github.com/openshift/build-machinery-go v0.0.0-20211213093930-7e33a7eb4ce3/go.mod h1:b1BuldmJlbA/xYtdZvKi+7j5YGB44qJUJDZ9zwiNCfE= github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3 h1:SG1aqwleU6bGD0X4mhkTNupjVnByMYYuW4XbnCPavQU= github.com/openshift/client-go v0.0.0-20211209144617-7385dd6338e3/go.mod h1:cwhyki5lqBmrT0m8Im+9I7PGFaraOzcYPtEz93RcsGY= -github.com/openshift/library-go v0.0.0-20211214183058-58531ccbde67 h1:wNd5jvgf9kXsyT+z11aBlh5spqKPNwsQKplrJRx4nsc= -github.com/openshift/library-go v0.0.0-20211214183058-58531ccbde67/go.mod h1:M/Gi/GUUrMdSS07nrYtTiK43J6/VUAyk/+IfN4ZqUY4= +github.com/openshift/library-go v0.0.0-20211220195323-eca2c467c492 h1:oj/rSQqVWVj6YJUydZwLz2frrJreiyI4oa9g/YPgMsM= +github.com/openshift/library-go v0.0.0-20211220195323-eca2c467c492/go.mod h1:4UQ9snU1vg53fyTpHQw3vLPiAxI8ub5xrc+y8KPQQFs= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/operator-framework/operator-sdk v0.5.1-0.20190301204940-c2efe6f74e7b h1:Q1q8w51pAZdx6LEkaYdSbUaaEOHXTyTXLhtGgIiKaiA= github.com/operator-framework/operator-sdk v0.5.1-0.20190301204940-c2efe6f74e7b/go.mod h1:iVyukRkam5JZa8AnjYf+/G3rk7JI1+M6GsU0sq0B9NA= diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go index 2f952f5c598a72d163472c26fbc7b1aa81e99b0c..1ffee4f80db22ffbed818c7b7cd7814aee904616 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/core.go @@ -337,16 +337,10 @@ func ApplyConfigMapImproved(ctx context.Context, client coreclientv1.ConfigMapsG // ApplySecret merges objectmeta, requires data func ApplySecretImproved(ctx context.Context, client coreclientv1.SecretsGetter, recorder events.Recorder, requiredInput *corev1.Secret, cache ResourceCache) (*corev1.Secret, bool, error) { + // copy the stringData to data. Error on a data content conflict inside required. This is usually a bug. + existing, err := client.Secrets(requiredInput.Namespace).Get(ctx, requiredInput.Name, metav1.GetOptions{}) - if apierrors.IsNotFound(err) { - requiredCopy := requiredInput.DeepCopy() - actual, err := client.Secrets(requiredCopy.Namespace). - Create(ctx, resourcemerge.WithCleanLabelsAndAnnotations(requiredCopy).(*corev1.Secret), metav1.CreateOptions{}) - reportCreateEvent(recorder, requiredCopy, err) - cache.UpdateCachedResourceMetadata(requiredInput, actual) - return actual, true, err - } - if err != nil { + if err != nil && !apierrors.IsNotFound(err) { return nil, false, err } @@ -354,7 +348,6 @@ func ApplySecretImproved(ctx context.Context, client coreclientv1.SecretsGetter, return existing, false, nil } - // copy the stringData to data. Error on a data content conflict inside required. This is usually a bug. required := requiredInput.DeepCopy() if required.Data == nil { required.Data = map[string][]byte{} @@ -369,6 +362,18 @@ func ApplySecretImproved(ctx context.Context, client coreclientv1.SecretsGetter, } required.StringData = nil + if apierrors.IsNotFound(err) { + requiredCopy := required.DeepCopy() + actual, err := client.Secrets(requiredCopy.Namespace). + Create(ctx, resourcemerge.WithCleanLabelsAndAnnotations(requiredCopy).(*corev1.Secret), metav1.CreateOptions{}) + reportCreateEvent(recorder, requiredCopy, err) + cache.UpdateCachedResourceMetadata(requiredInput, actual) + return actual, true, err + } + if err != nil { + return nil, false, err + } + existingCopy := existing.DeepCopy() resourcemerge.EnsureObjectMeta(resourcemerge.BoolPtr(false), &existingCopy.ObjectMeta, required.ObjectMeta) @@ -397,7 +402,7 @@ func ApplySecretImproved(ctx context.Context, client coreclientv1.SecretsGetter, } if equality.Semantic.DeepEqual(existingCopy, existing) { - cache.UpdateCachedResourceMetadata(required, existingCopy) + cache.UpdateCachedResourceMetadata(requiredInput, existingCopy) return existing, false, nil } @@ -431,7 +436,7 @@ func ApplySecretImproved(ctx context.Context, client coreclientv1.SecretsGetter, existingCopy.ResourceVersion = "" actual, err = client.Secrets(required.Namespace).Create(ctx, existingCopy, metav1.CreateOptions{}) reportCreateEvent(recorder, existingCopy, err) - cache.UpdateCachedResourceMetadata(required, actual) + cache.UpdateCachedResourceMetadata(requiredInput, actual) return actual, true, err } diff --git a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/resource_cache.go b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/resource_cache.go index 2ff94536e1cb16b925961aab59a65c5eaeec7025..daa1a5e15400d43700d36b9682a44ece5c36c578 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/resource_cache.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/resource/resourceapply/resource_cache.go @@ -4,6 +4,7 @@ import ( "crypto/md5" "fmt" "io" + "reflect" "k8s.io/apimachinery/pkg/api/meta" "k8s.io/apimachinery/pkg/runtime" @@ -42,10 +43,16 @@ func NewResourceCache() *resourceCache { var noCache *resourceCache func getResourceMetadata(obj runtime.Object) (schema.GroupKind, string, string, string, error) { + if obj == nil { + return schema.GroupKind{}, "", "", "", fmt.Errorf("nil object has no metadata") + } metadata, err := meta.Accessor(obj) if err != nil { return schema.GroupKind{}, "", "", "", err } + if metadata == nil || reflect.ValueOf(metadata).IsNil() { + return schema.GroupKind{}, "", "", "", fmt.Errorf("object has no metadata") + } resourceHash := hashOfResourceStruct(obj) // retrieve kind, sometimes this can be done via the accesor, sometimes not (depends on the type) @@ -66,10 +73,16 @@ func getResourceMetadata(obj runtime.Object) (schema.GroupKind, string, string, } func getResourceVersion(obj runtime.Object) (string, error) { + if obj == nil { + return "", fmt.Errorf("nil object has no resourceVersion") + } metadata, err := meta.Accessor(obj) if err != nil { return "", err } + if metadata == nil || reflect.ValueOf(metadata).IsNil() { + return "", fmt.Errorf("object has no metadata") + } rv := metadata.GetResourceVersion() if len(rv) == 0 { return "", fmt.Errorf("missing resourceVersion") diff --git a/vendor/modules.txt b/vendor/modules.txt index 7dcffc151eaf9ce4ac1b4cc2a6b51e09eed59a63..73666c7755d367e53b58f002eb4a6a42d859702c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -269,7 +269,7 @@ github.com/openshift/client-go/machine/informers/externalversions/internalinterf github.com/openshift/client-go/machine/informers/externalversions/machine github.com/openshift/client-go/machine/informers/externalversions/machine/v1beta1 github.com/openshift/client-go/machine/listers/machine/v1beta1 -# github.com/openshift/library-go v0.0.0-20211214183058-58531ccbde67 +# github.com/openshift/library-go v0.0.0-20211220195323-eca2c467c492 ## explicit; go 1.17 github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers github.com/openshift/library-go/pkg/config/clusterstatus