Better comment syntax
parent
b1648ca2e4
commit
c5f695e8a0
|
@ -57,7 +57,7 @@ var addonsOpenCmd = &cobra.Command{
|
||||||
exit.Usage("usage: minikube addons open ADDON_NAME")
|
exit.Usage("usage: minikube addons open ADDON_NAME")
|
||||||
}
|
}
|
||||||
addonName := args[0]
|
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()
|
api, err := machine.NewAPIClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("Error getting client", err)
|
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)
|
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()
|
api, err := machine.NewAPIClient()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "machine client")
|
return errors.Wrap(err, "machine client")
|
||||||
|
|
|
@ -417,7 +417,7 @@ func validateConfig() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function validates if the --registry-mirror
|
// This function validates if the --registry-mirror
|
||||||
//args match the format of http://localhost
|
// args match the format of http://localhost
|
||||||
func validateRegistryMirror() {
|
func validateRegistryMirror() {
|
||||||
|
|
||||||
if len(registryMirror) > 0 {
|
if len(registryMirror) > 0 {
|
||||||
|
|
|
@ -81,6 +81,7 @@ func runStop(cmd *cobra.Command, args []string) {
|
||||||
exit.WithError("update config", err)
|
exit.WithError("update config", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
RootCmd.AddCommand(stopCmd)
|
RootCmd.AddCommand(stopCmd)
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,10 +59,10 @@ var tunnelCmd = &cobra.Command{
|
||||||
}
|
}
|
||||||
glog.Infof("Creating k8s client...")
|
glog.Infof("Creating k8s client...")
|
||||||
|
|
||||||
//Tunnel uses the k8s clientset to query the API server for services in the LoadBalancerEmulator.
|
// 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.
|
// 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
|
// 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.
|
// 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)
|
clientset, err := service.K8s.GetClientset(1 * time.Second)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
exit.WithError("error creating clientset", err)
|
exit.WithError("error creating clientset", err)
|
||||||
|
|
|
@ -194,15 +194,15 @@ func (d *Driver) deleteNetwork() error {
|
||||||
|
|
||||||
func (d *Driver) checkDomains(conn *libvirt.Connect) error {
|
func (d *Driver) checkDomains(conn *libvirt.Connect) error {
|
||||||
type source struct {
|
type source struct {
|
||||||
//XMLName xml.Name `xml:"source"`
|
// XMLName xml.Name `xml:"source"`
|
||||||
Network string `xml:"network,attr"`
|
Network string `xml:"network,attr"`
|
||||||
}
|
}
|
||||||
type iface struct {
|
type iface struct {
|
||||||
//XMLName xml.Name `xml:"interface"`
|
// XMLName xml.Name `xml:"interface"`
|
||||||
Source source `xml:"source"`
|
Source source `xml:"source"`
|
||||||
}
|
}
|
||||||
type result struct {
|
type result struct {
|
||||||
//XMLName xml.Name `xml:"domain"`
|
// XMLName xml.Name `xml:"domain"`
|
||||||
Name string `xml:"name"`
|
Name string `xml:"name"`
|
||||||
Interfaces []iface `xml:"devices>interface"`
|
Interfaces []iface `xml:"devices>interface"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -230,7 +230,7 @@ func (k *Bootstrapper) StartCluster(k8s config.KubernetesConfig) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if version.LT(semver.MustParse("1.10.0-alpha.0")) {
|
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
|
master = k8s.NodeName
|
||||||
if err := util.RetryAfter(200, unmarkMaster, time.Second*1); err != nil {
|
if err := util.RetryAfter(200, unmarkMaster, time.Second*1); err != nil {
|
||||||
return errors.Wrap(err, "timed out waiting to unmark master")
|
return errors.Wrap(err, "timed out waiting to unmark master")
|
||||||
|
|
|
@ -58,9 +58,9 @@ var (
|
||||||
maxClockDesyncSeconds = 2.1
|
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
|
// 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()
|
// 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
|
// see: https://github.com/kubernetes/kubernetes/blob/master/pkg/kubectl/util/logs/logs.go#L32-L34
|
||||||
func init() {
|
func init() {
|
||||||
if err := flag.Set("logtostderr", "false"); err != nil {
|
if err := flag.Set("logtostderr", "false"); err != nil {
|
||||||
exit.WithError("unable to set logtostderr", err)
|
exit.WithError("unable to set logtostderr", err)
|
||||||
|
|
|
@ -153,7 +153,7 @@ const (
|
||||||
SHASuffix = ".sha256"
|
SHASuffix = ".sha256"
|
||||||
// DefaultMemorySize is the default memory which will be allocated to minikube, in megabytes
|
// DefaultMemorySize is the default memory which will be allocated to minikube, in megabytes
|
||||||
DefaultMemorySize = "2000mb"
|
DefaultMemorySize = "2000mb"
|
||||||
//MinimumMemorySize is the minimum memory size, in megabytes
|
// MinimumMemorySize is the minimum memory size, in megabytes
|
||||||
MinimumMemorySize = "1024mb"
|
MinimumMemorySize = "1024mb"
|
||||||
// DefaultCPUS is the default number of cpus of a host
|
// DefaultCPUS is the default number of cpus of a host
|
||||||
DefaultCPUS = 2
|
DefaultCPUS = 2
|
||||||
|
@ -421,7 +421,7 @@ const (
|
||||||
// StoredContainerdConfigTomlPath is the path where the default config.toml will be stored
|
// StoredContainerdConfigTomlPath is the path where the default config.toml will be stored
|
||||||
StoredContainerdConfigTomlPath = "/tmp/config.toml"
|
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"
|
GvisorConfigTomlTargetName = "gvisor-config.toml"
|
||||||
// GvisorContainerdShimTargetName is the go-bindata target name for gvisor-containerd-shim
|
// GvisorContainerdShimTargetName is the go-bindata target name for gvisor-containerd-shim
|
||||||
GvisorContainerdShimTargetName = "gvisor-containerd-shim.toml"
|
GvisorContainerdShimTargetName = "gvisor-containerd-shim.toml"
|
||||||
|
|
|
@ -46,7 +46,7 @@ func createHypervHost(config cfg.MachineConfig) interface{} {
|
||||||
d.CPU = config.CPUs
|
d.CPU = config.CPUs
|
||||||
d.DiskSize = int(config.DiskSize)
|
d.DiskSize = int(config.DiskSize)
|
||||||
d.SSHUser = "docker"
|
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
|
return d
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,17 +27,17 @@ import (
|
||||||
"k8s.io/client-go/rest"
|
"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 {
|
type requestSender interface {
|
||||||
send(request *rest.Request) ([]byte, error)
|
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 {
|
type patchConverter interface {
|
||||||
convert(restClient rest.Interface, patch *Patch) *rest.Request
|
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 {
|
type loadBalancerEmulator struct {
|
||||||
coreV1Client typed_core.CoreV1Interface
|
coreV1Client typed_core.CoreV1Interface
|
||||||
requestSender requestSender
|
requestSender requestSender
|
||||||
|
|
|
@ -35,13 +35,13 @@ func osGetPid() int {
|
||||||
return os.Getpid()
|
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) {
|
func osCheckIfRunning(pid int) (bool, error) {
|
||||||
p, err := os.FindProcess(pid)
|
p, err := os.FindProcess(pid)
|
||||||
if runtime.GOOS == "windows" {
|
if runtime.GOOS == "windows" {
|
||||||
return err == nil, nil
|
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 {
|
if err != nil {
|
||||||
return false, fmt.Errorf("error finding process %d: %s", pid, err)
|
return false, fmt.Errorf("error finding process %d: %s", pid, err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,9 +31,9 @@ import (
|
||||||
|
|
||||||
// ID represents a registry ID
|
// ID represents a registry ID
|
||||||
type ID struct {
|
type ID struct {
|
||||||
//Route is the key
|
// Route is the key
|
||||||
Route *Route
|
Route *Route
|
||||||
//the rest is metadata
|
// the rest is metadata
|
||||||
MachineName string
|
MachineName string
|
||||||
Pid int
|
Pid int
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import (
|
||||||
"github.com/golang/glog"
|
"github.com/golang/glog"
|
||||||
)
|
)
|
||||||
|
|
||||||
//reporter that reports the status of a tunnel
|
// reporter that reports the status of a tunnel
|
||||||
type reporter interface {
|
type reporter interface {
|
||||||
Report(tunnelState *Status)
|
Report(tunnelState *Status)
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,7 +100,7 @@ Got: "%s"`, tc.name, tc.expectedOutput, out.output)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
//testing deduplication
|
// testing deduplication
|
||||||
out := &recordingWriter{}
|
out := &recordingWriter{}
|
||||||
reporter := newReporter(out)
|
reporter := newReporter(out)
|
||||||
reporter.Report(testCases[0].tunnelState)
|
reporter.Report(testCases[0].tunnelState)
|
||||||
|
|
|
@ -23,19 +23,19 @@ import (
|
||||||
"github.com/golang/glog"
|
"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 {
|
type router interface {
|
||||||
//Inspect checks if the given route exists or not in the routing table
|
// Inspect checks if the given route exists or not in the routing table
|
||||||
//conflict is defined as: same destination CIDR, different Gateway
|
// conflict is defined as: same destination CIDR, different Gateway
|
||||||
//overlaps are defined as: routes that have overlapping but not exactly matching destination CIDR
|
// 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)
|
Inspect(route *Route) (exists bool, conflict string, overlaps []string, err error)
|
||||||
|
|
||||||
//EnsureRouteIsAdded is an idempotent way to add a route to the routing table
|
// EnsureRouteIsAdded is an idempotent way to add a route to the routing table
|
||||||
//it fails if there is a conflict
|
// it fails if there is a conflict
|
||||||
EnsureRouteIsAdded(route *Route) error
|
EnsureRouteIsAdded(route *Route) error
|
||||||
|
|
||||||
//Cleanup is an idempotent way to remove a route from the routing table
|
// Cleanup is an idempotent way to remove a route from the routing table
|
||||||
//it fails if there is a conflict
|
// it fails if there is a conflict
|
||||||
Cleanup(route *Route) error
|
Cleanup(route *Route) error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,8 +67,8 @@ func isValidToAddOrDelete(router router, r *Route) (bool, error) {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//a partial representation of the routing table on the host
|
// 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
|
// tunnel only requires the destination CIDR, the gateway and the actual textual representation per line
|
||||||
type routingTable []routingTableLine
|
type routingTable []routingTableLine
|
||||||
|
|
||||||
func (t *routingTable) Check(route *Route) (exists bool, conflict string, overlaps []string) {
|
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{}
|
t := routingTable{}
|
||||||
skip := true
|
skip := true
|
||||||
for _, line := range strings.Split(string(table), "\n") {
|
for _, line := range strings.Split(string(table), "\n") {
|
||||||
//header
|
// header
|
||||||
if strings.HasPrefix(line, "Destination") {
|
if strings.HasPrefix(line, "Destination") {
|
||||||
skip = false
|
skip = false
|
||||||
continue
|
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") {
|
if skip || strings.HasPrefix(line, "default") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ func (router *osRouter) parseTable(table []byte) routingTable {
|
||||||
|
|
||||||
fields := strings.Fields(line)
|
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 ||
|
if len(fields) == 0 ||
|
||||||
len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
|
len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
|
||||||
continue
|
continue
|
||||||
|
@ -82,12 +82,12 @@ func (router *osRouter) parseTable(table []byte) routingTable {
|
||||||
|
|
||||||
if len(fields) > 2 {
|
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]
|
dstCIDRString := fields[0]
|
||||||
gatewayIPString := fields[2]
|
gatewayIPString := fields[2]
|
||||||
gatewayIP := net.ParseIP(gatewayIPString)
|
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"
|
// "1.2.3.0/24 dev eno1 proto kernel scope link src 1.2.3.54 metric 100"
|
||||||
if fields[1] != "via" {
|
if fields[1] != "via" {
|
||||||
gatewayIP = net.ParseIP("0.0.0.0")
|
gatewayIP = net.ParseIP("0.0.0.0")
|
||||||
|
|
|
@ -64,14 +64,14 @@ func (router *osRouter) parseTable(table []byte) routingTable {
|
||||||
t := routingTable{}
|
t := routingTable{}
|
||||||
skip := true
|
skip := true
|
||||||
for _, line := range strings.Split(string(table), "\n") {
|
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") {
|
if strings.HasPrefix(line, "Network Destination") {
|
||||||
skip = false
|
skip = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
fields := strings.Fields(line)
|
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") {
|
if skip || len(fields) == 0 || len(fields) > 0 && (fields[0] == "default" || fields[0] == "0.0.0.0") {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,8 @@ func (r *recordingReporter) Report(tunnelState *Status) {
|
||||||
r.statesRecorded = append(r.statesRecorded, tunnelState)
|
r.statesRecorded = append(r.statesRecorded, tunnelState)
|
||||||
}
|
}
|
||||||
|
|
||||||
//simulating idempotent router behavior
|
// simulating idempotent router behavior
|
||||||
//without checking for conflicting routes
|
// without checking for conflicting routes
|
||||||
type fakeRouter struct {
|
type fakeRouter struct {
|
||||||
rt routingTable
|
rt routingTable
|
||||||
errorResponse error
|
errorResponse error
|
||||||
|
|
|
@ -32,9 +32,9 @@ import (
|
||||||
"k8s.io/minikube/pkg/minikube/constants"
|
"k8s.io/minikube/pkg/minikube/constants"
|
||||||
)
|
)
|
||||||
|
|
||||||
//tunnel represents the basic API for a tunnel: periodically the state of the tunnel
|
// 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
|
// can be updated and when the tunnel is not needed, it can be cleaned up
|
||||||
//It was mostly introduced for testability.
|
// It was mostly introduced for testability.
|
||||||
type controller interface {
|
type controller interface {
|
||||||
cleanup() *Status
|
cleanup() *Status
|
||||||
update() *Status
|
update() *Status
|
||||||
|
@ -85,7 +85,7 @@ func newTunnel(machineName string, machineAPI libmachine.API, configLoader confi
|
||||||
}
|
}
|
||||||
|
|
||||||
type tunnel struct {
|
type tunnel struct {
|
||||||
//collaborators
|
// collaborators
|
||||||
clusterInspector *clusterInspector
|
clusterInspector *clusterInspector
|
||||||
router router
|
router router
|
||||||
loadBalancerEmulator loadBalancerEmulator
|
loadBalancerEmulator loadBalancerEmulator
|
||||||
|
@ -142,8 +142,8 @@ func setupRoute(t *tunnel, h *host.Host) {
|
||||||
if t.status.RouteError != nil {
|
if t.status.RouteError != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
//the route was added successfully, we need to make sure the registry has it too
|
// 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
|
// this might fail in race conditions, when another process created this tunnel
|
||||||
if err := t.registry.Register(&t.status.TunnelID); err != nil {
|
if err := t.registry.Register(&t.status.TunnelID); err != nil {
|
||||||
glog.Errorf("failed to register tunnel: %s", err)
|
glog.Errorf("failed to register tunnel: %s", err)
|
||||||
t.status.RouteError = err
|
t.status.RouteError = err
|
||||||
|
@ -151,7 +151,7 @@ func setupRoute(t *tunnel, h *host.Host) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if h.DriverName == constants.DriverHyperkit {
|
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)
|
setupBridge(t)
|
||||||
if t.status.RouteError != nil {
|
if t.status.RouteError != nil {
|
||||||
return
|
return
|
||||||
|
@ -166,7 +166,7 @@ func setupRoute(t *tunnel, h *host.Host) {
|
||||||
return
|
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)
|
existingTunnel, err := t.registry.IsAlreadyDefinedAndRunning(&t.status.TunnelID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
glog.Errorf("failed to check for other tunnels: %s", err)
|
glog.Errorf("failed to check for other tunnels: %s", err)
|
||||||
|
@ -175,7 +175,7 @@ func setupRoute(t *tunnel, h *host.Host) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if existingTunnel == nil {
|
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 {
|
if err := t.registry.Register(&t.status.TunnelID); err != nil {
|
||||||
glog.Errorf("failed to register tunnel: %s", err)
|
glog.Errorf("failed to register tunnel: %s", err)
|
||||||
t.status.RouteError = err
|
t.status.RouteError = err
|
||||||
|
@ -184,7 +184,7 @@ func setupRoute(t *tunnel, h *host.Host) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if existingTunnel.Pid != getPid() {
|
if existingTunnel.Pid != getPid() {
|
||||||
//another running process owns the tunnel
|
// another running process owns the tunnel
|
||||||
t.status.RouteError = errorTunnelAlreadyExists(existingTunnel)
|
t.status.RouteError = errorTunnelAlreadyExists(existingTunnel)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ type Manager struct {
|
||||||
router router
|
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
|
const stateCheckInterval = 5 * time.Second
|
||||||
|
|
||||||
// NewManager creates a new Manager
|
// 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)
|
check := make(chan bool, 1)
|
||||||
done = 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.timerLoop(ready, check)
|
||||||
go mgr.run(ctx, tunnel, ready, check, done)
|
go mgr.run(ctx, tunnel, ready, check, done)
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import (
|
||||||
|
|
||||||
func TestTunnelManagerEventHandling(t *testing.T) {
|
func TestTunnelManagerEventHandling(t *testing.T) {
|
||||||
tcs := []struct {
|
tcs := []struct {
|
||||||
//tunnel inputs
|
// tunnel inputs
|
||||||
name string
|
name string
|
||||||
repeat int
|
repeat int
|
||||||
test func(tunnel *tunnelStub, cancel context.CancelFunc, ready, check, done chan bool) error
|
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 {
|
for _, tc := range tcs {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
var err error
|
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)
|
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)
|
contents := []byte(testISOString)
|
||||||
if !bytes.Contains(transferred, contents) {
|
if !bytes.Contains(transferred, contents) {
|
||||||
t.Fatalf("Expected transfers to contain: %s. It was: %s", contents, transferred)
|
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
|
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 {
|
func UnsetCurrentContext(filename, machineName string) error {
|
||||||
confg, err := ReadConfigOrNew(filename)
|
confg, err := ReadConfigOrNew(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -332,7 +332,7 @@ func UnsetCurrentContext(filename, machineName string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//SetCurrentContext sets the kubectl's current-context
|
// SetCurrentContext sets the kubectl's current-context
|
||||||
func SetCurrentContext(kubeCfgPath, name string) error {
|
func SetCurrentContext(kubeCfgPath, name string) error {
|
||||||
kcfg, err := ReadConfigOrNew(kubeCfgPath)
|
kcfg, err := ReadConfigOrNew(kubeCfgPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -266,7 +266,7 @@ func WaitForService(c kubernetes.Interface, namespace, name string, exist bool,
|
||||||
return nil
|
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 {
|
func WaitForServiceEndpointsNum(c kubernetes.Interface, namespace, serviceName string, expectNum int, interval, timeout time.Duration) error {
|
||||||
return wait.Poll(interval, timeout, func() (bool, error) {
|
return wait.Poll(interval, timeout, func() (bool, error) {
|
||||||
glog.Infof("Waiting for amount of service:%s endpoints to be %d", serviceName, expectNum)
|
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()
|
minikubeRunner.EnsureRunning()
|
||||||
logsCmdOutput := minikubeRunner.GetLogs()
|
logsCmdOutput := minikubeRunner.GetLogs()
|
||||||
|
|
||||||
//check for # of lines or check for strings
|
// check for # of lines or check for strings
|
||||||
logWords := []string{"minikube", ".go"}
|
logWords := []string{"minikube", ".go"}
|
||||||
for _, logWord := range logWords {
|
for _, logWord := range logWords {
|
||||||
if !strings.Contains(logsCmdOutput, logWord) {
|
if !strings.Contains(logsCmdOutput, logWord) {
|
||||||
|
|
|
@ -21,7 +21,7 @@ func StartServer(addrVal string, debugVal int, rootVal string) {
|
||||||
|
|
||||||
fmt.Print("ufs starting\n")
|
fmt.Print("ufs starting\n")
|
||||||
// determined by build tags
|
// determined by build tags
|
||||||
//extraFuncs()
|
// extraFuncs()
|
||||||
err := ufs.StartNetListener("tcp", addrVal)
|
err := ufs.StartNetListener("tcp", addrVal)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println(err)
|
log.Println(err)
|
||||||
|
|
|
@ -225,7 +225,7 @@ func (u *Ufs) Wstat(req *SrvReq) {
|
||||||
case true:
|
case true:
|
||||||
mt = st.ModTime()
|
mt = st.ModTime()
|
||||||
default:
|
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
|
// macOS filesystem st_mtime values are only accurate to the second
|
||||||
|
|
|
@ -219,7 +219,7 @@ func (u *Ufs) Wstat(req *SrvReq) {
|
||||||
case true:
|
case true:
|
||||||
mt = st.ModTime()
|
mt = st.ModTime()
|
||||||
default:
|
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)
|
e := os.Chtimes(fid.path, at, mt)
|
||||||
|
|
Loading…
Reference in New Issue