Skip to content

Commit aee3c1d

Browse files
authored
Merge branch 'master' into driver-fallback
2 parents c40a942 + 7fd834e commit aee3c1d

File tree

38 files changed

+924
-374
lines changed

38 files changed

+924
-374
lines changed

Diff for: .github/workflows/main.yml

+76-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
run : |
2020
make minikube-linux-amd64
2121
make e2e-linux-amd64
22+
make minikube-windows-amd64.exe
23+
make e2e-windows-amd64.exe
2224
cp -r test/integration/testdata ./out
2325
whoami
2426
echo github ref $GITHUB_REF
@@ -117,7 +119,7 @@ jobs:
117119
with:
118120
name: minikube_binaries
119121
- name: Run Integration Test
120-
continue-on-error: true
122+
continue-on-error: false
121123
# bash {0} to allow test to continue to next step. in case of
122124
shell: bash {0}
123125
run: |
@@ -251,6 +253,70 @@ jobs:
251253
numPass=$(echo $STAT | jq '.NumberOfPass')
252254
echo "*** $numPass Passed ***"
253255
if [ "$numFail" -gt 0 ];then echo "*** $numFail Failed ***";exit 2;fi
256+
docker_on_windows:
257+
needs: [build_minikube]
258+
env:
259+
TIME_ELAPSED: time
260+
JOB_NAME: "Docker_on_windows"
261+
COMMIT_STATUS: ""
262+
runs-on: windows-latest
263+
steps:
264+
- uses: actions/checkout@v2
265+
- name: Docker Info
266+
shell: bash
267+
run: |
268+
docker info || true
269+
docker version || true
270+
docker ps || true
271+
- name: Download gopogh
272+
run: |
273+
curl -LO https://github.com/medyagh/gopogh/releases/download/v0.1.16/gopogh.exe
274+
shell: bash
275+
- name: Download binaries
276+
uses: actions/download-artifact@v1
277+
with:
278+
name: minikube_binaries
279+
- name: run integration test
280+
continue-on-error: true
281+
run: |
282+
set +euo pipefail
283+
mkdir -p report
284+
mkdir -p testhome
285+
START_TIME=$(date -u +%s)
286+
KUBECONFIG=$(pwd)/testhome/kubeconfig MINIKUBE_HOME=$(pwd)/testhome minikube_binaries/e2e-windows-amd64.exe -minikube-start-args=--vm-driver=docker -binary=minikube_binaries/minikube-windows-amd64.exe -test.v -test.timeout=65m 2>&1 | tee ./report/testout.txt
287+
END_TIME=$(date -u +%s)
288+
TIME_ELAPSED=$(($END_TIME-$START_TIME))
289+
min=$((${TIME_ELAPSED}/60))
290+
sec=$((${TIME_ELAPSED}%60))
291+
TIME_ELAPSED="${min} min $sec seconds"
292+
echo ::set-env name=TIME_ELAPSED::${TIME_ELAPSED}
293+
shell: bash
294+
- name: Generate html report
295+
run: |
296+
go tool test2json -t < ./report/testout.txt > ./report/testout.json || true
297+
STAT=$(${GITHUB_WORKSPACE}/gopogh.exe -in ./report/testout.json -out ./report/testout.html -name " $GITHUB_REF" -repo "${JOB_NAME} ${GITHUB_REF} ${GITHUB_REPOSITORY}" -details "${GITHUB_SHA}") || true
298+
echo status: ${STAT}
299+
FailNum=$(echo $STAT | jq '.NumberOfFail')
300+
TestsNum=$(echo $STAT | jq '.NumberOfTests')
301+
GOPOGH_RESULT="${JOB_NAME} : completed with ${FailNum} / ${TestsNum} failures in ${TIME_ELAPSED}"
302+
echo ::set-env name=GOPOGH_RESULT::${GOPOGH_RESULT}
303+
echo ::set-env name=STAT::${STAT}
304+
shell: bash
305+
- uses: actions/upload-artifact@v1
306+
with:
307+
name: docker_on_windows
308+
path: report
309+
- name: The End Result
310+
run: |
311+
echo ${GOPOGH_RESULT}
312+
numFail=$(echo $STAT | jq '.NumberOfFail')
313+
echo "----------------${numFail} Failures----------------------------"
314+
echo $STAT | jq '.FailedTests' || true
315+
echo "--------------------------------------------"
316+
numPass=$(echo $STAT | jq '.NumberOfPass')
317+
echo "*** $numPass Passed ***"
318+
if [ "$numFail" -gt 0 ];then echo "*** $numFail Failed ***";exit 2;fi
319+
shell: bash
254320
none_ubuntu16_04:
255321
needs: [build_minikube]
256322
env:
@@ -521,6 +587,15 @@ jobs:
521587
run: |
522588
mkdir -p all_reports
523589
cp -r docker_ubuntu_18_04 ./all_reports/
590+
- name: download results docker_on_windows
591+
uses: actions/download-artifact@v1
592+
with:
593+
name: docker_on_windows
594+
- name: cp to all_report
595+
shell: bash
596+
run: |
597+
mkdir -p all_reports
598+
cp -r docker_on_windows ./all_reports/
524599
- name: Download Results none_ubuntu16_04
525600
uses: actions/download-artifact@v1
526601
with:

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ minikube is a Kubernetes [#sig-cluster-lifecycle](https://github.com/kubernetes/
6262
* [minikube-dev mailing list](https://groups.google.com/forum/#!forum/minikube-dev)
6363
* [Bi-weekly office hours, Mondays @ 11am PST](https://tinyurl.com/minikube-oh)
6464

65-
* [Contributing](https://minikube.sigs.k8s.io/docs/contributing/)
66-
* [Development Roadmap](https://minikube.sigs.k8s.io/docs/contributing/roadmap/)
65+
* [Contributing](https://minikube.sigs.k8s.io/docs/contrib/)
66+
* [Development Roadmap](https://minikube.sigs.k8s.io/docs/contrib/roadmap/)
6767

Diff for: cmd/minikube/cmd/docker-env.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import (
2424
"io"
2525
"net"
2626
"os"
27-
"os/exec"
2827
"strconv"
2928
"strings"
3029

@@ -38,6 +37,7 @@ import (
3837
"k8s.io/minikube/pkg/minikube/mustload"
3938
"k8s.io/minikube/pkg/minikube/out"
4039
"k8s.io/minikube/pkg/minikube/shell"
40+
"k8s.io/minikube/pkg/minikube/sysinit"
4141
)
4242

4343
var dockerEnvTmpl = fmt.Sprintf("{{ .Prefix }}%s{{ .Delimiter }}{{ .DockerTLSVerify }}{{ .Suffix }}{{ .Prefix }}%s{{ .Delimiter }}{{ .DockerHost }}{{ .Suffix }}{{ .Prefix }}%s{{ .Delimiter }}{{ .DockerCertPath }}{{ .Suffix }}{{ .Prefix }}%s{{ .Delimiter }}{{ .MinikubeDockerdProfile }}{{ .Suffix }}{{ if .NoProxyVar }}{{ .Prefix }}{{ .NoProxyVar }}{{ .Delimiter }}{{ .NoProxyValue }}{{ .Suffix }}{{end}}{{ .UsageHint }}", constants.DockerTLSVerifyEnv, constants.DockerHostEnv, constants.DockerCertPathEnv, constants.MinikubeActiveDockerdEnv)
@@ -116,9 +116,7 @@ func (EnvNoProxyGetter) GetNoProxyVar() (string, string) {
116116

117117
// isDockerActive checks if Docker is active
118118
func isDockerActive(r command.Runner) bool {
119-
c := exec.Command("sudo", "systemctl", "is-active", "--quiet", "service", "docker")
120-
_, err := r.RunCmd(c)
121-
return err == nil
119+
return sysinit.New(r).Active("docker")
122120
}
123121

124122
// dockerEnvCmd represents the docker-env command

Diff for: cmd/minikube/cmd/start.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ func validateUser(drvName string) {
668668
useForce := viper.GetBool(force)
669669

670670
if driver.NeedsRoot(drvName) && u.Uid != "0" && !useForce {
671-
exit.WithCodeT(exit.Permissions, `The "{{.driver_name}}" driver requires root privileges. Please run minikube using 'sudo minikube --driver={{.driver_name}}'.`, out.V{"driver_name": drvName})
671+
exit.WithCodeT(exit.Permissions, `The "{{.driver_name}}" driver requires root privileges. Please run minikube using 'sudo minikube start --driver={{.driver_name}}'.`, out.V{"driver_name": drvName})
672672
}
673673

674674
if driver.NeedsRoot(drvName) || u.Uid != "0" {

Diff for: cmd/minikube/cmd/status.go

+3-9
Original file line numberDiff line numberDiff line change
@@ -208,15 +208,9 @@ func status(api libmachine.API, cc config.ClusterConfig, n config.Node) (*Status
208208
return st, err
209209
}
210210

211-
stk, err := kverify.KubeletStatus(cr)
212-
glog.Infof("%s kubelet status = %s (err=%v)", name, stk, err)
213-
214-
if err != nil {
215-
glog.Warningf("kubelet err: %v", err)
216-
st.Kubelet = state.Error.String()
217-
} else {
218-
st.Kubelet = stk.String()
219-
}
211+
stk := kverify.KubeletStatus(cr)
212+
glog.Infof("%s kubelet status = %s", name, stk)
213+
st.Kubelet = stk.String()
220214

221215
// Early exit for regular nodes
222216
if !controlPlane {

Diff for: hack/preload-images/generate.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131
"k8s.io/minikube/pkg/minikube/config"
3232
"k8s.io/minikube/pkg/minikube/driver"
3333
"k8s.io/minikube/pkg/minikube/localpath"
34+
"k8s.io/minikube/pkg/minikube/sysinit"
3435
)
3536

3637
func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string) error {
@@ -86,7 +87,9 @@ func generateTarball(kubernetesVersion, containerRuntime, tarballFilename string
8687
KubernetesVersion: kubernetesVersion,
8788
}
8889
runner := command.NewKICRunner(profile, driver.OCIBinary)
89-
if err := bsutil.TransferBinaries(kcfg, runner); err != nil {
90+
sm := sysinit.New(runner)
91+
92+
if err := bsutil.TransferBinaries(kcfg, runner, sm); err != nil {
9093
return errors.Wrap(err, "transferring k8s binaries")
9194
}
9295
// Create image tarball

Diff for: pkg/drivers/hyperkit/iso_test.go

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
Copyright 2020 The Kubernetes Authors All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package hyperkit
18+
19+
import (
20+
"io/ioutil"
21+
"os"
22+
"testing"
23+
)
24+
25+
func TestExtractFile(t *testing.T) {
26+
testDir, err := ioutil.TempDir(os.TempDir(), "")
27+
if nil != err {
28+
return
29+
}
30+
defer os.Remove(testDir)
31+
32+
tests := []struct {
33+
name string
34+
isoPath string
35+
srcPath string
36+
destPath string
37+
expectedError bool
38+
}{
39+
{
40+
name: "all is right",
41+
isoPath: "iso_test.iso",
42+
srcPath: "/test1.txt",
43+
destPath: testDir + "/test1.txt",
44+
expectedError: false,
45+
},
46+
{
47+
name: "isoPath is error",
48+
isoPath: "tests.iso",
49+
srcPath: "/test1.txt",
50+
destPath: testDir + "/test1.txt",
51+
expectedError: true,
52+
},
53+
{
54+
name: "srcPath is empty",
55+
isoPath: "iso_tests.iso",
56+
srcPath: "",
57+
destPath: testDir + "/test1.txt",
58+
expectedError: true,
59+
},
60+
{
61+
name: "srcPath is error",
62+
isoPath: "iso_tests.iso",
63+
srcPath: "/t1.txt",
64+
destPath: testDir + "/test1.txt",
65+
expectedError: true,
66+
},
67+
{
68+
name: "destPath is empty",
69+
isoPath: "iso_test.iso",
70+
srcPath: "/test1.txt",
71+
destPath: "",
72+
expectedError: true,
73+
},
74+
{
75+
name: "find files in a folder",
76+
isoPath: "./iso_test.iso",
77+
srcPath: "/test2/test2.txt",
78+
destPath: testDir + "/test2.txt",
79+
expectedError: false,
80+
},
81+
}
82+
for _, tt := range tests {
83+
t.Run(tt.name, func(t *testing.T) {
84+
err := ExtractFile(tt.isoPath, tt.srcPath, tt.destPath)
85+
if (nil != err) != tt.expectedError {
86+
t.Errorf("expectedError = %v, get = %v", tt.expectedError, err)
87+
return
88+
}
89+
})
90+
}
91+
}

Diff for: pkg/drivers/hyperkit/iso_test.iso

354 KB
Binary file not shown.

Diff for: pkg/drivers/kic/kic.go

+28-17
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"os/exec"
2323
"strconv"
2424
"strings"
25+
"sync"
2526
"time"
2627

2728
"github.com/docker/machine/libmachine/drivers"
@@ -37,7 +38,7 @@ import (
3738
"k8s.io/minikube/pkg/minikube/constants"
3839
"k8s.io/minikube/pkg/minikube/cruntime"
3940
"k8s.io/minikube/pkg/minikube/download"
40-
"k8s.io/minikube/pkg/minikube/kubelet"
41+
"k8s.io/minikube/pkg/minikube/sysinit"
4142
)
4243

4344
// Driver represents a kic driver https://minikube.sigs.k8s.io/docs/reference/drivers/docker
@@ -112,6 +113,28 @@ func (d *Driver) Create() error {
112113
}
113114
}
114115

116+
if err := oci.PrepareContainerNode(params); err != nil {
117+
return errors.Wrap(err, "setting up container node")
118+
}
119+
120+
var waitForPreload sync.WaitGroup
121+
waitForPreload.Add(1)
122+
go func() {
123+
defer waitForPreload.Done()
124+
// If preload doesn't exist, don't bother extracting tarball to volume
125+
if !download.PreloadExists(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime) {
126+
return
127+
}
128+
t := time.Now()
129+
glog.Infof("Starting extracting preloaded images to volume")
130+
// Extract preloaded images to container
131+
if err := oci.ExtractTarballToVolume(download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, BaseImage); err != nil {
132+
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
133+
} else {
134+
glog.Infof("duration metric: took %f seconds to extract preloaded images to volume", time.Since(t).Seconds())
135+
}
136+
}()
137+
115138
if err := oci.CreateContainerNode(params); err != nil {
116139
return errors.Wrap(err, "create kic node")
117140
}
@@ -120,19 +143,7 @@ func (d *Driver) Create() error {
120143
return errors.Wrap(err, "prepare kic ssh")
121144
}
122145

123-
// If preload doesn't exist, don't bother extracting tarball to volume
124-
if !download.PreloadExists(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime) {
125-
return nil
126-
}
127-
t := time.Now()
128-
glog.Infof("Starting extracting preloaded images to volume")
129-
// Extract preloaded images to container
130-
if err := oci.ExtractTarballToVolume(download.TarballPath(d.NodeConfig.KubernetesVersion, d.NodeConfig.ContainerRuntime), params.Name, BaseImage); err != nil {
131-
glog.Infof("Unable to extract preloaded tarball to volume: %v", err)
132-
} else {
133-
glog.Infof("Took %f seconds to extract preloaded images to volume", time.Since(t).Seconds())
134-
}
135-
146+
waitForPreload.Wait()
136147
return nil
137148
}
138149

@@ -245,7 +256,7 @@ func (d *Driver) GetState() (state.State, error) {
245256
func (d *Driver) Kill() error {
246257
// on init this doesn't get filled when called from cmd
247258
d.exec = command.NewKICRunner(d.MachineName, d.OCIBinary)
248-
if err := kubelet.ForceStop(d.exec); err != nil {
259+
if err := sysinit.New(d.exec).ForceStop("kubelet"); err != nil {
249260
glog.Warningf("couldn't force stop kubelet. will continue with kill anyways: %v", err)
250261
}
251262
cmd := exec.Command(d.NodeConfig.OCIBinary, "kill", d.MachineName)
@@ -318,9 +329,9 @@ func (d *Driver) Stop() error {
318329
d.exec = command.NewKICRunner(d.MachineName, d.OCIBinary)
319330
// docker does not send right SIG for systemd to know to stop the systemd.
320331
// to avoid bind address be taken on an upgrade. more info https://github.com/kubernetes/minikube/issues/7171
321-
if err := kubelet.Stop(d.exec); err != nil {
332+
if err := sysinit.New(d.exec).Stop("kubelet"); err != nil {
322333
glog.Warningf("couldn't stop kubelet. will continue with stop anyways: %v", err)
323-
if err := kubelet.ForceStop(d.exec); err != nil {
334+
if err := sysinit.New(d.exec).ForceStop("kubelet"); err != nil {
324335
glog.Warningf("couldn't force stop kubelet. will continue with stop anyways: %v", err)
325336
}
326337
}

Diff for: pkg/drivers/kic/oci/oci.go

+13-4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,19 @@ func DeleteContainer(ociBin string, name string) error {
8484
return nil
8585
}
8686

87+
// PrepareContainerNode sets up the container node befpre CreateContainerNode is caleld
88+
// for the docker runtime, it creates a docker volume which will be mounted into kic
89+
func PrepareContainerNode(p CreateParams) error {
90+
if p.OCIBinary != Docker {
91+
return nil
92+
}
93+
if err := createDockerVolume(p.Name, p.Name); err != nil {
94+
return errors.Wrapf(err, "creating volume for %s container", p.Name)
95+
}
96+
glog.Infof("Successfully created a docker volume %s", p.Name)
97+
return nil
98+
}
99+
87100
// CreateContainerNode creates a new container node
88101
func CreateContainerNode(p CreateParams) error {
89102
runArgs := []string{
@@ -122,10 +135,6 @@ func CreateContainerNode(p CreateParams) error {
122135
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var:exec", hostVarVolPath))
123136
}
124137
if p.OCIBinary == Docker {
125-
if err := createDockerVolume(p.Name, p.Name); err != nil {
126-
return errors.Wrapf(err, "creating volume for %s container", p.Name)
127-
}
128-
glog.Infof("Successfully created a docker volume %s", p.Name)
129138
runArgs = append(runArgs, "--volume", fmt.Sprintf("%s:/var", p.Name))
130139
// setting resource limit in privileged mode is only supported by docker
131140
// podman error: "Error: invalid configuration, cannot set resources with rootless containers not using cgroups v2 unified mode"

0 commit comments

Comments
 (0)