Skip to content

Commit 37dccba

Browse files
author
Ravi Sankar Penta
committed
Make network diagnostic pod image configurable
1 parent b640a0e commit 37dccba

File tree

6 files changed

+13
-3
lines changed

6 files changed

+13
-3
lines changed

pkg/cmd/admin/diagnostics/client.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ func (o DiagnosticsOptions) buildClientDiagnostics(rawConfig *clientcmdapi.Confi
6262
Factory: o.Factory,
6363
PreventModification: o.PreventModification,
6464
LogDir: o.NetworkDiagLogDir,
65+
PodImage: o.NetworkDiagPodImage,
6566
})
6667
default:
6768
return nil, false, fmt.Errorf("unknown diagnostic: %v", diagnosticName)

pkg/cmd/admin/diagnostics/diagnostics.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ type DiagnosticsOptions struct {
4444
PreventModification bool
4545
// Path to store network diagnostic results in case of errors
4646
NetworkDiagLogDir string
47+
// Image to use for network diagnostic pod
48+
NetworkDiagPodImage string
4749
// We need a factory for creating clients. Creating a factory
4850
// creates flags as a byproduct, most of which we don't want.
4951
// The command creates these and binds only the flags we want.
@@ -133,6 +135,7 @@ func NewCmdDiagnostics(name string, fullName string, out io.Writer) *cobra.Comma
133135
cmd.Flags().BoolVar(&o.ImageTemplate.Latest, options.FlagLatestImageName, false, "If true, when expanding the image template, use latest version, not release version")
134136
cmd.Flags().BoolVar(&o.PreventModification, options.FlagPreventModificationName, false, "If true, may be set to prevent diagnostics making any changes via the API")
135137
cmd.Flags().StringVar(&o.NetworkDiagLogDir, options.FlagNetworkDiagLogDir, netutil.NetworkDiagDefaultLogDir, "Path to store network diagnostic results in case of errors")
138+
cmd.Flags().StringVar(&o.NetworkDiagPodImage, options.FlagNetworkDiagPodImage, netutil.NetworkDiagDefaultPodImage, "Image to use for network diagnostic pod")
136139
flagtypes.GLog(cmd.Flags())
137140
options.BindLoggerOptionFlags(cmd.Flags(), o.LogOptions, options.RecommendedLoggerOptionFlags())
138141

pkg/cmd/admin/diagnostics/options/flaginfo.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,5 @@ const (
5454
FlagLatestImageName = "latest-images"
5555
FlagPreventModificationName = "prevent-modification"
5656
FlagNetworkDiagLogDir = "network-logdir"
57+
FlagNetworkDiagPodImage = "network-pod-image"
5758
)

pkg/diagnostics/network/objects.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ import (
1313
)
1414

1515
const (
16-
diagnosticsImage = "openshift/origin"
1716
networkDiagTestPodSelector = "network-diag-pod-name"
1817

1918
testPodImage = "docker.io/openshift/hello-openshift"
2019
testPodPort = 9876
2120
testTargetPort = 8080
2221
)
2322

24-
func GetNetworkDiagnosticsPod(command, podName, nodeName string) *kapi.Pod {
23+
func GetNetworkDiagnosticsPod(diagnosticsImage, command, podName, nodeName string) *kapi.Pod {
2524
privileged := true
2625
hostRootVolName := "host-root-dir"
2726
secretVolName := "kconfig-secret"

pkg/diagnostics/network/run_pod.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ type NetworkDiagnostic struct {
3131
Factory *osclientcmd.Factory
3232
PreventModification bool
3333
LogDir string
34+
PodImage string
3435

3536
pluginName string
3637
nodes []kapi.Node
@@ -94,6 +95,9 @@ func (d *NetworkDiagnostic) Check() types.DiagnosticResult {
9495
if len(d.LogDir) == 0 {
9596
d.LogDir = util.NetworkDiagDefaultLogDir
9697
}
98+
if len(d.PodImage) == 0 {
99+
d.PodImage = util.NetworkDiagDefaultPodImage
100+
}
97101
d.runNetworkDiagnostic()
98102
return d.res
99103
}
@@ -172,7 +176,7 @@ func (d *NetworkDiagnostic) runNetworkPod(command string) error {
172176
for _, node := range d.nodes {
173177
podName := kapi.SimpleNameGenerator.GenerateName(fmt.Sprintf("%s-", util.NetworkDiagPodNamePrefix))
174178

175-
pod := GetNetworkDiagnosticsPod(command, podName, node.Name)
179+
pod := GetNetworkDiagnosticsPod(d.PodImage, command, podName, node.Name)
176180
_, err := d.KubeClient.Core().Pods(d.nsName1).Create(pod)
177181
if err != nil {
178182
return fmt.Errorf("Creating network diagnostic pod %q on node %q with command %q failed: %v", podName, node.Name, command, err)

pkg/diagnostics/networkpod/util/util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ const (
3131
NetworkDiagNodeLogDirPrefix = "/nodes"
3232
NetworkDiagMasterLogDirPrefix = "/master"
3333
NetworkDiagPodLogDirPrefix = "/pods"
34+
35+
NetworkDiagDefaultPodImage = "openshift/origin"
3436
)
3537

3638
func GetOpenShiftNetworkPlugin(osClient *osclient.Client) (string, bool, error) {

0 commit comments

Comments
 (0)