From fe6158d71af1768ea64afb87724d3705ac947c08 Mon Sep 17 00:00:00 2001 From: Thomas Jungblut Date: Wed, 9 Oct 2024 10:30:40 +0200 Subject: [PATCH] update library go for teting --- go.mod | 1 + go.sum | 4 ++-- .../pkg/operator/status/status_controller.go | 19 +++++++++++++++++-- vendor/modules.txt | 3 ++- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index c68cc3e37..17a057ff5 100644 --- a/go.mod +++ b/go.mod @@ -141,5 +141,6 @@ require ( replace ( github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 + github.com/openshift/library-go => github.com/tjungblu/library-go v0.0.0-20241009082417-6872a5e7263f vbom.ml/util => github.com/fvbommel/util v0.0.0-20180919145318-efcd4e0f9787 ) diff --git a/go.sum b/go.sum index 9a2311061..c7c487ffc 100644 --- a/go.sum +++ b/go.sum @@ -321,8 +321,6 @@ github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660 h1:F0 github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE= github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f h1:FRc0bVNWprihWS0GqQWzb3dY4dkCwpOP3mDw5NwSoR4= github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f/go.mod h1:KiZi2mJRH1TOJ3FtBDYS6YvUL30s/iIXaGSUrSa36mo= -github.com/openshift/library-go v0.0.0-20241007132721-695e3914ffaa h1:J+yNseiBYDHHX0ln6Jy1iKjNepq2v9PBBtbPb2xU+AQ= -github.com/openshift/library-go v0.0.0-20241007132721-695e3914ffaa/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0= github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -422,6 +420,8 @@ github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tjungblu/library-go v0.0.0-20241009082417-6872a5e7263f h1:9HEVVW8yjskSDpjMrZ6H0Z+TMeRi75lwCO0QVoA1rOU= +github.com/tjungblu/library-go v0.0.0-20241009082417-6872a5e7263f/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0= github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= diff --git a/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go index 2f7bf95d7..8cce7c0f3 100644 --- a/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go +++ b/vendor/github.com/openshift/library-go/pkg/operator/status/status_controller.go @@ -2,6 +2,7 @@ package status import ( "context" + "fmt" "strings" "time" @@ -51,6 +52,7 @@ type StatusSyncer struct { degradedInertia Inertia removeUnusedVersions bool + retryWithClientGet bool } var _ factory.Controller = &StatusSyncer{} @@ -126,9 +128,9 @@ func (c *StatusSyncer) WithVersionRemoval() *StatusSyncer { return &output } -// sync reacts to a change in prereqs by finding information that is required to match another value in the cluster. This +// Sync reacts to a change in prereqs by finding information that is required to match another value in the cluster. This // must be information that is logically "owned" by another component. -func (c StatusSyncer) Sync(ctx context.Context, syncCtx factory.SyncContext) error { +func (c *StatusSyncer) Sync(ctx context.Context, syncCtx factory.SyncContext) error { detailedSpec, currentDetailedStatus, _, err := c.operatorClient.GetOperatorState() if apierrors.IsNotFound(err) { syncCtx.Recorder().Warningf("StatusNotFound", "Unable to determine current operator status for clusteroperator/%s", c.clusterOperatorName) @@ -147,6 +149,14 @@ func (c StatusSyncer) Sync(ctx context.Context, syncCtx factory.SyncContext) err return err } + if c.retryWithClientGet { + c.retryWithClientGet = false + originalClusterOperatorObj, err = c.clusterOperatorClient.ClusterOperators().Get(ctx, c.clusterOperatorName, metav1.GetOptions{}) + if err != nil { + return fmt.Errorf("consistent client get from retry failed with: %w", err) + } + } + // ensure that we have a clusteroperator resource if originalClusterOperatorObj == nil || apierrors.IsNotFound(err) { klog.Infof("clusteroperator/%s not found", c.clusterOperatorName) @@ -225,6 +235,11 @@ func (c StatusSyncer) Sync(ctx context.Context, syncCtx factory.SyncContext) err klog.V(2).Infof("clusteroperator/%s diff %v", c.clusterOperatorName, resourceapply.JSONPatchNoError(originalClusterOperatorObj, clusterOperatorObj)) if _, updateErr := c.clusterOperatorClient.ClusterOperators().UpdateStatus(ctx, clusterOperatorObj, metav1.UpdateOptions{}); updateErr != nil { + // Conflicts are sometimes caused when the watch cache is lagging behind. We still want to ensure the operators update their status correctly. + // This is ensuring on the next sync loop to get the latest status directly with a client get. + if apierrors.IsConflict(updateErr) { + c.retryWithClientGet = true + } return updateErr } if !skipOperatorStatusChangedEvent(originalClusterOperatorObj.Status, clusterOperatorObj.Status) { diff --git a/vendor/modules.txt b/vendor/modules.txt index 9f2d2a51b..1c5a33136 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -334,7 +334,7 @@ github.com/openshift/client-go/operator/informers/externalversions/operator/v1 github.com/openshift/client-go/operator/informers/externalversions/operator/v1alpha1 github.com/openshift/client-go/operator/listers/operator/v1 github.com/openshift/client-go/operator/listers/operator/v1alpha1 -# github.com/openshift/library-go v0.0.0-20241007132721-695e3914ffaa +# github.com/openshift/library-go v0.0.0-20241007132721-695e3914ffaa => github.com/tjungblu/library-go v0.0.0-20241009082417-6872a5e7263f ## explicit; go 1.22.0 github.com/openshift/library-go/pkg/assets github.com/openshift/library-go/pkg/authorization/hardcodedauthorizer @@ -1580,4 +1580,5 @@ sigs.k8s.io/structured-merge-diff/v4/value sigs.k8s.io/yaml sigs.k8s.io/yaml/goyaml.v2 # github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.2 +# github.com/openshift/library-go => github.com/tjungblu/library-go v0.0.0-20241009082417-6872a5e7263f # vbom.ml/util => github.com/fvbommel/util v0.0.0-20180919145318-efcd4e0f9787