diff --git a/cmd/openshift-diagnostics/main.go b/cmd/openshift-diagnostics/main.go deleted file mode 100644 index ccd5ca006213..000000000000 --- a/cmd/openshift-diagnostics/main.go +++ /dev/null @@ -1,46 +0,0 @@ -package main - -import ( - "math/rand" - "os" - "runtime" - "time" - - "k8s.io/apiserver/pkg/util/logs" - - "github.com/openshift/origin/pkg/cmd/util/serviceability" - "github.com/openshift/origin/pkg/oc/admin/diagnostics" - "github.com/spf13/cobra" - - // install all APIs - _ "github.com/openshift/origin/pkg/api/install" - _ "k8s.io/kubernetes/pkg/apis/autoscaling/install" - _ "k8s.io/kubernetes/pkg/apis/batch/install" - _ "k8s.io/kubernetes/pkg/apis/core/install" - _ "k8s.io/kubernetes/pkg/apis/extensions/install" -) - -func main() { - logs.InitLogs() - defer logs.FlushLogs() - defer serviceability.BehaviorOnPanic(os.Getenv("OPENSHIFT_ON_PANIC"))() - defer serviceability.Profile(os.Getenv("OPENSHIFT_PROFILE")).Stop() - - rand.Seed(time.Now().UTC().UnixNano()) - if len(os.Getenv("GOMAXPROCS")) == 0 { - runtime.GOMAXPROCS(runtime.NumCPU()) - } - - cmd := &cobra.Command{ - Use: "openshift-diagnostics", - Short: "Diagnose OpenShift clusters", - } - cmd.AddCommand( - diagnostics.NewCommandPodDiagnostics("diagnostic-pod", os.Stdout), - diagnostics.NewCommandNetworkPodDiagnostics("network-diagnostic-pod", os.Stdout), - ) - - if err := cmd.Execute(); err != nil { - os.Exit(1) - } -} diff --git a/hack/lib/constants.sh b/hack/lib/constants.sh index 7d4fcf187add..4acb21fa82d6 100755 --- a/hack/lib/constants.sh +++ b/hack/lib/constants.sh @@ -43,7 +43,6 @@ readonly OS_CROSS_COMPILE_TARGETS=( cmd/openshift cmd/oc cmd/oadm - cmd/openshift-diagnostics cmd/template-service-broker vendor/k8s.io/kubernetes/cmd/hyperkube ) @@ -75,6 +74,7 @@ readonly OPENSHIFT_BINARY_SYMLINKS=( ) readonly OC_BINARY_COPY=( kubectl + openshift-diagnostics ) readonly OS_BINARY_RELEASE_CLIENT_WINDOWS=( oc.exe diff --git a/origin.spec b/origin.spec index 4d0a0e7ed71b..9e9161b10731 100644 --- a/origin.spec +++ b/origin.spec @@ -331,6 +331,7 @@ do done ln -s oc %{buildroot}%{_bindir}/kubectl +ln -s oc %{buildroot}%{_bindir}/openshift-diagnostics install -d -m 0755 %{buildroot}%{_sysconfdir}/origin/{master,node} @@ -533,6 +534,7 @@ fi %license LICENSE %{_bindir}/oc %{_bindir}/kubectl +%{_bindir}/openshift-diagnostics %{_bindir}/oadm %{_sysconfdir}/bash_completion.d/oc %{_mandir}/man1/oc* diff --git a/pkg/oc/admin/diagnostics/inpod.go b/pkg/oc/admin/diagnostics/inpod.go new file mode 100644 index 000000000000..06d56dfeb63a --- /dev/null +++ b/pkg/oc/admin/diagnostics/inpod.go @@ -0,0 +1,26 @@ +package diagnostics + +import ( + "io" + + "github.com/spf13/cobra" +) + +const ( + DiagnosticsInPodRecommendedName = "openshift-diagnostics" +) + +// NewCmdDiagnosticsInPod defines the base command that is used inside of a pod +// orchestrated by a regular diagnostic, to report from the in-pod vantage point. +func NewCmdDiagnosticsInPod(name string, fullName string, out io.Writer) *cobra.Command { + cmd := &cobra.Command{ + Use: name, + Short: "Diagnose OpenShift from inside a pod", + } + cmd.AddCommand( + NewCommandPodDiagnostics("diagnostic-pod", out), + NewCommandNetworkPodDiagnostics("network-diagnostic-pod", out), + ) + + return cmd +} diff --git a/pkg/oc/cli/cli.go b/pkg/oc/cli/cli.go index f278633bbe15..d2776b7cdbde 100644 --- a/pkg/oc/cli/cli.go +++ b/pkg/oc/cli/cli.go @@ -312,6 +312,8 @@ func CommandFor(basename string) *cobra.Command { switch basename { case "kubectl": cmd = kubecmd.NewKubectlCommand(kcmdutil.NewFactory(nil), in, out, errout) + case diagnostics.DiagnosticsInPodRecommendedName: + cmd = diagnostics.NewCmdDiagnosticsInPod(basename, basename, out) default: cmd = NewCommandCLI("oc", "oc", in, out, errout) }