Skip to content

Commit

Permalink
check microcluster ready status in join endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
bschimke95 committed Dec 6, 2024
1 parent 7c1391e commit 7f8155a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/k8s/pkg/k8sd/api/cluster_join.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ func (e *Endpoints) postClusterJoin(s state.State, r *http.Request) response.Res
if err != nil {
return response.BadRequest(fmt.Errorf("invalid hostname %q: %w", req.Name, err))
}
// Check if the cluster is already bootstrapped
status, err := e.provider.MicroCluster().Status(r.Context())
if err != nil {
return response.BadRequest(fmt.Errorf("failed to get microcluster status: %w", err))
}

if _, err := e.provider.MicroCluster().Status(r.Context()); err == nil {
if status.Ready {
return NodeInUse(fmt.Errorf("node %q is part of the cluster", hostname))
}

Expand Down

0 comments on commit 7f8155a

Please sign in to comment.