Skip to content

Commit

Permalink
openshift-diagnostics => diagnostics subcommands
Browse files Browse the repository at this point in the history
Instead of building a separate `openshift-diagnostics` just turn its
subcommands into hidden subcommands on `oc adm diagnostics`.
Then use these within diagnostics pods.

fixes openshift#18141
fixes https://bugzilla.redhat.com/show_bug.cgi?id=1534513
  • Loading branch information
sosiouxme committed Jan 19, 2018
1 parent 241fd4f commit 7b8ab0f
Show file tree
Hide file tree
Showing 15 changed files with 45 additions and 67 deletions.
46 changes: 0 additions & 46 deletions cmd/openshift-diagnostics/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion contrib/vagrant/provision-util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ os::provision::install-cmds() {
local deployed_root=$1

local output_path="$(os::build::get-bin-output-path "${deployed_root}")"
cp ${output_path}/{openshift,openshift-diagnostics,oc} /usr/bin
cp ${output_path}/{openshift,oc} /usr/bin
}

os::provision::add-to-hosts-file() {
Expand Down
4 changes: 4 additions & 0 deletions docs/man/man1/.files_generated_oc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/man/man1/oc-adm-diagnostics-inpod-networkcheck.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/man/man1/oc-adm-diagnostics-inpod-poddiagnostic.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/man/man1/oc-ex-diagnostics-inpod-networkcheck.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions docs/man/man1/oc-ex-diagnostics-inpod-poddiagnostic.1

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion hack/dind-cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,6 @@ function copy-runtime() {
local target=$2

cp "$(os::util::find::built_binary openshift)" "${target}"
cp "$(os::util::find::built_binary openshift-diagnostics)" "${target}"
cp "$(os::util::find::built_binary oc)" "${target}"
cp "$(os::util::find::built_binary host-local)" "${target}"
cp "$(os::util::find::built_binary loopback)" "${target}"
Expand Down
1 change: 0 additions & 1 deletion hack/lib/constants.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
1 change: 0 additions & 1 deletion images/dind/node/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ RUN mkdir -p /opt/cni/bin
# make reloading easy. Revisit if/when dind becomes useful for more
# than dev/test.
RUN ln -sf /data/openshift /usr/local/bin/ && \
ln -sf /data/openshift-diagnostics /usr/local/bin/ && \
ln -sf /data/oc /usr/local/bin/ && \
ln -sf /data/openshift /usr/local/bin/openshift-deploy && \
ln -sf /data/openshift /usr/local/bin/openshift-docker-build && \
Expand Down
7 changes: 7 additions & 0 deletions pkg/oc/admin/diagnostics/diagnostics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import (

"github.com/openshift/origin/pkg/client/config"
"github.com/openshift/origin/pkg/cmd/flagtypes"
clientdiag "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/client"
"github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/log"
networkdiag "github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/network"
"github.com/openshift/origin/pkg/oc/admin/diagnostics/diagnostics/types"
"github.com/openshift/origin/pkg/oc/admin/diagnostics/options"
osclientcmd "github.com/openshift/origin/pkg/oc/cli/util/clientcmd"
Expand Down Expand Up @@ -141,6 +143,11 @@ func NewCmdDiagnostics(name string, fullName string, out io.Writer) *cobra.Comma
for _, diag := range available {
cmd.AddCommand(NewCmdDiagnosticsIndividual(strings.ToLower(diag.Name()), fullName+" "+strings.ToLower(diag.Name()), out, diag))
}
// add hidden in-pod subcommands
cmd.AddCommand(
NewCommandPodDiagnostics(clientdiag.InPodDiagnosticRecommendedName, out),
NewCommandNetworkPodDiagnostics(networkdiag.InPodNetworkCheckRecommendedName, out),
)

return cmd
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ import (
)

const (
DiagnosticPodName = "DiagnosticPod"
ImageTemplateParam = "images"
LatestImageParam = "latest-images"
InPodDiagnosticRecommendedName = "inpod-poddiagnostic"
DiagnosticPodName = "DiagnosticPod"
ImageTemplateParam = "images"
LatestImageParam = "latest-images"
)

// DiagnosticPod is a diagnostic that runs a diagnostic pod and relays the results.
Expand Down Expand Up @@ -87,7 +88,7 @@ func (d *DiagnosticPod) runDiagnosticPod(r types.DiagnosticResult) {
{
Name: "pod-diagnostics",
Image: imageName,
Command: []string{"openshift-diagnostics", "diagnostic-pod", "-l", strconv.Itoa(loglevel)},
Command: []string{"oc", "adm", "diagnostics", InPodDiagnosticRecommendedName, "-l", strconv.Itoa(loglevel)},
},
},
},
Expand Down
15 changes: 8 additions & 7 deletions pkg/oc/admin/diagnostics/diagnostics/network/run_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ import (
)

const (
NetworkDiagnosticName = "NetworkCheck"
FlagNetworkDiagLogDir = "logdir"
FlagNetworkDiagPodImage = "pod-image"
FlagNetworkDiagTestPodImage = "test-pod-image"
FlagNetworkDiagTestPodProtocol = "test-pod-protocol"
FlagNetworkDiagTestPodPort = "test-pod-port"
InPodNetworkCheckRecommendedName = "inpod-networkcheck"
NetworkDiagnosticName = "NetworkCheck"
FlagNetworkDiagLogDir = "logdir"
FlagNetworkDiagPodImage = "pod-image"
FlagNetworkDiagTestPodImage = "test-pod-image"
FlagNetworkDiagTestPodProtocol = "test-pod-protocol"
FlagNetworkDiagTestPodPort = "test-pod-port"
)

// NetworkDiagnostic is a diagnostic that runs a network diagnostic pod and relays the results.
Expand Down Expand Up @@ -181,7 +182,7 @@ func (d *NetworkDiagnostic) runNetworkDiagnostic() {
// In Collection phase, results from each node are moved to the user machine where the CLI cmd is executed.

// TEST Phase: Run network diagnostic pod on all valid nodes in parallel
command := fmt.Sprintf("openshift-diagnostics network-diagnostic-pod -l %d", loglevel)
command := fmt.Sprintf("oc adm diagnostics %s -l %d", InPodNetworkCheckRecommendedName, loglevel)
if err := d.runNetworkPod(command); err != nil {
d.res.Error("DNet2006", err, err.Error())
return
Expand Down
7 changes: 4 additions & 3 deletions pkg/oc/admin/diagnostics/network_pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ func NewCommandNetworkPodDiagnostics(name string, out io.Writer) *cobra.Command
}

cmd := &cobra.Command{
Use: name,
Short: "Within a privileged pod, run network diagnostics",
Long: fmt.Sprintf(longNetworkPodDiagDescription),
Use: name,
Short: "Within a privileged pod, run network diagnostics",
Long: fmt.Sprintf(longNetworkPodDiagDescription),
Hidden: true,
Run: func(c *cobra.Command, args []string) {
kcmdutil.CheckErr(o.Complete(args))

Expand Down
7 changes: 4 additions & 3 deletions pkg/oc/admin/diagnostics/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ func NewCommandPodDiagnostics(name string, out io.Writer) *cobra.Command {
}

cmd := &cobra.Command{
Use: name,
Short: "Within a pod, run pod diagnostics",
Long: fmt.Sprintf(longPodDiagDescription),
Use: name,
Short: "Within a pod, run pod diagnostics",
Long: fmt.Sprintf(longPodDiagDescription),
Hidden: true,
Run: func(c *cobra.Command, args []string) {
kcmdutil.CheckErr(o.Complete(args))

Expand Down

0 comments on commit 7b8ab0f

Please sign in to comment.