Skip to content

Instantly share code, notes, and snippets.

@sttts
Created December 13, 2024 14:09
Show Gist options
  • Save sttts/a8460e338edaae7bf271bf280a08a466 to your computer and use it in GitHub Desktop.
Save sttts/a8460e338edaae7bf271bf280a08a466 to your computer and use it in GitHub Desktop.
commit 35652e53928c351644c70b3448ca17040d494898
Author: Dr. Stefan Schimanski <[email protected]>
Date: Fri Dec 13 15:08:10 2024 +0100
Fix option mutation
Signed-off-by: Dr. Stefan Schimanski <[email protected]>
diff --git a/pkg/controlplane/apiserver/config.go b/pkg/controlplane/apiserver/config.go
index 0137e7be961..dd1e0efe15d 100644
--- a/pkg/controlplane/apiserver/config.go
+++ b/pkg/controlplane/apiserver/config.go
@@ -180,10 +180,7 @@ func BuildGenericConfig(
sets.NewString("attach", "exec", "proxy", "log", "portforward"),
)
- if genericConfig.RequestTimeout > 0 {
- s.Etcd.StorageConfig.EventsHistoryWindow = genericConfig.RequestTimeout + 15*time.Second
- }
-
+ // TODO(sttts): remove these side-effects by moving the initialization elsewhere and not mutate s.
if genericConfig.EgressSelector != nil {
s.Etcd.StorageConfig.Transport.EgressLookup = genericConfig.EgressSelector.Lookup
}
diff --git a/pkg/controlplane/apiserver/options/options.go b/pkg/controlplane/apiserver/options/options.go
index 2266be0cbed..cac4dfa4091 100644
--- a/pkg/controlplane/apiserver/options/options.go
+++ b/pkg/controlplane/apiserver/options/options.go
@@ -225,6 +225,10 @@ func (o *Options) Complete(ctx context.Context, fss cliflag.NamedFlagSets, alter
return CompletedOptions{}, fmt.Errorf("error creating self-signed certificates: %v", err)
}
+ if o.GenericServerRunOptions.RequestTimeout > 0 {
+ completed.Etcd.StorageConfig.EventsHistoryWindow = completed.GenericServerRunOptions.RequestTimeout + 15*time.Second
+ }
+
if len(completed.GenericServerRunOptions.ExternalHost) == 0 {
if len(completed.GenericServerRunOptions.AdvertiseAddress) > 0 {
completed.GenericServerRunOptions.ExternalHost = completed.GenericServerRunOptions.AdvertiseAddress.String()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment