未验证 提交 77931fb4 编写于 作者: S Sharif Elgamal

Merge branch 'master' of github.com:kubernetes/minikube into extract-advice

Balint Pato <balintp@google.com> (@balopat)
Thomas Stromberg <tstromberg@google.com> (@tstromberg)
Anders F Björklund <anders.f.bjorklund@gmail.com> (@afbjorklund)
Sharif Elgamal <selgamal@google.com> (@sharifelgamal)
......
# See the OWNERS docs at https://go.k8s.io/owners
reviewers:
- balopat
- tstromberg
- afbjorklund
- sharifelgamal
- RA489
- medyagh
approvers:
- balopat
- tstromberg
- afbjorklund
- sharifelgamal
......@@ -18,3 +16,4 @@ emeritus_approvers:
- dlorenc
- luxas
- jimmidyson
- r2d4
......@@ -101,6 +101,7 @@ Other drivers which are not yet part of our continuous integration system are:
* [hyperv](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#hyperV-driver)
* [vmware](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#vmware-unified-driver)
* [parallels](https://github.com/kubernetes/minikube/blob/master/docs/drivers.md#parallels-driver)
## Quick Start
......
......@@ -10,5 +10,7 @@
# DO NOT REPORT SECURITY VULNERABILITIES DIRECTLY TO THESE NAMES, FOLLOW THE
# INSTRUCTIONS AT https://kubernetes.io/security/
dlorenc
gbraad
tstromberg
afbjorklund
medyagh
sharifelgamal
......@@ -57,7 +57,7 @@ var addonsOpenCmd = &cobra.Command{
exit.Usage("usage: minikube addons open ADDON_NAME")
}
addonName := args[0]
//TODO(r2d4): config should not reference API, pull this out
// TODO(r2d4): config should not reference API, pull this out
api, err := machine.NewAPIClient()
if err != nil {
exit.WithError("Error getting client", err)
......
......@@ -110,7 +110,7 @@ func EnableOrDisableAddon(name string, val string) error {
return errors.Wrapf(err, "parsing bool: %s", name)
}
//TODO(r2d4): config package should not reference API, pull this out
// TODO(r2d4): config package should not reference API, pull this out
api, err := machine.NewAPIClient()
if err != nil {
return errors.Wrap(err, "machine client")
......
......@@ -421,7 +421,7 @@ func validateConfig() {
}
// This function validates if the --registry-mirror
//args match the format of http://localhost
// args match the format of http://localhost
func validateRegistryMirror() {
if len(registryMirror) > 0 {
......@@ -751,7 +751,11 @@ func configureRuntimes(runner cruntime.CommandRunner) cruntime.Manager {
exit.WithError(fmt.Sprintf("Failed runtime for %+v", config), err)
}
err = cr.Enable()
disableOthers := true
if viper.GetString(vmDriver) == constants.DriverNone {
disableOthers = false
}
err = cr.Enable(disableOthers)
if err != nil {
exit.WithError("Failed to enable container runtime", err)
}
......
......@@ -81,6 +81,7 @@ func runStop(cmd *cobra.Command, args []string) {
exit.WithError("update config", err)
}
}
func init() {
RootCmd.AddCommand(stopCmd)
}
......@@ -59,10 +59,10 @@ var tunnelCmd = &cobra.Command{
}
glog.Infof("Creating k8s client...")
//Tunnel uses the k8s clientset to query the API server for services in the LoadBalancerEmulator.
//We define the tunnel and minikube error free if the API server responds within a second.
//This also contributes to better UX, the tunnel status check can happen every second and
//doesn't hang on the API server call during startup and shutdown time or if there is a temporary error.
// Tunnel uses the k8s clientset to query the API server for services in the LoadBalancerEmulator.
// We define the tunnel and minikube error free if the API server responds within a second.
// This also contributes to better UX, the tunnel status check can happen every second and
// doesn't hang on the API server call during startup and shutdown time or if there is a temporary error.
clientset, err := service.K8s.GetClientset(1 * time.Second)
if err != nil {
exit.WithError("error creating clientset", err)
......
# Locally computed
sha256 4f978a59c6ee516f7e3febfb3b0360a17d1be2c283313e1aeb27adcb8c8f9166 dde3ccf93f01ce5a3e0f7a2c97053697cc3ed152.tar.gz
sha256 75fad6e66b43c5039719edbd82ba072723aea6a9d4d8be4e7ac1c245a291ab1b 8455ce1ef385120deb827d0f0588c04357bad4c4.tar.gz
CONMON_MASTER_VERSION = dde3ccf93f01ce5a3e0f7a2c97053697cc3ed152
################################################################################
#
# conmon
#
################################################################################
# HEAD as of 2019-06-13
CONMON_MASTER_VERSION = 8455ce1ef385120deb827d0f0588c04357bad4c4
CONMON_MASTER_SITE = https://github.com/containers/conmon/archive
CONMON_MASTER_SOURCE = $(CONMON_MASTER_VERSION).tar.gz
CONMON_MASTER_LICENSE = Apache-2.0
......
sha256 8565a655345f3db2f7b78b77a2cd3103895229aa44cd0e4c710ba3559e344b5a v1.2.0.tar.gz
sha256 b92819bde71de947329814a3c649b8adb106cc03be16aae217b94297f4b843a1 v1.2.5.tar.gz
sha256 f2d578b743fb9faa5b3477b7cf4b33d00501087043a53b27754f14bbe741f891 v1.2.6.tar.gz
......@@ -3,8 +3,8 @@
# containerd
#
################################################################################
CONTAINERD_BIN_VERSION = v1.2.5
CONTAINERD_BIN_COMMIT = bb71b10fd8f58240ca47fbb579b9d1028eea7c84
CONTAINERD_BIN_VERSION = v1.2.6
CONTAINERD_BIN_COMMIT = 894b81a4b802e4eb2a91d1ce216b8817763c29fb
CONTAINERD_BIN_SITE = https://github.com/containerd/containerd/archive
CONTAINERD_BIN_SOURCE = $(CONTAINERD_BIN_VERSION).tar.gz
CONTAINERD_BIN_DEPENDENCIES = host-go libgpgme
......
sha256 ccf83574556793ceb01717dc91c66b70f183c60c2bbec70283939aae8fdef768 crictl-v1.11.1-linux-amd64.tar.gz
sha256 9bdbea7a2b382494aff2ff014da328a042c5aba9096a7772e57fdf487e5a1d51 crictl-v1.13.0-linux-amd64.tar.gz
sha256 c3b71be1f363e16078b51334967348aab4f72f46ef64a61fe7754e029779d45a crictl-v1.15.0-linux-amd64.tar.gz
......@@ -4,7 +4,7 @@
#
################################################################################
CRICTL_BIN_VERSION = v1.13.0
CRICTL_BIN_VERSION = v1.15.0
CRICTL_BIN_SITE = https://github.com/kubernetes-sigs/cri-tools/releases/download/$(CRICTL_BIN_VERSION)
CRICTL_BIN_SOURCE = crictl-$(CRICTL_BIN_VERSION)-linux-amd64.tar.gz
CRICTL_BIN_STRIP_COMPONENTS = 0
......
......@@ -10,3 +10,4 @@ sha256 a979d9a952fae474886c7588da692ee00684cb2421d2c633c7ed415948cf0b10 docker-
sha256 346f9394393ee8db5f8bd1e229ee9d90e5b36931bdd754308b2ae68884dd6822 docker-18.06.3-ce.tgz
sha256 99ca9395e9c7ffbf75537de71aa828761f492491d02bc6e29db2920fa582c6c5 docker-18.09.5.tgz
sha256 1f3f6774117765279fce64ee7f76abbb5f260264548cf80631d68fb2d795bb09 docker-18.09.6.tgz
sha256 e106ccfa2b1f60794faaa6bae57a2dac9dc4cb33e5541fad6a826ea525d01cc4 docker-18.09.7.tgz
......@@ -4,7 +4,7 @@
#
################################################################################
DOCKER_BIN_VERSION = 18.09.6
DOCKER_BIN_VERSION = 18.09.7
DOCKER_BIN_SITE = https://download.docker.com/linux/static/stable/x86_64
DOCKER_BIN_SOURCE = docker-$(DOCKER_BIN_VERSION).tgz
......
......@@ -6,3 +6,6 @@ sha256 f7a462563dd587208eff3c3c0689bc4d01071a8f7933bec2a13126be123f63a8 v1.0.0.t
sha256 b4d6843e13c0f2f1557ab20b4364bb42ea9102442ee3f1be806c06128aa687d8 v1.2.0.tar.gz
sha256 548a82b62ff183ca9e68f164779d6ded94fce07261242ceb96faa267fcecf56b v1.3.0.tar.gz
sha256 7ccbfa80900cd438468986911038da4c38382ef507a2fa717217faefb738fbc4 v1.3.1.tar.gz
sha256 17fdf68e85106d0848e89825e191198a4079bb6d9ca6dd3e415e5c010192db9e v1.4.0.tar.gz
sha256 45eb7bccd81a1431b0c7a0697829c0bcc397048595d143fd91179b31d22a3c63 v1.4.1.tar.gz
sha256 2e027c1b935f3a03f27ef7f17823ccf334607a17d033d4ce53a90b98294e7f68 v1.4.4.tar.gz
PODMAN_VERSION = v1.3.1
PODMAN_COMMIT = 7210727e205c333af9a2d0ed0bb66adcf92a6369
PODMAN_VERSION = v1.4.4
PODMAN_COMMIT = b3f10c8be229bcc58c1673b0431285fd5fce1293
PODMAN_SITE = https://github.com/containers/libpod/archive
PODMAN_SOURCE = $(PODMAN_VERSION).tar.gz
PODMAN_LICENSE = Apache-2.0
......
......@@ -4,3 +4,4 @@ sha256 9318fa9de6e3b2c89760f08d73bf718c97c93d683611716e024d2f3283c96d90 c1e454b2
sha256 a960decadf6bd5d3cee1ca7b94455d37cc921c964061428bd9f3dd17a13c8bb3 6635b4f0c6af3810594d2770f662f34ddc15b40d.tar.gz
sha256 ad41ae930059fef18de1926cd78e00474c89290248fecdcc0e431c8aefee1deb 0a012df867a2d525f62a146d8ebdf2e6ab8a5ad5.tar.gz
sha256 e52c5d7365b2b9048f977bac8f06bf626dccb4d816d0947ec8523f543272f4ff 2b18fe1d885ee5083ef9f0838fee39b62d653e30.tar.gz
sha256 257ac2c2bbc9770998f31b73f587718848ebb09465ce2cd20fbac198ebd5726e 425e105d5a03fabd737a126ad93d62a9eeede87f.tar.gz
......@@ -4,8 +4,8 @@
#
################################################################################
# HEAD as of 2019-03-07
RUNC_MASTER_VERSION = 2b18fe1d885ee5083ef9f0838fee39b62d653e30
# HEAD as of 2019-04-25
RUNC_MASTER_VERSION = 425e105d5a03fabd737a126ad93d62a9eeede87f
RUNC_MASTER_SITE = https://github.com/opencontainers/runc/archive
RUNC_MASTER_SOURCE = $(RUNC_MASTER_VERSION).tar.gz
RUNC_MASTER_LICENSE = Apache-2.0
......
......@@ -13,6 +13,7 @@ the host PATH:
* [Hyperkit](#hyperkit-driver)
* [HyperV](#hyperv-driver)
* [VMware](#vmware-unified-driver)
* [Parallels](#parallels-driver)
## KVM2 driver
......@@ -214,6 +215,30 @@ and run minikube as usual:
minikube start
```
## Parallels driver
This driver is useful for users who own Parallels Desktop for Mac that do not have VT-x hardware support required by the hyperkit driver.
Pre-requisites: Parallels Desktop for Mac
Install the [Parallels docker-machine driver](https://github.com/Parallels/docker-machine-parallels) using [brew](https://brew.sh):
```shell
brew install docker-machine-parallels
```
To use the driver:
```shell
minikube start --vm-driver parallels
```
or, to use parallels as a default driver for minikube:
```shell
minikube config set vm-driver parallels
```
## Troubleshooting
minikube is currently unable to display the error message received back from the VM driver. Users can however reveal the error by passing `--alsologtostderr -v=8` to `minikube start`. For instance:
......
......@@ -20,15 +20,16 @@
https://k8s-testgrid.appspot.com
"""
from __future__ import print_function
import os, sys, json, re, argparse, calendar, time, subprocess, shlex
def get_classname(test_script):
""" parse out the test classname from the full path of the test script"""
classname = os.path.basename(test).split('.')[0]
classname = os.path.basename(test_script).split('.')[0]
return classname
def write_results(outdir, started, finished, test_results):
""" write current results into artifacts/junit_runner.xml
""" write current results into artifacts/junit_runner.xml
format:
<testsuite failures="XXX" tests="YYY" time="ZZZ">
<testcase classname="SUITENAME" name="TESTNAME" time="ZZZ1" />
......@@ -36,7 +37,7 @@ def write_results(outdir, started, finished, test_results):
...
</testsuite>
write the started.json and finish.json files
write the started.json and finish.json files
format:
started.json: {"timestamp":STARTTIMEINSECONDSINCEEPOCH}
finished.json: {"timestamp":FINISHTIMEINSECONDSINCEEPOCH,
......@@ -67,9 +68,9 @@ def write_results(outdir, started, finished, test_results):
junit_xml.write('</testsuite>')
junit_xml.close()
started_json.write(json.dumps(started))
started_json.write(json.dumps(started))
started_json.close()
finished_json.write(json.dumps(finished))
finished_json.write(json.dumps(finished))
finished_json.close()
return
......@@ -86,12 +87,12 @@ def upload_results(outdir, test_script, buildnum, bucket):
classname = get_classname(test_script)
args = shlex.split("gsutil cp -R gcs_out/ gs://%s/logs/%s/%s" % (bucket, classname, buildnum))
p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout:
print line
for line in str(p.stdout):
print(line)
def run_tests(test_script, log_path, exit_status, started, finished, test_results):
""" execute the test script, grab the start time, finish time, build logs and exit status
Pull test results and important information out of the build log
Pull test results and important information out of the build log
test results format should be:
=== RUN TestFunctional/Mounting
--- PASS: TestFunctional (42.87s)
......@@ -109,9 +110,9 @@ def run_tests(test_script, log_path, exit_status, started, finished, test_result
classname = get_classname(test_script)
build_log_file = open(log_path, 'w')
p = subprocess.Popen(['bash','-x',test_script], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout:
for line in str(p.stdout):
build_log_file.write(line)
print line.rstrip()
print(line.rstrip())
if '--- PASS' in line:
match = re.match('.*--- PASS: ([^ ]+) \(([0-9.]+)s\)', line)
(name, seconds) = match.group(1, 2)
......
......@@ -194,15 +194,15 @@ func (d *Driver) deleteNetwork() error {
func (d *Driver) checkDomains(conn *libvirt.Connect) error {
type source struct {
//XMLName xml.Name `xml:"source"`
// XMLName xml.Name `xml:"source"`
Network string `xml:"network,attr"`
}
type iface struct {
//XMLName xml.Name `xml:"interface"`
// XMLName xml.Name `xml:"interface"`
Source source `xml:"source"`
}
type result struct {
//XMLName xml.Name `xml:"domain"`
// XMLName xml.Name `xml:"domain"`
Name string `xml:"name"`
Interfaces []iface `xml:"devices>interface"`
}
......
......@@ -231,7 +231,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {
}
if version.LT(semver.MustParse("1.10.0-alpha.0")) {
//TODO(r2d4): get rid of global here
// TODO(r2d4): get rid of global here
master = k8s.NodeName
if err := util.RetryAfter(200, unmarkMaster, time.Second*1); err != nil {
return errors.Wrap(err, "timed out waiting to unmark master")
......
......@@ -171,7 +171,8 @@ Documentation=http://kubernetes.io/docs/
ExecStart=/usr/bin/kubelet
Restart=always
StartLimitInterval=0
RestartSec=10
# Tuned for local dev: faster than upstream default (10s), but slower than systemd default (100ms)
RestartSec=600ms
[Install]
WantedBy=multi-user.target
......
......@@ -58,9 +58,9 @@ var (
maxClockDesyncSeconds = 2.1
)
//This init function is used to set the logtostderr variable to false so that INFO level log info does not clutter the CLI
//INFO lvl logging is displayed due to the kubernetes api calling flag.Set("logtostderr", "true") in its init()
//see: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/util/logs/logs.go#L32-L34
// This init function is used to set the logtostderr variable to false so that INFO level log info does not clutter the CLI
// INFO lvl logging is displayed due to the kubernetes api calling flag.Set("logtostderr", "true") in its init()
// see: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/util/logs/logs.go#L32-L34
func init() {
if err := flag.Set("logtostderr", "false"); err != nil {
exit.WithError("unable to set logtostderr", err)
......
......@@ -66,6 +66,7 @@ func OutStyle(style StyleEnum, format string, a ...interface{}) {
Out(outStyled, a...)
}
// OutT writes a stylized and templated message to stdout
func OutT(style StyleEnum, format string, a map[string]interface{}) {
outStyled := applyTemplateFormatting(style, useColor, format, a)
Out(outStyled)
......@@ -94,6 +95,7 @@ func ErrStyle(style StyleEnum, format string, a ...interface{}) {
Err(errStyled, a...)
}
// ErrT writes a stylized and templated error message to stderr
func ErrT(style StyleEnum, format string, a map[string]interface{}) {
errStyled := applyTemplateFormatting(style, useColor, format, a)
Err(errStyled)
......
......@@ -153,7 +153,7 @@ const (
SHASuffix = ".sha256"
// DefaultMemorySize is the default memory which will be allocated to minikube, in megabytes
DefaultMemorySize = "2000mb"
//MinimumMemorySize is the minimum memory size, in megabytes
// MinimumMemorySize is the minimum memory size, in megabytes
MinimumMemorySize = "1024mb"
// DefaultCPUS is the default number of cpus of a host
DefaultCPUS = 2
......@@ -421,7 +421,7 @@ const (
// StoredContainerdConfigTomlPath is the path where the default config.toml will be stored
StoredContainerdConfigTomlPath = "/tmp/config.toml"
//GvisorConfigTomlTargetName is the go-bindata target name for the gvisor config.toml
// GvisorConfigTomlTargetName is the go-bindata target name for the gvisor config.toml
GvisorConfigTomlTargetName = "gvisor-config.toml"
// GvisorContainerdShimTargetName is the go-bindata target name for gvisor-containerd-shim
GvisorContainerdShimTargetName = "gvisor-containerd-shim.toml"
......
......@@ -80,9 +80,11 @@ func (r *Containerd) Available() error {
}
// Enable idempotently enables containerd on a host
func (r *Containerd) Enable() error {
if err := disableOthers(r, r.Runner); err != nil {
glog.Warningf("disableOthers: %v", err)
func (r *Containerd) Enable(disOthers bool) error {
if disOthers {
if err := disableOthers(r, r.Runner); err != nil {
glog.Warningf("disableOthers: %v", err)
}
}
if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil {
return err
......
......@@ -78,9 +78,11 @@ func (r *CRIO) Active() bool {
}
// Enable idempotently enables CRIO on a host
func (r *CRIO) Enable() error {
if err := disableOthers(r, r.Runner); err != nil {
glog.Warningf("disableOthers: %v", err)
func (r *CRIO) Enable(disOthers bool) error {
if disOthers {
if err := disableOthers(r, r.Runner); err != nil {
glog.Warningf("disableOthers: %v", err)
}
}
if err := populateCRIConfig(r.Runner, r.SocketPath()); err != nil {
return err
......
......@@ -38,7 +38,7 @@ type Manager interface {
// Version retrieves the current version of this runtime
Version() (string, error)
// Enable idempotently enables this runtime on a host
Enable() error
Enable(bool) error
// Disable idempotently disables this runtime on a host
Disable() error
// Active returns whether or not a runtime is active on a host
......
......@@ -406,7 +406,7 @@ func TestEnable(t *testing.T) {
if err != nil {
t.Fatalf("New(%s): %v", tc.runtime, err)
}
err = cr.Enable()
err = cr.Enable(true)
if err != nil {
t.Errorf("%s disable unexpected error: %v", tc.runtime, err)
}
......
......@@ -78,9 +78,11 @@ func (r *Docker) Active() bool {
}
// Enable idempotently enables Docker on a host
func (r *Docker) Enable() error {
if err := disableOthers(r, r.Runner); err != nil {
glog.Warningf("disableOthers: %v", err)
func (r *Docker) Enable(disOthers bool) error {
if disOthers {
if err := disableOthers(r, r.Runner); err != nil {
glog.Warningf("disableOthers: %v", err)
}
}
return r.Runner.Run("sudo systemctl start docker")
}
......
......@@ -46,7 +46,7 @@ func createHypervHost(config cfg.MachineConfig) interface{} {
d.CPU = config.CPUs
d.DiskSize = int(config.DiskSize)
d.SSHUser = "docker"
d.DisableDynamicMemory = true //default to disable dynamic memory as minikube is unlikely to work properly with dynamic memory
d.DisableDynamicMemory = true // default to disable dynamic memory as minikube is unlikely to work properly with dynamic memory
return d
}
......@@ -19,6 +19,8 @@ package extract
import (
"encoding/json"
"io/ioutil"
"os"
"path/filepath"
"reflect"
"testing"
)
......@@ -30,8 +32,22 @@ func TestExtract(t *testing.T) {
// The function we care about
functions := []string{"extract.PrintToScreen"}
// The directory where the sample translation file is in
output := "testdata/"
tempdir, err := ioutil.TempDir("", "temptestdata")
if err != nil {
t.Fatalf("Creating temp dir: %v", err)
}
defer os.RemoveAll(tempdir)
src, err := ioutil.ReadFile("testdata/test.json")
if err != nil {
t.Fatalf("Reading json file: %v", err)
}
tempfile := filepath.Join(tempdir, "tmpdata.json")
err = ioutil.WriteFile(tempfile, src, 0666)
if err != nil {
t.Fatalf("Writing temp json file: %v", err)
}
expected := map[string]interface{}{
"Hint: This is not a URL, come on.": "",
......@@ -41,18 +57,18 @@ func TestExtract(t *testing.T) {
"Wow another string: %s": "",
}
err := TranslatableStrings(paths, functions, output)
err = TranslatableStrings(paths, functions, tempdir)
if err != nil {
t.Fatalf("Error translating strings: %v", err)
}
var got map[string]interface{}
f, err := ioutil.ReadFile("testdata/test.json")
f, err := ioutil.ReadFile(tempfile)
if err != nil {
t.Fatalf("Reading json file: %s", err)
t.Fatalf("Reading resulting json file: %v", err)
}
var got map[string]interface{}
err = json.Unmarshal(f, &got)
if err != nil {
t.Fatalf("Error unmarshalling json: %v", err)
......
......@@ -27,17 +27,17 @@ import (
"k8s.io/client-go/rest"
)
//requestSender is an interface exposed for testing what requests are sent through the k8s REST client
// requestSender is an interface exposed for testing what requests are sent through the k8s REST client
type requestSender interface {
send(request *rest.Request) ([]byte, error)
}
//patchConverter is an interface exposed for testing what patches are sent through the k8s REST client
// patchConverter is an interface exposed for testing what patches are sent through the k8s REST client
type patchConverter interface {
convert(restClient rest.Interface, patch *Patch) *rest.Request
}
//loadBalancerEmulator is the main struct for emulating the loadbalancer behavior. it sets the ingress to the cluster IP
// loadBalancerEmulator is the main struct for emulating the loadbalancer behavior. it sets the ingress to the cluster IP
type loadBalancerEmulator struct {
coreV1Client typed_core.CoreV1Interface
requestSender requestSender
......
......@@ -35,13 +35,13 @@ func osGetPid() int {
return os.Getpid()
}
//TODO(balintp): this is vulnerable to pid reuse we should include process name in the check
// TODO(balintp): this is vulnerable to pid reuse we should include process name in the check
func osCheckIfRunning(pid int) (bool, error) {
p, err := os.FindProcess(pid)
if runtime.GOOS == "windows" {
return err == nil, nil
}
//on unix systems further checking is required, as findProcess is noop
// on unix systems further checking is required, as findProcess is noop
if err != nil {
return false, fmt.Errorf("error finding process %d: %s", pid, err)
}
......
......@@ -31,9 +31,9 @@ import (
// ID represents a registry ID
type ID struct {
//Route is the key
// Route is the key
Route *Route
//the rest is metadata
// the rest is metadata
MachineName string
Pid int
}
......
......@@ -25,7 +25,7 @@ import (
"github.com/golang/glog"
)
//reporter that reports the status of a tunnel
// reporter that reports the status of a tunnel
type reporter interface {
Report(tunnelState *Status)
}
......
......@@ -100,7 +100,7 @@ Got: "%s"`, tc.name, tc.expectedOutput, out.output)
})
}
//testing deduplication
// testing deduplication
out := &recordingWriter{}
reporter := newReporter(out)
reporter.Report(testCases[0].tunnelState)
......
......@@ -23,19 +23,19 @@ import (
"github.com/golang/glog"
)
//router manages the routing table on the host, implementations should cater for OS specific methods
// router manages the routing table on the host, implementations should cater for OS specific methods
type router interface {
//Inspect checks if the given route exists or not in the routing table
//conflict is defined as: same destination CIDR, different Gateway
//overlaps are defined as: routes that have overlapping but not exactly matching destination CIDR
// Inspect checks if the given route exists or not in the routing table
// conflict is defined as: same destination CIDR, different Gateway
// overlaps are defined as: routes that have overlapping but not exactly matching destination CIDR
Inspect(route *Route) (exists bool, conflict string, overlaps []string, err error)
//EnsureRouteIsAdded is an idempotent way to add a route to the routing table
//it fails if there is a conflict
// EnsureRouteIsAdded is an idempotent way to add a route to the routing table
// it fails if there is a conflict
EnsureRouteIsAdded(route *Route) error
//Cleanup is an idempotent way to remove a route from the routing table
//it fails if there is a conflict
// Cleanup is an idempotent way to remove a route from the routing table
// it fails if there is a conflict
Cleanup(route *Route) error
}
......@@ -67,8 +67,8 @@ func isValidToAddOrDelete(router router, r *Route) (bool, error) {
return false, nil
}
//a partial representation of the routing table on the host
//tunnel only requires the destination CIDR, the gateway and the actual textual representation per line
// a partial representation of the routing table on the host
// tunnel only requires the destination CIDR, the gateway and the actual textual representation per line
type routingTable []routingTableLine
func (t *routingTable) Check(route *Route) (exists bool, conflict string, overlaps []string) {
......
......@@ -77,12 +77,12 @@ func (router *osRouter) parseTable(table []byte) routingTable {
t := routingTable{}
skip := true
for _, line := range strings.Split(string(table), "\n") {
//header
// header
if strings.HasPrefix(line, "Destination") {
skip = false
continue
}
//don't care about the 0.0.0.0 routes
// don't care about the 0.0.0.0 routes
if skip || strings.HasPrefix(line, "default") {
continue
}
......
......@@ -74,7 +74,7 @@ func (router *osRouter) parseTable(table []byte) routingTable {
fields := strings.Fields(line)
//don't care about the routes that 0.0.0.0
// don't care about the routes that 0.0.0.0
if len(fields) == 0 ||
len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
continue
......@@ -82,12 +82,12 @@ func (router *osRouter) parseTable(table []byte) routingTable {
if len(fields) > 2 {
//assuming "10.96.0.0/12 via 192.168.39.47 dev virbr1"
// assuming "10.96.0.0/12 via 192.168.39.47 dev virbr1"
dstCIDRString := fields[0]
gatewayIPString := fields[2]
gatewayIP := net.ParseIP(gatewayIPString)
//if not via format, then gateway is assumed to be 0.0.0.0
// if not via format, then gateway is assumed to be 0.0.0.0
// "1.2.3.0/24 dev eno1 proto kernel scope link src 1.2.3.54 metric 100"
if fields[1] != "via" {
gatewayIP = net.ParseIP("0.0.0.0")
......
......@@ -64,14 +64,14 @@ func (router *osRouter) parseTable(table []byte) routingTable {
t := routingTable{}
skip := true
for _, line := range strings.Split(string(table), "\n") {
//after first line of header we can start consuming
// after first line of header we can start consuming
if strings.HasPrefix(line, "Network Destination") {
skip = false
continue
}
fields := strings.Fields(line)
//don't care about the 0.0.0.0 routes
// don't care about the 0.0.0.0 routes
if skip || len(fields) == 0 || len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
continue
}
......
......@@ -32,8 +32,8 @@ func (r *recordingReporter) Report(tunnelState *Status) {
r.statesRecorded = append(r.statesRecorded, tunnelState)
}
//simulating idempotent router behavior
//without checking for conflicting routes
// simulating idempotent router behavior
// without checking for conflicting routes
type fakeRouter struct {
rt routingTable
errorResponse error
......
......@@ -32,9 +32,9 @@ import (
"k8s.io/minikube/pkg/minikube/constants"
)
//tunnel represents the basic API for a tunnel: periodically the state of the tunnel
//can be updated and when the tunnel is not needed, it can be cleaned up
//It was mostly introduced for testability.
// tunnel represents the basic API for a tunnel: periodically the state of the tunnel
// can be updated and when the tunnel is not needed, it can be cleaned up
// It was mostly introduced for testability.
type controller interface {
cleanup() *Status
update() *Status
......@@ -85,7 +85,7 @@ func newTunnel(machineName string, machineAPI libmachine.API, configLoader confi
}
type tunnel struct {
//collaborators
// collaborators
clusterInspector *clusterInspector
router router
loadBalancerEmulator loadBalancerEmulator
......@@ -142,8 +142,8 @@ func setupRoute(t *tunnel, h *host.Host) {
if t.status.RouteError != nil {
return
}
//the route was added successfully, we need to make sure the registry has it too
//this might fail in race conditions, when another process created this tunnel
// the route was added successfully, we need to make sure the registry has it too
// this might fail in race conditions, when another process created this tunnel
if err := t.registry.Register(&t.status.TunnelID); err != nil {
glog.Errorf("failed to register tunnel: %s", err)
t.status.RouteError = err
......@@ -151,7 +151,7 @@ func setupRoute(t *tunnel, h *host.Host) {
}
if h.DriverName == constants.DriverHyperkit {
//the virtio-net interface acts up with ip tunnels :(
// the virtio-net interface acts up with ip tunnels :(
setupBridge(t)
if t.status.RouteError != nil {
return
......@@ -166,7 +166,7 @@ func setupRoute(t *tunnel, h *host.Host) {
return
}
//the route exists, make sure that this process owns it in the registry
// the route exists, make sure that this process owns it in the registry
existingTunnel, err := t.registry.IsAlreadyDefinedAndRunning(&t.status.TunnelID)
if err != nil {
glog.Errorf("failed to check for other tunnels: %s", err)
......@@ -175,7 +175,7 @@ func setupRoute(t *tunnel, h *host.Host) {
}
if existingTunnel == nil {
//the route exists, but "orphaned", this process will "own it" in the registry
// the route exists, but "orphaned", this process will "own it" in the registry
if err := t.registry.Register(&t.status.TunnelID); err != nil {
glog.Errorf("failed to register tunnel: %s", err)
t.status.RouteError = err
......@@ -184,7 +184,7 @@ func setupRoute(t *tunnel, h *host.Host) {
}
if existingTunnel.Pid != getPid() {
//another running process owns the tunnel
// another running process owns the tunnel
t.status.RouteError = errorTunnelAlreadyExists(existingTunnel)
return
}
......
......@@ -38,7 +38,7 @@ type Manager struct {
router router
}
//stateCheckInterval defines how frequently the cluster and route states are checked
// stateCheckInterval defines how frequently the cluster and route states are checked
const stateCheckInterval = 5 * time.Second
// NewManager creates a new Manager
......@@ -68,7 +68,7 @@ func (mgr *Manager) startTunnel(ctx context.Context, tunnel controller) (done ch
check := make(chan bool, 1)
done = make(chan bool, 1)
//simulating Ctrl+C so that we can cancel the tunnel programmatically too
// simulating Ctrl+C so that we can cancel the tunnel programmatically too
go mgr.timerLoop(ready, check)
go mgr.run(ctx, tunnel, ready, check, done)
......
......@@ -29,7 +29,7 @@ import (
func TestTunnelManagerEventHandling(t *testing.T) {
tcs := []struct {
//tunnel inputs
// tunnel inputs
name string
repeat int
test func(tunnel *tunnelStub, cancel context.CancelFunc, ready, check, done chan bool) error
......@@ -120,7 +120,7 @@ func TestTunnelManagerEventHandling(t *testing.T) {
},
}
//t.Parallel()
// t.Parallel()
for _, tc := range tcs {
t.Run(tc.name, func(t *testing.T) {
var err error
......
......@@ -69,7 +69,7 @@ func TestCacheMinikubeISOFromURL(t *testing.T) {
t.Fatalf("File not copied. Could not open file at path: %s", isoPath)
}
//test that the ISO is transferred properly
// test that the ISO is transferred properly
contents := []byte(testISOString)
if !bytes.Contains(transferred, contents) {
t.Fatalf("Expected transfers to contain: %s. It was: %s", contents, transferred)
......
......@@ -313,7 +313,7 @@ func GetPortFromKubeConfig(filename, machineName string) (int, error) {
return port, err
}
//UnsetCurrentContext unsets the current-context from minikube to "" on minikube stop
// UnsetCurrentContext unsets the current-context from minikube to "" on minikube stop
func UnsetCurrentContext(filename, machineName string) error {
confg, err := ReadConfigOrNew(filename)
if err != nil {
......@@ -332,7 +332,7 @@ func UnsetCurrentContext(filename, machineName string) error {
return nil
}
//SetCurrentContext sets the kubectl's current-context
// SetCurrentContext sets the kubectl's current-context
func SetCurrentContext(kubeCfgPath, name string) error {
kcfg, err := ReadConfigOrNew(kubeCfgPath)
if err != nil {
......
......@@ -266,7 +266,7 @@ func WaitForService(c kubernetes.Interface, namespace, name string, exist bool,
return nil
}
//WaitForServiceEndpointsNum waits until the amount of endpoints that implement service to expectNum.
// WaitForServiceEndpointsNum waits until the amount of endpoints that implement service to expectNum.
func WaitForServiceEndpointsNum(c kubernetes.Interface, namespace, serviceName string, expectNum int, interval, timeout time.Duration) error {
return wait.Poll(interval, timeout, func() (bool, error) {
glog.Infof("Waiting for amount of service:%s endpoints to be %d", serviceName, expectNum)
......
......@@ -29,7 +29,7 @@ func testClusterLogs(t *testing.T) {
minikubeRunner.EnsureRunning()
logsCmdOutput := minikubeRunner.GetLogs()
//check for # of lines or check for strings
// check for # of lines or check for strings
logWords := []string{"minikube", ".go"}
for _, logWord := range logWords {
if !strings.Contains(logsCmdOutput, logWord) {
......
......@@ -21,7 +21,7 @@ func StartServer(addrVal string, debugVal int, rootVal string) {
fmt.Print("ufs starting\n")
// determined by build tags
//extraFuncs()
// extraFuncs()
err := ufs.StartNetListener("tcp", addrVal)
if err != nil {
log.Println(err)
......
......@@ -225,7 +225,7 @@ func (u *Ufs) Wstat(req *SrvReq) {
case true:
mt = st.ModTime()
default:
//at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
// at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
}
}
// macOS filesystem st_mtime values are only accurate to the second
......
......@@ -219,7 +219,7 @@ func (u *Ufs) Wstat(req *SrvReq) {
case true:
mt = st.ModTime()
default:
//at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
// at = time.Time(0)//atime(st.Sys().(*syscall.Stat_t))
}
}
e := os.Chtimes(fid.path, at, mt)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册