@@ -55,23 +55,25 @@ func Join(ctx context.Context, params JoinParams) (*JoinResult, error) {
5555 if params .ID .Role != types .RoleInstance && params .ID .Role != types .RoleBot {
5656 return nil , trace .BadParameter ("Only Instance and Bot roles may be used for direct join attempts" )
5757 }
58+
5859 slog .InfoContext (ctx , "Trying to join with the new join service" )
5960 result , err := joinNew (ctx , params )
60- if trace .IsNotImplemented (err ) {
61- // Fall back to joining via legacy service.
62- slog .InfoContext (ctx , "Falling back to joining via the legacy join service" , "error" , err )
63- // Non-bots must generate their own host UUID when joining via legacy service.
64- if params .ID .Role != types .RoleBot {
65- hostID , err := hostid .Generate (ctx , params .JoinMethod )
66- if err != nil {
67- return nil , trace .Wrap (err , "generating host ID" )
68- }
69- params .ID .HostUUID = hostID
61+ if err == nil {
62+ return result , nil
63+ }
64+
65+ // Fall back to joining via legacy service.
66+ slog .InfoContext (ctx , "Falling back to joining via the legacy join service" , "error" , err )
67+ // Non-bots must generate their own host UUID when joining via legacy service.
68+ if params .ID .Role != types .RoleBot {
69+ hostID , err := hostid .Generate (ctx , params .JoinMethod )
70+ if err != nil {
71+ return nil , trace .Wrap (err , "generating host ID" )
7072 }
71- result , err := LegacyJoin (ctx , params )
72- return result , trace .Wrap (err )
73+ params .ID .HostUUID = hostID
7374 }
74- return result , trace .Wrap (err )
75+ result , err = LegacyJoin (ctx , params )
76+ return result , trace .Wrap (err , "joining via legacy join service" )
7577}
7678
7779// LegacyJoin is used to join the cluster via the legacy service with client-chosen host UUIDs.
0 commit comments