Skip to content

Commit 23dd96c

Browse files
committed
react to changes
1 parent 51c2a5e commit 23dd96c

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

pkg/cmd/certregenerationcontroller/cmd.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Options struct {
3030

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

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

47-
err = o.Run(ctx)
48+
err = o.Run(ctx, c)
4849
if err != nil {
4950
return err
5051
}
5152

5253
return nil
53-
})
54+
}, c)
5455

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

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

9798
operatorClient, dynamicInformers, err := genericoperatorclient.NewStaticPodOperatorClient(
98-
clock.RealClock{},
99+
clock,
99100
o.controllerContext.KubeConfig,
100101
operatorv1.GroupVersion.WithResource("kubeapiservers"),
101102
operatorv1.GroupVersion.WithKind("KubeAPIServer"),

pkg/cmd/checkendpoints/cmd.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2020
"k8s.io/client-go/informers"
2121
"k8s.io/client-go/kubernetes"
22+
"k8s.io/utils/clock"
2223
)
2324

2425
func NewCheckEndpointsCommand() *cobra.Command {
@@ -55,7 +56,7 @@ func NewCheckEndpointsCommand() *cobra.Command {
5556
if err != nil {
5657
return err
5758
}
58-
recorder := events.NewRecorder(kubeClient.CoreV1().Events(namespace), "check-endpoint", involvedObjectRef)
59+
recorder := events.NewRecorder(kubeClient.CoreV1().Events(namespace), "check-endpoint", involvedObjectRef, cctx.Clock)
5960

6061
check := controller.NewPodNetworkConnectivityCheckController(
6162
podName,
@@ -100,7 +101,7 @@ func NewCheckEndpointsCommand() *cobra.Command {
100101
go stopController.Run(ctx, 1)
101102
<-ctx.Done()
102103
return nil
103-
})
104+
}, clock.RealClock{})
104105
config.DisableLeaderElection = true
105106
cmd := config.NewCommandWithContext(context.Background())
106107
cmd.Use = "check-endpoints"

pkg/cmd/operator/cmd.go

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

1112
func NewOperator() *cobra.Command {
1213
cmd := controllercmd.
13-
NewControllerCommandConfig("kube-apiserver-operator", version.Get(), operator.RunOperator).
14+
NewControllerCommandConfig("kube-apiserver-operator", version.Get(), operator.RunOperator, clock.RealClock{}).
1415
NewCommand()
1516
cmd.Use = "operator"
1617
cmd.Short = "Start the Cluster kube-apiserver Operator"

pkg/operator/starter.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ import (
7575
"k8s.io/client-go/dynamic/dynamicinformer"
7676
"k8s.io/client-go/kubernetes"
7777
"k8s.io/klog/v2"
78-
"k8s.io/utils/clock"
7978
"k8s.io/utils/ptr"
8079
kubemigratorclient "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/clientset"
8180
migrationv1alpha1informer "sigs.k8s.io/kube-storage-version-migrator/pkg/clients/informer"
@@ -133,7 +132,7 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
133132
)
134133
configInformers := configv1informers.NewSharedInformerFactory(configClient, 10*time.Minute)
135134
operatorClient, dynamicInformersForAllNamespaces, err := genericoperatorclient.NewStaticPodOperatorClient(
136-
clock.RealClock{},
135+
controllerContext.Clock,
137136
controllerContext.KubeConfig,
138137
operatorv1.GroupVersion.WithResource("kubeapiservers"),
139138
operatorv1.GroupVersion.WithKind("KubeAPIServer"),
@@ -304,7 +303,7 @@ func RunOperator(ctx context.Context, controllerContext *controllercmd.Controlle
304303
}
305304
versionRecorder.SetVersion("raw-internal", status.VersionForOperatorFromEnv())
306305

307-
staticPodControllers, err := staticpod.NewBuilder(operatorClient, kubeClient, kubeInformersForNamespaces, configInformers).
306+
staticPodControllers, err := staticpod.NewBuilder(operatorClient, kubeClient, kubeInformersForNamespaces, configInformers, controllerContext.Clock).
308307
WithEvents(controllerContext.EventRecorder).
309308
WithCustomInstaller([]string{"cluster-kube-apiserver-operator", "installer"}, installerErrorInjector(operatorClient)).
310309
WithPruning([]string{"cluster-kube-apiserver-operator", "prune"}, "kube-apiserver-pod").

0 commit comments

Comments
 (0)