Skip to content

Commit e6c6375

Browse files
authored
Merge pull request #3831 from gman0/cachedserver-external-etcd
Added support for external etcd in cache-server
2 parents 65aadf9 + e639075 commit e6c6375

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

cmd/sharded-test-server/main.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func main() {
4949
numberOfShards := flag.Int("number-of-shards", 1, "The number of shards to create. The first created is assumed root.")
5050
cacheSyntheticDelay := flag.Duration("cache-synthetic-delay", 0, "The duration of time the cache server will inject a delay for to all inbound requests.")
5151
quiet := flag.Bool("quiet", false, "Suppress output of the subprocesses")
52+
cacheServerKubeconfig := flag.String("cache-kubeconfig", "", "Path to a kubeconfig of an external cache-server. If empty, a dedicated cache-server is started.")
5253

5354
// split flags into --proxy-*, --shard-* and everything else (generic). The former are
5455
// passed to the respective components.
@@ -64,13 +65,13 @@ func main() {
6465
}
6566
flag.CommandLine.Parse(genericFlags) //nolint:errcheck
6667

67-
if err := start(proxyFlags, shardFlags, *logDirPath, *workDirPath, *numberOfShards, *quiet, *cacheSyntheticDelay); err != nil {
68+
if err := start(proxyFlags, shardFlags, *logDirPath, *workDirPath, *numberOfShards, *quiet, *cacheSyntheticDelay, *cacheServerKubeconfig); err != nil {
6869
fmt.Println(err.Error())
6970
os.Exit(1)
7071
}
7172
}
7273

73-
func start(proxyFlags, shardFlags []string, logDirPath, workDirPath string, numberOfShards int, quiet bool, cacheSyntheticDelay time.Duration) error {
74+
func start(proxyFlags, shardFlags []string, logDirPath, workDirPath string, numberOfShards int, quiet bool, cacheSyntheticDelay time.Duration, cacheServerConfigPath string) error {
7475
// We use a shutdown context to know that it's time to gather metrics, before stopping the shards, proxy, etc.
7576
shutdownCtx, shutdownCancel := context.WithCancel(genericapiserver.SetupSignalContext())
7677
defer shutdownCancel()
@@ -197,16 +198,17 @@ func start(proxyFlags, shardFlags []string, logDirPath, workDirPath string, numb
197198
standaloneVW := sets.New[string](shardFlags...).Has("--run-virtual-workspaces=false")
198199

199200
cacheServerErrCh := make(chan indexErrTuple)
200-
cacheServerConfigPath := ""
201-
cacheServerCh, configPath, err := startCacheServer(ctx, logDirPath, workDirPath, hostIP.String(), cacheSyntheticDelay)
202-
if err != nil {
203-
return fmt.Errorf("error starting the cache server: %w", err)
201+
if cacheServerConfigPath == "" {
202+
cacheServerCh, configPath, err := startCacheServer(ctx, logDirPath, workDirPath, hostIP.String(), cacheSyntheticDelay)
203+
if err != nil {
204+
return fmt.Errorf("error starting the cache server: %w", err)
205+
}
206+
cacheServerConfigPath = configPath
207+
go func() {
208+
err := <-cacheServerCh
209+
cacheServerErrCh <- indexErrTuple{0, err}
210+
}()
204211
}
205-
cacheServerConfigPath = configPath
206-
go func() {
207-
err := <-cacheServerCh
208-
cacheServerErrCh <- indexErrTuple{0, err}
209-
}()
210212

211213
if err := writeLogicalClusterAdminKubeConfig(hostIP.String(), workDirPath); err != nil {
212214
return err

pkg/cache/server/options/options.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ func (o *Options) Complete() (*CompletedOptions, error) {
114114
}
115115

116116
func (o *Options) AddFlags(fs *pflag.FlagSet) {
117+
o.Etcd.AddFlags(fs)
117118
o.EmbeddedEtcd.AddFlags(fs)
118119
o.SecureServing.AddFlags(fs)
119120
fs.DurationVar(&o.SyntheticDelay, "synthetic-delay", 0, "The duration of time the cache server will inject a delay for to all inbound requests. Useful for testing.")

0 commit comments

Comments
 (0)