Move etcd ready channel into executor

This eliminates the final channel that was being passed around in an internal struct. The ETCD management code passes in a func that can be polled until etcd is ready; the executor is responsible for polling this after etcd is started and closing the etcd ready channel at the correct time.

Signed-off-by: Brad Davidson <brad.davidson@rancher.com>
This commit is contained in:
Brad Davidson
2025-03-14 22:24:49 +00:00
committed by Brad Davidson
parent 72bbd676f1
commit d45006be66
12 changed files with 89 additions and 69 deletions

View File

@@ -30,7 +30,7 @@ func (e *Executor) APIServerHandlers(ctx context.Context) (authenticator.Request
return nil, nil, errors.New("not implemented")
}
func (e *Executor) APIServer(ctx context.Context, etcdReady <-chan struct{}, args []string) error {
func (e *Executor) APIServer(ctx context.Context, args []string) error {
return errors.New("not implemented")
}
@@ -46,9 +46,9 @@ func (e *Executor) CurrentETCDOptions() (executor.InitialOptions, error) {
return executor.InitialOptions{}, nil
}
func (e *Executor) ETCD(ctx context.Context, args executor.ETCDConfig, extraArgs []string) error {
func (e *Executor) ETCD(ctx context.Context, args *executor.ETCDConfig, extraArgs []string, test executor.TestFunc) error {
embed := &executor.Embedded{}
return embed.ETCD(ctx, args, extraArgs)
return embed.ETCD(ctx, args, extraArgs, test)
}
func (e *Executor) CloudControllerManager(ctx context.Context, ccmRBACReady <-chan struct{}, args []string) error {
@@ -73,6 +73,12 @@ func (e *Executor) APIServerReadyChan() <-chan struct{} {
return c
}
func (e *Executor) ETCDReadyChan() <-chan struct{} {
c := make(chan struct{})
close(c)
return c
}
func (e *Executor) CRIReadyChan() <-chan struct{} {
c := make(chan struct{})
close(c)

View File

@@ -8,6 +8,7 @@ import (
"github.com/k3s-io/k3s/pkg/daemons/config"
"github.com/k3s-io/k3s/pkg/daemons/control/deps"
"github.com/k3s-io/k3s/pkg/daemons/executor"
"github.com/k3s-io/k3s/tests/mock"
)
// GenerateDataDir creates a temporary directory at "/tmp/k3s/<RANDOM_STRING>/".