From 0948775e7fcb164fe30314879380ae34e8b2c466 Mon Sep 17 00:00:00 2001 From: Ross Jones Date: Thu, 21 Mar 2024 17:08:46 +0000 Subject: [PATCH] Allow nodes to call register on startup, even if previously registered (#3672) More gracefully handles registration flow for compute nodes that are already registered. Allows for re-registration of nodes by removing the sentinel file (if any) --- pkg/compute/management_client.go | 13 ++++++------- pkg/node/manager/node_manager.go | 4 +++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/pkg/compute/management_client.go b/pkg/compute/management_client.go index 020dc13b8d..31b0726ed9 100644 --- a/pkg/compute/management_client.go +++ b/pkg/compute/management_client.go @@ -61,13 +61,12 @@ func (m *ManagementClient) getNodeInfo(ctx context.Context) models.NodeInfo { }) } -// RegisterNode sends a registration request to the requester node iff -// we have not got evidence (a local sentinel file) that we have already -// registered. Should we fail to register, we will return an error and -// expect the caller to exit. +// RegisterNode sends a registration request to the requester node. If we successfully +// register, a sentinel file is created to indicate that we are registered. If present +// the requester node will know it is already registered. If not present, it will +// attempt to register again, expecting the requester node to gracefully handle any +// previous registrations. func (m *ManagementClient) RegisterNode(ctx context.Context) error { - // We only want to register this node if we haven't already - // been registered. if m.registrationFile.Exists() { log.Ctx(ctx).Debug().Msg("not registering with requester, already registered") return nil @@ -82,10 +81,10 @@ func (m *ManagementClient) RegisterNode(ctx context.Context) error { } if response.Accepted { - log.Ctx(ctx).Debug().Msg("register request accepted") if err := m.registrationFile.Set(); err != nil { return errors.Wrap(err, "failed to record local registration status") } + log.Ctx(ctx).Debug().Msg("register request accepted") } else { // Might be an error, or might be rejected because it is in a pending // state instead diff --git a/pkg/node/manager/node_manager.go b/pkg/node/manager/node_manager.go index e095226ce4..59d032afec 100644 --- a/pkg/node/manager/node_manager.go +++ b/pkg/node/manager/node_manager.go @@ -57,8 +57,10 @@ func (n *NodeManager) Register(ctx context.Context, request requests.RegisterReq }, nil } + // Otherwise we'll allow the registration, but let the compute node + // that it has already been registered on a previous occasion. return &requests.RegisterResponse{ - Accepted: false, + Accepted: true, Reason: "node already registered", }, nil }