diff --git a/.gitignore b/.gitignore index a2f58b2f08..976bbd3fac 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ /parts/ /stage/ /prime/ +.vscode/ +env/ **.snap @@ -20,4 +22,4 @@ k8s_*.txt /docs/tools/.sphinx/warnings.txt /docs/tools/.sphinx/.wordlist.dic /docs/tools/.sphinx/.doctrees/ -/docs/tools/.sphinx/node_modules \ No newline at end of file +/docs/tools/.sphinx/node_modules diff --git a/src/k8s/cmd/k8s/k8s_status.go b/src/k8s/cmd/k8s/k8s_status.go index e5ffdec5bd..3fcdc752cc 100644 --- a/src/k8s/cmd/k8s/k8s_status.go +++ b/src/k8s/cmd/k8s/k8s_status.go @@ -36,7 +36,7 @@ func newStatusCmd(env cmdutil.ExecutionEnvironment) *cobra.Command { cobra.OnFinalize(cancel) if _, err := client.NodeStatus(cmd.Context()); err != nil { - cmd.PrintErrln("Error: The node is not part of a Kubernetes cluster. You can bootstrap a new cluster with:\n\n sudo k8s bootstrap") + cmd.PrintErrf("Error: The node is not part of a Kubernetes cluster. You can bootstrap a new cluster with:\n\n sudo k8s bootstrap: original error: %v\n", err) env.Exit(1) return } diff --git a/src/k8s/pkg/k8sd/api/impl/k8sd.go b/src/k8s/pkg/k8sd/api/impl/k8sd.go index 8751ddefdd..5ed59be668 100644 --- a/src/k8s/pkg/k8sd/api/impl/k8sd.go +++ b/src/k8s/pkg/k8sd/api/impl/k8sd.go @@ -2,6 +2,7 @@ package impl import ( "context" + "errors" "fmt" apiv1 "github.com/canonical/k8s/api/v1" @@ -39,6 +40,7 @@ func GetClusterMembers(ctx context.Context, s *state.State) ([]apiv1.NodeStatus, // GetLocalNodeStatus retrieves the status of the local node, including its roles within the cluster. // Unlike "GetClusterMembers" this also works on a worker node. func GetLocalNodeStatus(ctx context.Context, s *state.State, snap snap.Snap) (apiv1.NodeStatus, error) { + return apiv1.NodeStatus{}, errors.New("something went wrong") // Determine cluster role. clusterRole := apiv1.ClusterRoleUnknown isWorker, err := snaputil.IsWorker(snap) diff --git a/src/k8s/pkg/k8sd/api/node.go b/src/k8s/pkg/k8sd/api/node.go index bc9664f5f2..eb6ea1c03c 100644 --- a/src/k8s/pkg/k8sd/api/node.go +++ b/src/k8s/pkg/k8sd/api/node.go @@ -14,7 +14,7 @@ func (e *Endpoints) getNodeStatus(s *state.State, r *http.Request) response.Resp status, err := impl.GetLocalNodeStatus(r.Context(), s, snap) if err != nil { - response.InternalError(err) + return response.InternalError(err) } result := apiv1.GetNodeStatusResponse{