Skip to content

Commit

Permalink
refactor: use etcd configuration from the EtcdSpec resource
Browse files Browse the repository at this point in the history
This is currently no-op, just noticed that while looking into another
bug. This should make the intention more clean.

Signed-off-by: Andrey Smirnov <andrey.smirnov@siderolabs.com>
  • Loading branch information
smira committed Jan 22, 2024
1 parent 4e9b688 commit c1e4507
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions internal/app/machined/pkg/system/services/etcd.go
Expand Up @@ -108,22 +108,22 @@ func (e *Etcd) PreFunc(ctx context.Context, r runtime.Runtime) error {
// Pull the image and unpack it.
containerdctx := namespaces.WithNamespace(ctx, constants.SystemContainerdNamespace)

img, err := image.Pull(containerdctx, r.Config().Machine().Registries(), client, r.Config().Cluster().Etcd().Image(), image.WithSkipIfAlreadyPulled())
spec, err := safe.ReaderGet[*etcdresource.Spec](ctx, r.State().V1Alpha2().Resources(), etcdresource.NewSpec(etcdresource.NamespaceName, etcdresource.SpecID).Metadata())
if err != nil {
// spec should be ready
return fmt.Errorf("failed to get etcd spec: %w", err)
}

img, err := image.Pull(containerdctx, r.Config().Machine().Registries(), client, spec.TypedSpec().Image, image.WithSkipIfAlreadyPulled())
if err != nil {
return fmt.Errorf("failed to pull image %q: %w", r.Config().Cluster().Etcd().Image(), err)
return fmt.Errorf("failed to pull image %q: %w", spec.TypedSpec().Image, err)
}

e.imgRef = img.Target().Digest.String()

// Clear any previously set learner member ID
e.learnerMemberID = 0

spec, err := safe.ReaderGet[*etcdresource.Spec](ctx, r.State().V1Alpha2().Resources(), etcdresource.NewSpec(etcdresource.NamespaceName, etcdresource.SpecID).Metadata())
if err != nil {
// spec should be ready
return fmt.Errorf("failed to get etcd spec: %w", err)
}

switch t := r.Config().Machine().Type(); t {
case machine.TypeInit:
if err = e.argsForInit(ctx, r, spec.TypedSpec()); err != nil {
Expand Down Expand Up @@ -400,7 +400,7 @@ func (e *Etcd) argsForInit(ctx context.Context, r runtime.Runtime, spec *etcdres
"experimental-compact-hash-check-enabled": "true",
}

extraArgs := argsbuilder.Args(r.Config().Cluster().Etcd().ExtraArgs())
extraArgs := argsbuilder.Args(spec.ExtraArgs)

denyList := argsbuilder.WithDenyList(denyListArgs)

Expand Down Expand Up @@ -477,7 +477,7 @@ func (e *Etcd) argsForControlPlane(ctx context.Context, r runtime.Runtime, spec
"experimental-compact-hash-check-enabled": "true",
}

extraArgs := argsbuilder.Args(r.Config().Cluster().Etcd().ExtraArgs())
extraArgs := argsbuilder.Args(spec.ExtraArgs)

denyList := argsbuilder.WithDenyList(denyListArgs)

Expand Down

0 comments on commit c1e4507

Please sign in to comment.