Skip to content

Commit 219824d

Browse files
committed
react to changes
1 parent 8d72c7a commit 219824d

File tree

7 files changed

+20
-10
lines changed

7 files changed

+20
-10
lines changed

pkg/cmd/operator/cmd.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@ import (
66
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/operator"
77
"github.com/openshift/cluster-kube-controller-manager-operator/pkg/version"
88
"github.com/openshift/library-go/pkg/controller/controllercmd"
9+
10+
"k8s.io/utils/clock"
911
)
1012

1113
func NewOperator() *cobra.Command {
1214
cmd := controllercmd.
13-
NewControllerCommandConfig("kube-controller-manager-operator", version.Get(), operator.RunOperator).
15+
NewControllerCommandConfig("kube-controller-manager-operator", version.Get(), operator.RunOperator, clock.RealClock{}).
1416
NewCommand()
1517
cmd.Use = "operator"
1618
cmd.Short = "Start the Cluster kube-controller-manager Operator"

pkg/cmd/recoverycontroller/cmd.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/openshift/library-go/pkg/operator/v1helpers"
1616
"github.com/spf13/cobra"
1717
"k8s.io/client-go/kubernetes"
18+
"k8s.io/utils/clock"
1819
)
1920

2021
type Options struct {
@@ -23,6 +24,7 @@ type Options struct {
2324

2425
func NewCertRecoveryControllerCommand(ctx context.Context) *cobra.Command {
2526
o := &Options{}
27+
c := clock.RealClock{}
2628

2729
ccc := controllercmd.NewControllerCommandConfig("cert-recovery-controller", version.Get(), func(ctx context.Context, controllerContext *controllercmd.ControllerContext) error {
2830
o.controllerContext = controllerContext
@@ -37,13 +39,13 @@ func NewCertRecoveryControllerCommand(ctx context.Context) *cobra.Command {
3739
return err
3840
}
3941

40-
err = o.Run(ctx)
42+
err = o.Run(ctx, c)
4143
if err != nil {
4244
return err
4345
}
4446

4547
return nil
46-
})
48+
}, c)
4749

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

69-
func (o *Options) Run(ctx context.Context) error {
71+
func (o *Options) Run(ctx context.Context, clock clock.Clock) error {
7072
kubeClient, err := kubernetes.NewForConfig(o.controllerContext.ProtoKubeConfig)
7173
if err != nil {
7274
return fmt.Errorf("can't build kubernetes client: %w", err)
@@ -81,6 +83,7 @@ func (o *Options) Run(ctx context.Context) error {
8183
)
8284

8385
operatorClient, dynamicInformers, err := genericoperatorclient.NewStaticPodOperatorClient(
86+
clock,
8487
o.controllerContext.KubeConfig,
8588
operatorv1.GroupVersion.WithResource("kubecontrollermanagers"),
8689
operatorv1.GroupVersion.WithKind("KubeControllerManager"),

pkg/operator/configobservation/clustername/observeinfraid_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
88
"k8s.io/client-go/tools/cache"
9+
"k8s.io/utils/clock"
910

1011
configv1 "github.com/openshift/api/config/v1"
1112
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
@@ -97,7 +98,7 @@ func TestObserveInfraID(t *testing.T) {
9798
listers := configobservation.Listers{
9899
InfrastructureLister_: configlistersv1.NewInfrastructureLister(indexer),
99100
}
100-
result, errs := ObserveInfraID(listers, events.NewInMemoryRecorder("infraid"), test.input)
101+
result, errs := ObserveInfraID(listers, events.NewInMemoryRecorder("infraid", clock.RealClock{}), test.input)
101102
if len(errs) > 0 {
102103
t.Fatal(errs)
103104
} else {

pkg/operator/configobservation/network/observe_networking_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66

77
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
88
"k8s.io/client-go/tools/cache"
9+
"k8s.io/utils/clock"
910

1011
configv1 "github.com/openshift/api/config/v1"
1112
configlistersv1 "github.com/openshift/client-go/config/listers/config/v1"
@@ -78,7 +79,7 @@ func TestObserveClusterCIDRs(t *testing.T) {
7879
listers := configobservation.Listers{
7980
NetworkLister: configlistersv1.NewNetworkLister(indexer),
8081
}
81-
result, errs := ObserveClusterCIDRs(listers, events.NewInMemoryRecorder("network"), map[string]interface{}{})
82+
result, errs := ObserveClusterCIDRs(listers, events.NewInMemoryRecorder("network", clock.RealClock{}), map[string]interface{}{})
8283
if len(errs) > 0 && !test.expectedError {
8384
t.Fatal(errs)
8485
} else if len(errs) == 0 {
@@ -101,7 +102,7 @@ func TestObserveServiceClusterIPRanges(t *testing.T) {
101102
listers := configobservation.Listers{
102103
NetworkLister: configlistersv1.NewNetworkLister(indexer),
103104
}
104-
result, errs := ObserveServiceClusterIPRanges(listers, events.NewInMemoryRecorder("network"), map[string]interface{}{})
105+
result, errs := ObserveServiceClusterIPRanges(listers, events.NewInMemoryRecorder("network", clock.RealClock{}), map[string]interface{}{})
105106
if len(errs) > 0 {
106107
t.Fatal(errs)
107108
}

pkg/operator/gcwatchercontroller/gcwatcher_controller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"k8s.io/client-go/informers"
1818
"k8s.io/client-go/kubernetes/fake"
1919
"k8s.io/client-go/tools/cache"
20+
"k8s.io/utils/clock"
2021

2122
configv1 "github.com/openshift/api/config/v1"
2223
operatorv1 "github.com/openshift/api/operator/v1"
@@ -429,7 +430,7 @@ func TestGarbageCollectorSync(t *testing.T) {
429430
tc.gc.configMapClient = configMapGetter
430431
clusterListers := configlisters.NewClusterOperatorLister(indexer)
431432
tc.gc.clusterLister = clusterListers
432-
eventRecorder := events.NewInMemoryRecorder("dummy")
433+
eventRecorder := events.NewInMemoryRecorder("dummy", clock.RealClock{})
433434
syncContext := factory.NewSyncContext(controllerName, eventRecorder)
434435
syncContext.Queue().Add(invalidateAlertingRulesCacheKey)
435436
err := tc.gc.sync(context.TODO(), syncContext)

pkg/operator/starter.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ func RunOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
6868
)
6969

7070
operatorClient, dynamicInformers, err := genericoperatorclient.NewStaticPodOperatorClient(
71+
cc.Clock,
7172
cc.KubeConfig,
7273
operatorv1.GroupVersion.WithResource("kubecontrollermanagers"),
7374
operatorv1.GroupVersion.WithKind("KubeControllerManager"),
@@ -213,7 +214,7 @@ func RunOperator(ctx context.Context, cc *controllercmd.ControllerContext) error
213214
}
214215
versionRecorder.SetVersion("raw-internal", status.VersionForOperatorFromEnv())
215216

216-
staticPodControllers, err := staticpod.NewBuilder(operatorClient, kubeClient, kubeInformersForNamespaces, configInformers).
217+
staticPodControllers, err := staticpod.NewBuilder(operatorClient, kubeClient, kubeInformersForNamespaces, configInformers, cc.Clock).
217218
WithEvents(cc.EventRecorder).
218219
WithInstaller([]string{"cluster-kube-controller-manager-operator", "installer"}).
219220
WithPruning([]string{"cluster-kube-controller-manager-operator", "prune"}, "kube-controller-manager-pod").

pkg/operator/targetconfigcontroller/targetconfigcontroller_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"k8s.io/client-go/kubernetes/fake"
2323
corev1listers "k8s.io/client-go/listers/core/v1"
2424
"k8s.io/client-go/tools/cache"
25+
"k8s.io/utils/clock"
2526
)
2627

2728
func TestIsRequiredConfigPresent(t *testing.T) {
@@ -305,7 +306,7 @@ func TestManageCSRSigner(t *testing.T) {
305306
t.Fatal(err.Error())
306307
}
307308
lister := corev1listers.NewSecretLister(indexer)
308-
_, delay, changed, err := ManageCSRSigner(context.Background(), lister, client.CoreV1(), events.NewInMemoryRecorder("target-config-controller"))
309+
_, delay, changed, err := ManageCSRSigner(context.Background(), lister, client.CoreV1(), events.NewInMemoryRecorder("target-config-controller", clock.RealClock{}))
309310
// there's a 10s difference we need to account for to avoid flakes
310311
offset := 10 * time.Second
311312
if delay < test.expectedDelay-offset || delay > test.expectedDelay+offset {

0 commit comments

Comments
 (0)