From 5a67e54c1e2fedeba165fdfff4e2f82e4cfa9813 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julian=20Peliz=C3=A4us?= Date: Mon, 20 Apr 2026 11:59:47 +0200 Subject: [PATCH] service: Create join tokens with a lifetime of 1 hour MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This accommodates slower environments but especially join procedures with lots of necessary setup actions. An example is setting up a MicroCloud with many OSDs. Fixes https://github.com/canonical/microcloud/issues/1339. Signed-off-by: Julian Pelizäus --- service/microceph.go | 5 +++-- service/microcloud.go | 5 +++-- service/microovn.go | 5 +++-- service/service_handler.go | 4 ++++ 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/service/microceph.go b/service/microceph.go index 4ff839be1..901cd4526 100644 --- a/service/microceph.go +++ b/service/microceph.go @@ -103,9 +103,10 @@ func (s CephService) Bootstrap(ctx context.Context) error { } } -// IssueToken issues a token for the given peer. Each token will last 5 minutes in case the system joins the cluster very slowly. +// IssueToken issues a token for the given peer. +// Each token will last 1 hour in case the system joins the cluster very slowly or there are other services which take longer to join (e.g. MicroCeph OSD setup). func (s CephService) IssueToken(ctx context.Context, peer string) (string, error) { - return s.m.NewJoinToken(ctx, peer, 5*time.Minute) + return s.m.NewJoinToken(ctx, peer, ServiceJoinTokenLifetime) } // DeleteToken deletes a token by its name. diff --git a/service/microcloud.go b/service/microcloud.go index 29680229e..af9874b5e 100644 --- a/service/microcloud.go +++ b/service/microcloud.go @@ -99,9 +99,10 @@ func (s CloudService) Bootstrap(ctx context.Context) error { } } -// IssueToken issues a token for the given peer. Each token will last 5 minutes in case the system joins the cluster very slowly. +// IssueToken issues a token for the given peer. +// Each token will last 1 hour in case the system joins the cluster very slowly or there are other services which take longer to join (e.g. MicroCeph OSD setup). func (s CloudService) IssueToken(ctx context.Context, peer string) (string, error) { - return s.client.NewJoinToken(ctx, peer, 5*time.Minute) + return s.client.NewJoinToken(ctx, peer, ServiceJoinTokenLifetime) } // DeleteToken deletes a token by its name. diff --git a/service/microovn.go b/service/microovn.go index 477e34ad8..bd43b0d39 100644 --- a/service/microovn.go +++ b/service/microovn.go @@ -89,9 +89,10 @@ func (s OVNService) Bootstrap(ctx context.Context) error { } } -// IssueToken issues a token for the given peer. Each token will last 5 minutes in case the system joins the cluster very slowly. +// IssueToken issues a token for the given peer. +// Each token will last 1 hour in case the system joins the cluster very slowly or there are other services which take longer to join (e.g. MicroCeph OSD setup). func (s OVNService) IssueToken(ctx context.Context, peer string) (string, error) { - return s.m.NewJoinToken(ctx, peer, 5*time.Minute) + return s.m.NewJoinToken(ctx, peer, ServiceJoinTokenLifetime) } // DeleteToken deletes a token by its name. diff --git a/service/service_handler.go b/service/service_handler.go index 82d83aef9..12e4ab99e 100644 --- a/service/service_handler.go +++ b/service/service_handler.go @@ -7,6 +7,7 @@ import ( "os" "path/filepath" "sync" + "time" "github.com/canonical/lxd/shared/api" @@ -31,6 +32,9 @@ const ( CloudMulticastPort int64 = 9444 ) +// ServiceJoinTokenLifetime is the duration for which a join token issued by a service will be valid. +const ServiceJoinTokenLifetime = time.Hour + // Handler holds a set of stateful services. type Handler struct { Services map[types.ServiceType]Service