Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: improve error messages for Helm commands #2597

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions cli/clustermesh.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func newCmdClusterMeshStatus() *cobra.Command {

cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if _, err := cm.Status(context.Background()); err != nil {
fatalf("Unable to determine status: %s", err)
fatalf("Failed to determine status: %s", err)
}
return nil
},
Expand Down Expand Up @@ -126,7 +126,7 @@ func newCmdExternalWorkloadCreate() *cobra.Command {
}
cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.CreateExternalWorkload(context.Background(), args); err != nil {
fatalf("Unable to add external workloads: %s", err)
fatalf("Failed to add external workloads: %s", err)
}
return nil
},
Expand All @@ -151,7 +151,7 @@ func newCmdExternalWorkloadDelete() *cobra.Command {
RunE: func(_ *cobra.Command, args []string) error {
cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.DeleteExternalWorkload(context.Background(), args); err != nil {
fatalf("Unable to remove external workloads: %s", err)
fatalf("Failed to remove external workloads: %s", err)
}
return nil
},
Expand Down Expand Up @@ -179,7 +179,7 @@ func newCmdExternalWorkloadInstall() *cobra.Command {
if len(args) > 0 {
file, err := os.Create(args[0])
if err != nil {
fatalf("Unable to open file %s: %s", args[0], err)
fatalf("Failed to open file %s: %s", args[0], err)
}
defer func() {
file.Chmod(0775)
Expand All @@ -190,7 +190,7 @@ func newCmdExternalWorkloadInstall() *cobra.Command {
writer = os.Stdout
}
if err := cm.WriteExternalWorkloadInstallScript(context.Background(), writer); err != nil {
fatalf("Unable to create external workload install script: %s", err)
fatalf("Failed to create external workload install script: %s", err)
}
return nil
},
Expand Down Expand Up @@ -218,7 +218,7 @@ func newCmdExternalWorkloadStatus() *cobra.Command {

cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.ExternalWorkloadStatus(context.Background(), args); err != nil {
fatalf("Unable to determine status: %s", err)
fatalf("Failed to determine status: %s", err)
}
return nil
},
Expand All @@ -243,7 +243,7 @@ func newCmdClusterMeshEnableWithHelm() *cobra.Command {
params.HelmReleaseName = helmReleaseName
ctx := context.Background()
if err := clustermesh.EnableWithHelm(ctx, k8sClient, params); err != nil {
fatalf("Unable to enable ClusterMesh: %s", err)
fatalf("Failed to enable ClusterMesh: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
return nil
},
Expand All @@ -270,7 +270,7 @@ func newCmdClusterMeshDisableWithHelm() *cobra.Command {
params.HelmReleaseName = helmReleaseName
ctx := context.Background()
if err := clustermesh.DisableWithHelm(ctx, k8sClient, params); err != nil {
fatalf("Unable to disable ClusterMesh: %s", err)
fatalf("Failed to disable ClusterMesh: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
return nil
},
Expand All @@ -293,7 +293,7 @@ func newCmdClusterMeshConnectWithHelm() *cobra.Command {
params.HelmReleaseName = helmReleaseName
cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.ConnectWithHelm(context.Background()); err != nil {
fatalf("Unable to connect cluster: %s", err)
fatalf("Failed to connect cluster: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
return nil
},
Expand All @@ -317,7 +317,7 @@ func newCmdClusterMeshDisconnectWithHelm() *cobra.Command {
params.HelmReleaseName = helmReleaseName
cm := clustermesh.NewK8sClusterMesh(k8sClient, params)
if err := cm.DisconnectWithHelm(context.Background()); err != nil {
fatalf("Unable to disconnect clusters: %s", err)
fatalf("Failed to disconnect clusters: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
},
}
Expand Down
8 changes: 4 additions & 4 deletions cli/hubble.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func newCmdPortForwardCommand() *cobra.Command {
ctx := context.Background()

if err := params.RelayPortForwardCommand(ctx, k8sClient); err != nil {
fatalf("Unable to port forward: %s", err)
fatalf("Failed to port forward: %s", err)
}
return nil
},
Expand All @@ -67,7 +67,7 @@ func newCmdUI() *cobra.Command {
params.Namespace = namespace

if err := params.UIPortForwardCommand(); err != nil {
fatalf("Unable to port forward: %s", err)
fatalf("Failed to port forward: %s", err)
}
return nil
},
Expand Down Expand Up @@ -99,7 +99,7 @@ func newCmdHubbleEnableWithHelm() *cobra.Command {
params.HelmReleaseName = helmReleaseName
ctx := context.Background()
if err := hubble.EnableWithHelm(ctx, k8sClient, params); err != nil {
fatalf("Unable to enable Hubble: %s", err)
fatalf("Failed to enable Hubble: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
return nil
},
Expand All @@ -123,7 +123,7 @@ func newCmdHubbleDisableWithHelm() *cobra.Command {
params.HelmReleaseName = helmReleaseName
ctx := context.Background()
if err := hubble.DisableWithHelm(ctx, k8sClient, params); err != nil {
fatalf("Unable to disable Hubble: %s", err)
fatalf("Failed to disable Hubble: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
return nil
},
Expand Down
8 changes: 4 additions & 4 deletions cli/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ cilium install --context kind-cluster1 --set cluster.id=1 --set cluster.name=clu
}
cmd.SilenceUsage = true
if err := installer.InstallWithHelm(context.Background(), k8sClient); err != nil {
fatalf("Unable to install Cilium: %s", err)
fatalf("Failed to install Cilium: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
return nil
},
Expand Down Expand Up @@ -129,7 +129,7 @@ func newCmdUninstallWithHelm() *cobra.Command {
if k8sErrors.IsNotFound(err) {
break
}
fatalf("Unable to list pods waiting for hubble-relay to stop: %s", err)
fatalf("Failed to list pods waiting for hubble-relay to stop: %s", err)
}
if len(ps.Items) == 0 {
break
Expand All @@ -144,7 +144,7 @@ func newCmdUninstallWithHelm() *cobra.Command {

fmt.Printf("⌛ Uninstalling Cilium\n")
if err := uninstaller.UninstallWithHelm(ctx, k8sClient.HelmActionConfig); err != nil {
fatalf("Unable to uninstall Cilium: %s", err)
fatalf("Failed to uninstall Cilium: %s", err)
}
return nil
},
Expand Down Expand Up @@ -185,7 +185,7 @@ cilium upgrade --set cluster.id=1 --set cluster.name=cluster1
}
cmd.SilenceUsage = true
if err := installer.UpgradeWithHelm(context.Background(), k8sClient); err != nil {
fatalf("Unable to upgrade Cilium: %s", err)
fatalf("Failed to upgrade Cilium: %s, please ensure that you have specified the --namespace and --helm-release-name if you are working with a cluster with customized Cilium installation.", err)
}
return nil
},
Expand Down
Loading