Skip to content

Commit b7e091b

Browse files
committed
Display warning when socat cmd is missing
Display warning to users when executing cluster up without `socat` cmd installed
1 parent 7f5189a commit b7e091b

File tree

1 file changed

+16
-0
lines changed
  • pkg/oc/bootstrap/docker

1 file changed

+16
-0
lines changed

pkg/oc/bootstrap/docker/up.go

+16
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
"github.com/openshift/origin/pkg/oc/bootstrap/docker/dockermachine"
3434
"github.com/openshift/origin/pkg/oc/bootstrap/docker/errors"
3535
"github.com/openshift/origin/pkg/oc/bootstrap/docker/host"
36+
"github.com/openshift/origin/pkg/oc/bootstrap/docker/localcmd"
3637
"github.com/openshift/origin/pkg/oc/bootstrap/docker/openshift"
3738
"github.com/openshift/origin/pkg/oc/cli/util/clientcmd"
3839
osclientcmd "github.com/openshift/origin/pkg/oc/cli/util/clientcmd"
@@ -334,6 +335,7 @@ func (c *CommonStartConfig) Complete(f *osclientcmd.Factory, cmd *cobra.Command)
334335
c.addTask(simpleTask("Checking OpenShift client", c.CheckOpenShiftClient))
335336

336337
c.addTask(conditionalTask("Create Docker machine", c.CreateDockerMachine, func() bool { return c.ShouldCreateDockerMachine }))
338+
337339
// Get a Docker client.
338340
// If a Docker machine was specified, make sure that the machine is running.
339341
// Otherwise, use environment variables.
@@ -342,6 +344,8 @@ func (c *CommonStartConfig) Complete(f *osclientcmd.Factory, cmd *cobra.Command)
342344
// Check that we have the minimum Docker version available to run OpenShift
343345
c.addTask(simpleTask("Checking Docker version", c.CheckDockerVersion))
344346

347+
c.addTask(conditionalTask("Checking prerequisites for port forwarding", c.CheckPortForwardingPrerequisites, func() bool { return c.PortForwarding }))
348+
345349
// Check for an OpenShift container. If one exists and is running, exit.
346350
// If one exists but not running, delete it.
347351
c.addTask(simpleTask("Checking for existing OpenShift container", c.CheckExistingOpenShiftContainer))
@@ -739,6 +743,18 @@ func (c *CommonStartConfig) CheckDockerVersion(out io.Writer) error {
739743
return nil
740744
}
741745

746+
// CheckPortForwardingPrerequisites checks that socat is installed when port forwarding is enabled
747+
// Socat needs to be installed manually on MacOS
748+
func (c *CommonStartConfig) CheckPortForwardingPrerequisites(out io.Writer) error {
749+
err := localcmd.New("socat").Args("-V").Run()
750+
if err != nil {
751+
glog.V(2).Infof("Error from socat command execution: %v", err)
752+
fmt.Fprintf(out, "WARNING: Port forwarding requires socat command line utility."+
753+
"Cluster public ip may not be reachable. Please make sure socat installed in your operating system \n")
754+
}
755+
return nil
756+
}
757+
742758
func (c *CommonStartConfig) EnsureHostDirectories(io.Writer) error {
743759
return c.HostHelper().EnsureHostDirectories(!c.UseNsenterMount)
744760
}

0 commit comments

Comments
 (0)