Skip to content

Commit

Permalink
[TEST] Return internal error
Browse files Browse the repository at this point in the history
  • Loading branch information
HomayoonAlimohammadi committed Jul 24, 2024
1 parent 73358d8 commit e29b359
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/parts/
/stage/
/prime/
.vscode/
env/


**.snap
Expand All @@ -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
/docs/tools/.sphinx/node_modules
2 changes: 1 addition & 1 deletion src/k8s/cmd/k8s/k8s_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions src/k8s/pkg/k8sd/api/impl/k8sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package impl

import (
"context"
"errors"
"fmt"

apiv1 "github.com/canonical/k8s/api/v1"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/k8s/pkg/k8sd/api/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit e29b359

Please sign in to comment.