Skip to content

Commit cc449c5

Browse files
author
Ravi Sankar Penta
committed
Fix network diagnostic default image path
- variable.DefaultImagePrefix is populated from {node,master}-config.yaml (imageConfig.format) and if this value is not specified in the config, openshift ansible defaults it to 'registry.access.redhat.com'. - Network diagnostics is run as a admin CLI command so there is no config for variable.DefaultImagePrefix and it defaults to 'registry.access.redhat.com' which may not be true for AWS or some other openshift environments. - This change will remove the registry path from the default image so that it defaults to registry configured on the openshift node. Example: Earlier image path: registry.access.redhat.com/openshift3/ose New image path: openshift3/ose On AWS node, this will resolve to registry.reg-aws.openshift.com:443/openshift3/ose
1 parent 9a94985 commit cc449c5

File tree

1 file changed

+16
-2
lines changed
  • pkg/diagnostics/networkpod/util

1 file changed

+16
-2
lines changed

pkg/diagnostics/networkpod/util/util.go

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,29 @@ const (
3737
NetworkDiagDefaultTestPodPort = 8080
3838
)
3939

40+
func trimRegistryPath(image string) string {
41+
// Image format could be: [<dns-name>/]openshift/origin-deployer[:<tag>]
42+
// Return image without registry dns: openshift/origin-deployer[:<tag>]
43+
tokens := strings.Split(image, "/")
44+
sz := len(tokens)
45+
trimmedImage := image
46+
if sz >= 2 {
47+
trimmedImage = fmt.Sprintf("%s/%s", tokens[sz-2], tokens[sz-1])
48+
}
49+
return trimmedImage
50+
}
51+
4052
func GetNetworkDiagDefaultPodImage() string {
4153
imageTemplate := variable.NewDefaultImageTemplate()
4254
imageTemplate.Format = variable.DefaultImagePrefix + ":${version}"
43-
return imageTemplate.ExpandOrDie("")
55+
image := imageTemplate.ExpandOrDie("")
56+
return trimRegistryPath(image)
4457
}
4558

4659
func GetNetworkDiagDefaultTestPodImage() string {
4760
imageTemplate := variable.NewDefaultImageTemplate()
48-
return imageTemplate.ExpandOrDie("deployer")
61+
image := imageTemplate.ExpandOrDie("deployer")
62+
return trimRegistryPath(image)
4963
}
5064

5165
func GetOpenShiftNetworkPlugin(clusterNetworkClient networktypedclient.ClusterNetworksGetter) (string, bool, error) {

0 commit comments

Comments
 (0)