Skip to content

Commit

Permalink
Merge pull request #1767 from p0lyn0mial/bump-library-go
Browse files Browse the repository at this point in the history
API-1835: bump library-go
  • Loading branch information
openshift-merge-bot[bot] authored Nov 21, 2024
2 parents dc7ef78 + ae4e0c3 commit 8ef2c1d
Show file tree
Hide file tree
Showing 42 changed files with 151 additions and 82 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
github.com/openshift/api v0.0.0-20241104230711-4c27e61e5554
github.com/openshift/build-machinery-go v0.0.0-20240613134303-8359781da660
github.com/openshift/client-go v0.0.0-20241001162912-da6d55e4611f
github.com/openshift/library-go v0.0.0-20241114083156-ec00d85ac1e8
github.com/openshift/library-go v0.0.0-20241119162247-f466fdd82330
github.com/pkg/profile v1.7.0 // indirect
github.com/prometheus/client_golang v1.19.1
github.com/spf13/cobra v1.8.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,8 @@ 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-20241114083156-ec00d85ac1e8 h1:x4pfSoKQcsf+mvBmj4mpFeHSVvIGwz/NSzKslNqtCtQ=
github.com/openshift/library-go v0.0.0-20241114083156-ec00d85ac1e8/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0=
github.com/openshift/library-go v0.0.0-20241119162247-f466fdd82330 h1:nK16PhWNPIjnv7Vux1jBlzEPgA9q/o/CwqsbRpQJrpY=
github.com/openshift/library-go v0.0.0-20241119162247-f466fdd82330/go.mod h1:9B1MYPoLtP9tqjWxcbUNVpwxy68zOH/3EIP6c31dAM0=
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
9 changes: 5 additions & 4 deletions pkg/cmd/certregenerationcontroller/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type Options struct {

func NewCertRegenerationControllerCommand(ctx context.Context) *cobra.Command {
o := &Options{}
c := clock.RealClock{}

ccc := controllercmd.NewControllerCommandConfig("cert-regeneration-controller", version.Get(), func(ctx context.Context, controllerContext *controllercmd.ControllerContext) error {
o.controllerContext = controllerContext
Expand All @@ -44,13 +45,13 @@ func NewCertRegenerationControllerCommand(ctx context.Context) *cobra.Command {
return err
}

err = o.Run(ctx)
err = o.Run(ctx, c)
if err != nil {
return err
}

return nil
})
}, c)

// Disable serving for recovery as it introduces a dependency on kube-system::extension-apiserver-authentication
// configmap which prevents it to start as the CA bundle is expired.
Expand All @@ -73,7 +74,7 @@ func (o *Options) Complete(ctx context.Context) error {
return nil
}

func (o *Options) Run(ctx context.Context) error {
func (o *Options) Run(ctx context.Context, clock clock.Clock) error {
kubeClient, err := kubernetes.NewForConfig(o.controllerContext.ProtoKubeConfig)
if err != nil {
return fmt.Errorf("can't build kubernetes client: %w", err)
Expand All @@ -95,7 +96,7 @@ func (o *Options) Run(ctx context.Context) error {
)

operatorClient, dynamicInformers, err := genericoperatorclient.NewStaticPodOperatorClient(
clock.RealClock{},
clock,
o.controllerContext.KubeConfig,
operatorv1.GroupVersion.WithResource("kubeapiservers"),
operatorv1.GroupVersion.WithKind("KubeAPIServer"),
Expand Down
5 changes: 3 additions & 2 deletions pkg/cmd/checkendpoints/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/informers"
"k8s.io/client-go/kubernetes"
"k8s.io/utils/clock"
)

func NewCheckEndpointsCommand() *cobra.Command {
Expand Down Expand Up @@ -55,7 +56,7 @@ func NewCheckEndpointsCommand() *cobra.Command {
if err != nil {
return err
}
recorder := events.NewRecorder(kubeClient.CoreV1().Events(namespace), "check-endpoint", involvedObjectRef)
recorder := events.NewRecorder(kubeClient.CoreV1().Events(namespace), "check-endpoint", involvedObjectRef, cctx.Clock)

check := controller.NewPodNetworkConnectivityCheckController(
podName,
Expand Down Expand Up @@ -100,7 +101,7 @@ func NewCheckEndpointsCommand() *cobra.Command {
go stopController.Run(ctx, 1)
<-ctx.Done()
return nil
})
}, clock.RealClock{})
config.DisableLeaderElection = true
cmd := config.NewCommandWithContext(context.Background())
cmd.Use = "check-endpoints"
Expand Down
6 changes: 4 additions & 2 deletions pkg/cmd/checkendpoints/controller/backoff_recorder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

"github.com/openshift/library-go/pkg/operator/events"
"github.com/stretchr/testify/assert"

"k8s.io/utils/clock"
)

func TestWithShortWindow(t *testing.T) {
Expand All @@ -18,7 +20,7 @@ func TestWithShortWindow(t *testing.T) {
backoffDuration := longDuration
excessiveEventCount := 10

inMemoryRecorder := events.NewInMemoryRecorder(t.Name())
inMemoryRecorder := events.NewInMemoryRecorder(t.Name(), clock.RealClock{})
r := NewBackoffEventRecorder(inMemoryRecorder,
WithShortWindow(shortDuration, shortCountMax),
WithLongWindow(longDuration, longCountMax),
Expand Down Expand Up @@ -61,7 +63,7 @@ func TestWithLongWindow(t *testing.T) {
backoffDuration := longDuration
excessiveEventCount := 10

inMemoryRecorder := events.NewInMemoryRecorder(t.Name())
inMemoryRecorder := events.NewInMemoryRecorder(t.Name(), clock.RealClock{})
r := NewBackoffEventRecorder(inMemoryRecorder,
WithShortWindow(shortDuration, shortCountMax),
WithLongWindow(longDuration, longCountMax),
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/checkendpoints/controller/connection_checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/mergepatch"
"k8s.io/utils/clock"

"github.com/openshift/cluster-kube-apiserver-operator/pkg/cmd/checkendpoints/trace"
)
Expand Down Expand Up @@ -418,7 +419,7 @@ func TestManageStatusOutage(t *testing.T) {
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
status := tc.initial
manageStatusOutage(events.NewInMemoryRecorder(t.Name()))(status)
manageStatusOutage(events.NewInMemoryRecorder(t.Name(), clock.RealClock{}))(status)
assert.Equal(t, tc.expected, status.Outages)
if t.Failed() {
t.Log("\n", mergepatch.ToYAMLOrError(tc.expected))
Expand Down
3 changes: 2 additions & 1 deletion pkg/cmd/operator/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator"
"github.com/openshift/cluster-kube-apiserver-operator/pkg/version"
"github.com/openshift/library-go/pkg/controller/controllercmd"
"k8s.io/utils/clock"
)

func NewOperator() *cobra.Command {
cmd := controllercmd.
NewControllerCommandConfig("kube-apiserver-operator", version.Get(), operator.RunOperator).
NewControllerCommandConfig("kube-apiserver-operator", version.Get(), operator.RunOperator, clock.RealClock{}).
NewCommand()
cmd.Use = "operator"
cmd.Short = "Start the Cluster kube-apiserver Operator"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"k8s.io/apimachinery/pkg/util/diff"
corelistersv1 "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/clock"

configv1 "github.com/openshift/api/config/v1"
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
Expand Down Expand Up @@ -71,7 +72,7 @@ func TestObserveUserClientCABundle(t *testing.T) {
APIServerLister_: configlistersv1.NewAPIServerLister(indexer),
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
}
result, errs := ObserveUserClientCABundle(listers, events.NewInMemoryRecorder(t.Name()), tc.existing)
result, errs := ObserveUserClientCABundle(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tc.existing)
if len(errs) > 0 {
t.Errorf("Expected 0 errors, got %v.", len(errs))
}
Expand Down Expand Up @@ -501,7 +502,7 @@ func TestObserveNamedCertificates(t *testing.T) {
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
ConfigSecretLister_: corelistersv1.NewSecretLister(indexer),
}
result, errs := ObserveNamedCertificates(listers, events.NewInMemoryRecorder(t.Name()), tc.existing)
result, errs := ObserveNamedCertificates(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tc.existing)
if tc.expectErrs && len(errs) == 0 {
t.Error("Expected errors.", errs)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/util/diff"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/clock"
)

func TestObserveAdditionalCORSAllowedOrigins(t *testing.T) {
Expand Down Expand Up @@ -73,7 +74,7 @@ func TestObserveAdditionalCORSAllowedOrigins(t *testing.T) {
APIServerLister_: configlistersv1.NewAPIServerLister(indexer),
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
}
result, errs := ObserveAdditionalCORSAllowedOrigins(listers, events.NewInMemoryRecorder(t.Name()), tc.existing)
result, errs := ObserveAdditionalCORSAllowedOrigins(listers, events.NewInMemoryRecorder(t.Name(), clock.RealClock{}), tc.existing)
if len(errs) > 0 {
t.Errorf("Expected 0 errors, got %v.", len(errs))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/clock"

configv1 "github.com/openshift/api/config/v1"
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
Expand Down Expand Up @@ -94,7 +95,7 @@ func TestObserveSendRetryAfterWhileNotReadyOnce(t *testing.T) {
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
// test data
eventRecorder := events.NewInMemoryRecorder("")
eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{})
infrastructureIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
infrastructureIndexer.Add(&configv1.Infrastructure{
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/clock"

configv1 "github.com/openshift/api/config/v1"
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
Expand Down Expand Up @@ -69,7 +70,7 @@ func TestObserveWatchTerminationDuration(t *testing.T) {
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
// test data
eventRecorder := events.NewInMemoryRecorder("")
eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{})
infrastructureIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
infrastructureIndexer.Add(&configv1.Infrastructure{
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
Expand Down Expand Up @@ -182,7 +183,7 @@ func TestObserveShutdownDelayDuration(t *testing.T) {
for _, scenario := range scenarios {
t.Run(scenario.name, func(t *testing.T) {
// test data
eventRecorder := events.NewInMemoryRecorder("")
eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{})
infrastructureIndexer := cache.NewIndexer(cache.MetaNamespaceKeyFunc, cache.Indexers{})
infrastructureIndexer.Add(&configv1.Infrastructure{
ObjectMeta: metav1.ObjectMeta{Name: "cluster"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/utils/clock"

configv1 "github.com/openshift/api/config/v1"
kubecontrolplanev1 "github.com/openshift/api/kubecontrolplane/v1"
Expand Down Expand Up @@ -107,7 +108,7 @@ func TestObservedConfig(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
testRecorder := events.NewInMemoryRecorder("SAIssuerTest")
testRecorder := events.NewInMemoryRecorder("SAIssuerTest", clock.RealClock{})

newConfig, errs := observedConfig(
unstructuredAPIConfigForIssuer(t, tc.existingIssuer, tc.trustedIssuers),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/openshift/api/features"
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates"
"github.com/openshift/library-go/pkg/operator/events"
"k8s.io/utils/clock"
)

func TestObservePodSecurityAdmissionEnforcement(t *testing.T) {
Expand Down Expand Up @@ -79,7 +80,7 @@ func TestObservePodSecurityAdmissionEnforcement(t *testing.T) {
},
} {
t.Run(tc.name, func(t *testing.T) {
testRecorder := events.NewInMemoryRecorder("SAIssuerTest")
testRecorder := events.NewInMemoryRecorder("SAIssuerTest", clock.RealClock{})
existingConfig := map[string]interface{}{}
require.NoError(t, json.Unmarshal([]byte(tc.existingJSON), &existingConfig))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation"
"github.com/openshift/library-go/pkg/operator/events"
"github.com/openshift/library-go/pkg/operator/resourcesynccontroller"
"k8s.io/utils/clock"
)

var correctKubeConfigString = []byte(`
Expand Down Expand Up @@ -154,7 +155,7 @@ func TestObserveWebhookTokenAuthenticator(t *testing.T) {
ResourceSync: &mockResourceSyncer{t: t, synced: synced},
}

eventRecorder := events.NewInMemoryRecorder("webhookauthenticatortest")
eventRecorder := events.NewInMemoryRecorder("webhookauthenticatortest", clock.RealClock{})

gotConfig, errs := ObserveWebhookTokenAuthenticator(listers, eventRecorder, tt.existingConfig)
gotAuthenticator, _, err := unstructured.NestedStringSlice(gotConfig, webhookTokenAuthenticatorPath...)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"k8s.io/apimachinery/pkg/util/mergepatch"
corev1listers "k8s.io/client-go/listers/core/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/clock"

"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/configobservation"
)
Expand Down Expand Up @@ -62,7 +63,7 @@ func TestObserveStorageURLs(t *testing.T) {
t.Fatalf("error adding endpoint to store: %#v", err)
}
}
actual, errs := ObserveStorageURLs(lister, events.NewInMemoryRecorder("test"), tt.currentConfig)
actual, errs := ObserveStorageURLs(lister, events.NewInMemoryRecorder("test", clock.RealClock{}), tt.currentConfig)
if tt.expectErrors && len(errs) == 0 {
t.Errorf("errors expected")
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/operator/configobservation/images/observe_images_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/client-go/tools/cache"
"k8s.io/utils/clock"

configv1 "github.com/openshift/api/config/v1"
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
Expand Down Expand Up @@ -138,7 +139,7 @@ func TestObserveImageConfig(t *testing.T) {
listers := configobservation.Listers{
ImageConfigLister: configlistersv1.NewImageLister(indexer),
}
eventRecorder := events.NewInMemoryRecorder("")
eventRecorder := events.NewInMemoryRecorder("", clock.RealClock{})

initialExistingConfig := map[string]interface{}{}

Expand Down
Loading

0 comments on commit 8ef2c1d

Please sign in to comment.