Skip to content

Commit

Permalink
Merge pull request #8684 from tstromberg/none-cni
Browse files Browse the repository at this point in the history
none CNI: error if portmap plug-in is required but unavailable
  • Loading branch information
medyagh authored Jul 10, 2020
2 parents 231bf12 + 0b3e2ae commit 3c9e96e
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
9 changes: 9 additions & 0 deletions pkg/minikube/cni/flannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ limitations under the License.
package cni

import (
"os/exec"

"github.com/pkg/errors"
"k8s.io/minikube/pkg/minikube/config"
)

Expand Down Expand Up @@ -637,6 +640,12 @@ func (c Flannel) String() string {

// Apply enables the CNI
func (c Flannel) Apply(r Runner) error {
// Mostly applicable to the 'none' driver
_, err := r.RunCmd(exec.Command("stat", "/opt/cni/bin/portmap"))
if err != nil {
return errors.Wrap(err, "required 'portmap' CNI plug-in not found")
}

return applyManifest(c.cc, r, manifestAsset([]byte(flannelTmpl)))
}

Expand Down
7 changes: 7 additions & 0 deletions pkg/minikube/cni/kindnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cni

import (
"bytes"
"os/exec"
"text/template"

"github.com/pkg/errors"
Expand Down Expand Up @@ -168,6 +169,12 @@ func (c KindNet) manifest() (assets.CopyableFile, error) {

// Apply enables the CNI
func (c KindNet) Apply(r Runner) error {
// This is mostly applicable to the 'none' driver
_, err := r.RunCmd(exec.Command("stat", "/opt/cni/bin/portmap"))
if err != nil {
return errors.Wrap(err, "required 'portmap' CNI plug-in not found")
}

m, err := c.manifest()
if err != nil {
return errors.Wrap(err, "manifest")
Expand Down
11 changes: 10 additions & 1 deletion test/integration/net_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,16 @@ func TestNetworkPlugins(t *testing.T) {
}
if !t.Failed() {
t.Run("KubeletFlags", func(t *testing.T) {
rr, err := Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "pgrep -a kubelet"))
var rr *RunResult
var err error

// none does not support 'minikube ssh'
if NoneDriver() {
rr, err = Run(t, exec.CommandContext(ctx, "pgrep", "-a", "kubelet"))
} else {
rr, err = Run(t, exec.CommandContext(ctx, Target(), "ssh", "-p", profile, "pgrep -a kubelet"))
}

if err != nil {
t.Fatalf("ssh failed: %v", err)
}
Expand Down

0 comments on commit 3c9e96e

Please sign in to comment.