From 0faf0ae2b4275fd23729baefefbf8d6bc9d8bd9d Mon Sep 17 00:00:00 2001 From: Serge Logvinov Date: Thu, 25 Apr 2024 20:23:17 +0300 Subject: [PATCH] fix: refresh talos token Due to the failover process, we also need to refresh the Talos token. Signed-off-by: Serge Logvinov --- pkg/talos/client.go | 2 +- pkg/talos/cloud.go | 2 +- pkg/talos/instances.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/talos/client.go b/pkg/talos/client.go index d31716b..ffca6fc 100644 --- a/pkg/talos/client.go +++ b/pkg/talos/client.go @@ -47,7 +47,7 @@ func newClient(ctx context.Context, config *cloudConfig) (*client, error) { }, nil } -func (c *client) refreshClient(ctx context.Context) error { +func (c *client) refreshTalosClient(ctx context.Context) error { if _, err := c.talos.Version(ctx); err != nil { talos, err := newClient(ctx, c.config) if err != nil { diff --git a/pkg/talos/cloud.go b/pkg/talos/cloud.go index 4d9a93e..3b601c6 100644 --- a/pkg/talos/cloud.go +++ b/pkg/talos/cloud.go @@ -75,7 +75,7 @@ func (c *cloud) Initialize(clientBuilder cloudprovider.ControllerClientBuilder, c.ctx = ctx c.stop = cancel - if _, err := c.client.talos.Version(c.ctx); err != nil { + if err := c.client.refreshTalosClient(c.ctx); err != nil { klog.Errorf("failed to initialized talos client: %v", err) return diff --git a/pkg/talos/instances.go b/pkg/talos/instances.go index 32c421d..7c859a4 100644 --- a/pkg/talos/instances.go +++ b/pkg/talos/instances.go @@ -60,7 +60,7 @@ func (i *instances) InstanceMetadata(ctx context.Context, node *v1.Node) (*cloud nodeIP string ) - if err = i.c.refreshClient(ctx); err != nil { + if err = i.c.refreshTalosClient(ctx); err != nil { return nil, fmt.Errorf("error refreshing client connection: %w", err) }