@@ -1,167 +0,0 @@
|
|||||||
version: 2.0
|
|
||||||
jobs:
|
|
||||||
validate:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.15
|
|
||||||
environment:
|
|
||||||
GO111MODULE: "on"
|
|
||||||
GOPROXY: https://proxy.golang.org
|
|
||||||
working_directory: /go/src/github.com/virtual-kubelet/virtual-kubelet
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- validate-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}
|
|
||||||
- run:
|
|
||||||
name: go vet
|
|
||||||
command: V=1 CI=1 make vet
|
|
||||||
- run:
|
|
||||||
name: Lint
|
|
||||||
command: make lint
|
|
||||||
- run:
|
|
||||||
name: Dependencies
|
|
||||||
command: scripts/validate/gomod.sh
|
|
||||||
- save_cache:
|
|
||||||
key: validate-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}
|
|
||||||
paths:
|
|
||||||
- "/go/pkg/mod"
|
|
||||||
|
|
||||||
test:
|
|
||||||
resource_class: xlarge
|
|
||||||
docker:
|
|
||||||
- image: circleci/golang:1.16
|
|
||||||
environment:
|
|
||||||
GO111MODULE: "on"
|
|
||||||
working_directory: /go/src/github.com/virtual-kubelet/virtual-kubelet
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- test-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}
|
|
||||||
- run:
|
|
||||||
name: Build
|
|
||||||
command: V=1 make build
|
|
||||||
- run: go install gotest.tools/gotestsum@latest
|
|
||||||
- run:
|
|
||||||
name: Tests
|
|
||||||
environment:
|
|
||||||
GOTEST: gotestsum -- -timeout=9m
|
|
||||||
GOTESTSUM_JUNITFILE: output/unit/results.xml
|
|
||||||
GODEBUG: cgocheck=2
|
|
||||||
command: |
|
|
||||||
mkdir -p output/unit
|
|
||||||
V=1 make test envtest
|
|
||||||
- save_cache:
|
|
||||||
key: test-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}
|
|
||||||
paths:
|
|
||||||
- "/go/pkg/mod"
|
|
||||||
- store_test_results:
|
|
||||||
path: output
|
|
||||||
|
|
||||||
e2e:
|
|
||||||
machine:
|
|
||||||
image: ubuntu-1604:202010-01
|
|
||||||
working_directory: /home/circleci/go/src/github.com/virtual-kubelet/virtual-kubelet
|
|
||||||
environment:
|
|
||||||
CHANGE_MINIKUBE_NONE_USER: true
|
|
||||||
GOPATH: /home/circleci/go
|
|
||||||
KUBECONFIG: /home/circleci/.kube/config
|
|
||||||
KUBERNETES_VERSION: v1.20.1
|
|
||||||
MINIKUBE_HOME: /home/circleci
|
|
||||||
MINIKUBE_VERSION: v1.16.0
|
|
||||||
MINIKUBE_WANTUPDATENOTIFICATION: false
|
|
||||||
MINIKUBE_WANTREPORTERRORPROMPT: false
|
|
||||||
SKAFFOLD_VERSION: v1.17.2
|
|
||||||
GO111MODULE: "on"
|
|
||||||
steps:
|
|
||||||
- checkout
|
|
||||||
- run:
|
|
||||||
name: Install kubectl
|
|
||||||
command: |
|
|
||||||
curl -Lo kubectl https://storage.googleapis.com/kubernetes-release/release/${KUBERNETES_VERSION}/bin/linux/amd64/kubectl
|
|
||||||
chmod +x kubectl
|
|
||||||
sudo mv kubectl /usr/local/bin/
|
|
||||||
mkdir -p ${HOME}/.kube
|
|
||||||
touch ${HOME}/.kube/config
|
|
||||||
- run:
|
|
||||||
name: Install Skaffold
|
|
||||||
command: |
|
|
||||||
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/${SKAFFOLD_VERSION}/skaffold-linux-amd64
|
|
||||||
chmod +x skaffold
|
|
||||||
sudo mv skaffold /usr/local/bin/
|
|
||||||
- run:
|
|
||||||
name: Install Minikube dependencies
|
|
||||||
command: |
|
|
||||||
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
|
|
||||||
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
|
|
||||||
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
|
||||||
deb https://apt.kubernetes.io/ kubernetes-xenial main
|
|
||||||
EOF
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y kubelet # systemd unit is disabled
|
|
||||||
- run:
|
|
||||||
name: Install Minikube
|
|
||||||
command: |
|
|
||||||
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
|
|
||||||
chmod +x minikube
|
|
||||||
sudo mv minikube /usr/local/bin/
|
|
||||||
- run:
|
|
||||||
name: Start Minikube
|
|
||||||
command: |
|
|
||||||
sudo -E minikube start --vm-driver=none --cpus 2 --memory 2048 --kubernetes-version=${KUBERNETES_VERSION}
|
|
||||||
- run:
|
|
||||||
name: Wait for Minikube
|
|
||||||
command: |
|
|
||||||
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
|
|
||||||
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
|
|
||||||
sleep 1;
|
|
||||||
done
|
|
||||||
- run:
|
|
||||||
name: Watch pods
|
|
||||||
command: kubectl get pods -o json --watch
|
|
||||||
background: true
|
|
||||||
- run:
|
|
||||||
name: Watch nodes
|
|
||||||
command: kubectl get nodes -o json --watch
|
|
||||||
background: true
|
|
||||||
- restore_cache:
|
|
||||||
keys:
|
|
||||||
- e2e-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}-2
|
|
||||||
- run:
|
|
||||||
name: Run the end-to-end test suite
|
|
||||||
environment:
|
|
||||||
GOTEST: gotestsum --
|
|
||||||
command: |
|
|
||||||
mkdir $HOME/.go
|
|
||||||
export PATH=$HOME/.go/bin:${PATH}
|
|
||||||
curl -fsSL -o "/tmp/go.tar.gz" "https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz"
|
|
||||||
tar -C $HOME/.go --strip-components=1 -xzf "/tmp/go.tar.gz"
|
|
||||||
go version
|
|
||||||
mkdir -p output/e2e
|
|
||||||
export GOTESTSUM_JUNITFILE="$(pwd)/output/e2e/results.xml"
|
|
||||||
export PATH="${GOPATH}/bin:${PATH}"
|
|
||||||
go install gotest.tools/gotestsum@latest
|
|
||||||
make e2e
|
|
||||||
- store_test_results:
|
|
||||||
path: output
|
|
||||||
- save_cache:
|
|
||||||
key: e2e-{{ checksum "go.mod" }}-{{ checksum "go.sum" }}-2
|
|
||||||
paths:
|
|
||||||
- "/home/circleci/go/pkg/mod"
|
|
||||||
- run:
|
|
||||||
name: Collect logs on failure from vkubelet-mock-0
|
|
||||||
command: |
|
|
||||||
kubectl logs vkubelet-mock-0
|
|
||||||
when: on_fail
|
|
||||||
|
|
||||||
workflows:
|
|
||||||
version: 2
|
|
||||||
validate_and_test:
|
|
||||||
jobs:
|
|
||||||
- validate
|
|
||||||
- test
|
|
||||||
- e2e:
|
|
||||||
requires:
|
|
||||||
- validate
|
|
||||||
- test
|
|
||||||
110
.github/workflows/ci.yml
vendored
Normal file
110
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
name: CI
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
env:
|
||||||
|
GO_VERSION: "1.18"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
lint:
|
||||||
|
name: Lint
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: golangci/golangci-lint-action@v3
|
||||||
|
with:
|
||||||
|
version: v1.48.0
|
||||||
|
args: --timeout=5m
|
||||||
|
|
||||||
|
unit-tests:
|
||||||
|
name: Unit Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Run Tests
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
env-tests:
|
||||||
|
name: Evntest Tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- name: Run Tests
|
||||||
|
run: make envtest
|
||||||
|
|
||||||
|
e2e:
|
||||||
|
name: E2E
|
||||||
|
runs-on: ubuntu-22.04
|
||||||
|
timeout-minutes: 10
|
||||||
|
env:
|
||||||
|
CHANGE_MINIKUBE_NONE_USER: true
|
||||||
|
KUBERNETES_VERSION: v1.20.1
|
||||||
|
MINIKUBE_HOME: /home/circleci
|
||||||
|
MINIKUBE_VERSION: v1.16.0
|
||||||
|
MINIKUBE_WANTUPDATENOTIFICATION: false
|
||||||
|
MINIKUBE_WANTREPORTERRORPROMPT: false
|
||||||
|
SKAFFOLD_VERSION: v1.17.2
|
||||||
|
GO111MODULE: "on"
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Install Skaffold
|
||||||
|
run: |
|
||||||
|
curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/${SKAFFOLD_VERSION}/skaffold-linux-amd64
|
||||||
|
chmod +x skaffold
|
||||||
|
sudo mv skaffold /usr/local/bin/
|
||||||
|
echo /usr/local/bin >> $GITHUB_PATH
|
||||||
|
- name: Install Minikube dependencies
|
||||||
|
run: |
|
||||||
|
sudo apt-get update && sudo apt-get install -y apt-transport-https curl
|
||||||
|
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
|
||||||
|
cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
|
||||||
|
deb https://apt.kubernetes.io/ kubernetes-xenial main
|
||||||
|
EOF
|
||||||
|
sudo apt-get update
|
||||||
|
sudo apt-get install -y kubelet # systemd unit is disabled
|
||||||
|
- name: Install Minikube
|
||||||
|
run: |
|
||||||
|
curl -Lo minikube https://storage.googleapis.com/minikube/releases/${MINIKUBE_VERSION}/minikube-linux-amd64
|
||||||
|
chmod +x minikube
|
||||||
|
sudo mv minikube /usr/local/bin/
|
||||||
|
- name: Start Minikube
|
||||||
|
run: |
|
||||||
|
sudo -E PATH=$PATH minikube start --vm-driver=none --cpus 2 --memory 2048 --kubernetes-version=${KUBERNETES_VERSION}
|
||||||
|
- name: Wait for Minikube
|
||||||
|
run: |
|
||||||
|
JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}';
|
||||||
|
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
|
||||||
|
sleep 1;
|
||||||
|
done
|
||||||
|
- name: Run Tests
|
||||||
|
run: make e2e
|
||||||
12
.github/workflows/codeql-analysis.yml
vendored
12
.github/workflows/codeql-analysis.yml
vendored
@@ -1,13 +1,17 @@
|
|||||||
name: "CodeQL"
|
name: "CodeQL"
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: ${{ github.workflow }}-${{ github.ref }}
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
pull_request:
|
pull_request:
|
||||||
# The branches below must be a subset of the branches above
|
# The branches below must be a subset of the branches above
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '19 18 * * 3'
|
- cron: "19 18 * * 3"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
analyze:
|
analyze:
|
||||||
@@ -17,7 +21,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
language: [ 'go' ]
|
language: ["go"]
|
||||||
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||||
# Learn more:
|
# Learn more:
|
||||||
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|||||||
@@ -12,20 +12,26 @@ run:
|
|||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- errcheck
|
- errcheck
|
||||||
- govet
|
- structcheck
|
||||||
- ineffassign
|
|
||||||
- golint
|
|
||||||
- goconst
|
|
||||||
- goimports
|
|
||||||
- unused
|
|
||||||
- varcheck
|
- varcheck
|
||||||
- deadcode
|
- staticcheck
|
||||||
|
- unconvert
|
||||||
|
- gofmt
|
||||||
|
- goimports
|
||||||
|
- ineffassign
|
||||||
|
- vet
|
||||||
|
- unused
|
||||||
- misspell
|
- misspell
|
||||||
- nolintlint
|
- gosec
|
||||||
- gocritic
|
- exportloopref # Checks for pointers to enclosing loop variables
|
||||||
|
- tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17
|
||||||
|
|
||||||
|
linters-settings:
|
||||||
|
gosec:
|
||||||
|
excludes:
|
||||||
|
- G304
|
||||||
issues:
|
issues:
|
||||||
exclude-use-default: false
|
exclude-use-default: false
|
||||||
exclude:
|
exclude:
|
||||||
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
|
# EXC0001 errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
|
||||||
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). is not checked
|
- Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). (is not checked|Errors unhandled)
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import (
|
|||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
"k8s.io/klog/v2"
|
klog "k8s.io/klog/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type mapVar map[string]string
|
type mapVar map[string]string
|
||||||
@@ -61,7 +61,9 @@ func installFlags(flags *pflag.FlagSet, c *Opts) {
|
|||||||
flags.StringVar(&c.KubeConfigPath, "kubeconfig", c.KubeConfigPath, "kube config file to use for connecting to the Kubernetes API server")
|
flags.StringVar(&c.KubeConfigPath, "kubeconfig", c.KubeConfigPath, "kube config file to use for connecting to the Kubernetes API server")
|
||||||
|
|
||||||
flags.StringVar(&c.KubeNamespace, "namespace", c.KubeNamespace, "kubernetes namespace (default is 'all')")
|
flags.StringVar(&c.KubeNamespace, "namespace", c.KubeNamespace, "kubernetes namespace (default is 'all')")
|
||||||
|
/* #nosec */
|
||||||
flags.MarkDeprecated("namespace", "Nodes must watch for pods in all namespaces. This option is now ignored.") //nolint:errcheck
|
flags.MarkDeprecated("namespace", "Nodes must watch for pods in all namespaces. This option is now ignored.") //nolint:errcheck
|
||||||
|
/* #nosec */
|
||||||
flags.MarkHidden("namespace") //nolint:errcheck
|
flags.MarkHidden("namespace") //nolint:errcheck
|
||||||
|
|
||||||
flags.StringVar(&c.KubeClusterDomain, "cluster-domain", c.KubeClusterDomain, "kubernetes cluster-domain (default is 'cluster.local')")
|
flags.StringVar(&c.KubeClusterDomain, "cluster-domain", c.KubeClusterDomain, "kubernetes cluster-domain (default is 'cluster.local')")
|
||||||
@@ -74,12 +76,15 @@ func installFlags(flags *pflag.FlagSet, c *Opts) {
|
|||||||
flags.StringVar(&c.TaintKey, "taint", c.TaintKey, "Set node taint key")
|
flags.StringVar(&c.TaintKey, "taint", c.TaintKey, "Set node taint key")
|
||||||
|
|
||||||
flags.BoolVar(&c.DisableTaint, "disable-taint", c.DisableTaint, "disable the virtual-kubelet node taint")
|
flags.BoolVar(&c.DisableTaint, "disable-taint", c.DisableTaint, "disable the virtual-kubelet node taint")
|
||||||
|
/* #nosec */
|
||||||
flags.MarkDeprecated("taint", "Taint key should now be configured using the VK_TAINT_KEY environment variable") //nolint:errcheck
|
flags.MarkDeprecated("taint", "Taint key should now be configured using the VK_TAINT_KEY environment variable") //nolint:errcheck
|
||||||
|
|
||||||
flags.IntVar(&c.PodSyncWorkers, "pod-sync-workers", c.PodSyncWorkers, `set the number of pod synchronization workers`)
|
flags.IntVar(&c.PodSyncWorkers, "pod-sync-workers", c.PodSyncWorkers, `set the number of pod synchronization workers`)
|
||||||
|
|
||||||
flags.BoolVar(&c.EnableNodeLease, "enable-node-lease", c.EnableNodeLease, `use node leases (1.13) for node heartbeats`)
|
flags.BoolVar(&c.EnableNodeLease, "enable-node-lease", c.EnableNodeLease, `use node leases (1.13) for node heartbeats`)
|
||||||
|
/* #nosec */
|
||||||
flags.MarkDeprecated("enable-node-lease", "leases are always enabled") //nolint:errcheck
|
flags.MarkDeprecated("enable-node-lease", "leases are always enabled") //nolint:errcheck
|
||||||
|
/* #nosec */
|
||||||
flags.MarkHidden("enable-node-lease") //nolint:errcheck
|
flags.MarkHidden("enable-node-lease") //nolint:errcheck
|
||||||
|
|
||||||
flags.StringSliceVar(&c.TraceExporters, "trace-exporter", c.TraceExporters, fmt.Sprintf("sets the tracing exporter to use, available exporters: %s", AvailableTraceExporters()))
|
flags.StringSliceVar(&c.TraceExporters, "trace-exporter", c.TraceExporters, fmt.Sprintf("sets the tracing exporter to use, available exporters: %s", AvailableTraceExporters()))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ func getTaint(c Opts) (*corev1.Taint, error) {
|
|||||||
|
|
||||||
key = getEnv("VKUBELET_TAINT_KEY", key)
|
key = getEnv("VKUBELET_TAINT_KEY", key)
|
||||||
value = getEnv("VKUBELET_TAINT_VALUE", value)
|
value = getEnv("VKUBELET_TAINT_VALUE", value)
|
||||||
effectEnv := getEnv("VKUBELET_TAINT_EFFECT", string(c.TaintEffect))
|
effectEnv := getEnv("VKUBELET_TAINT_EFFECT", c.TaintEffect)
|
||||||
|
|
||||||
var effect corev1.TaintEffect
|
var effect corev1.TaintEffect
|
||||||
switch effectEnv {
|
switch effectEnv {
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
package root
|
package root
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"strconv"
|
||||||
@@ -95,6 +96,8 @@ type Opts struct {
|
|||||||
Version string
|
Version string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const maxInt32 = 1<<31 - 1
|
||||||
|
|
||||||
// SetDefaultOpts sets default options for unset values on the passed in option struct.
|
// SetDefaultOpts sets default options for unset values on the passed in option struct.
|
||||||
// Fields tht are already set will not be modified.
|
// Fields tht are already set will not be modified.
|
||||||
func SetDefaultOpts(c *Opts) error {
|
func SetDefaultOpts(c *Opts) error {
|
||||||
@@ -128,6 +131,10 @@ func SetDefaultOpts(c *Opts) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error parsing KUBELET_PORT environment variable")
|
return errors.Wrap(err, "error parsing KUBELET_PORT environment variable")
|
||||||
}
|
}
|
||||||
|
if p > maxInt32 {
|
||||||
|
return fmt.Errorf("KUBELET_PORT environment variable is too large")
|
||||||
|
}
|
||||||
|
/* #nosec */
|
||||||
c.ListenPort = int32(p)
|
c.ListenPort = int32(p)
|
||||||
} else {
|
} else {
|
||||||
c.ListenPort = DefaultListenPort
|
c.ListenPort = DefaultListenPort
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
"github.com/virtual-kubelet/virtual-kubelet/errdefs"
|
||||||
@@ -105,7 +106,8 @@ func setupZpages(ctx context.Context) {
|
|||||||
zpages.Handle(mux, "/debug")
|
zpages.Handle(mux, "/debug")
|
||||||
go func() {
|
go func() {
|
||||||
// This should never terminate, if it does, it will always terminate with an error
|
// This should never terminate, if it does, it will always terminate with an error
|
||||||
e := http.Serve(listener, mux)
|
srv := &http.Server{Handler: mux, ReadHeaderTimeout: 30 * time.Second}
|
||||||
|
e := srv.Serve(listener)
|
||||||
if e == http.ErrServerClosed {
|
if e == http.ErrServerClosed {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ import (
|
|||||||
"go.opencensus.io/trace"
|
"go.opencensus.io/trace"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TracingExporterOptions struct { // nolint: golint
|
// TracingExporterOptions is the options passed to the tracing exporter init function.
|
||||||
|
type TracingExporterOptions struct { //nolint: golint
|
||||||
Tags map[string]string
|
Tags map[string]string
|
||||||
ServiceName string
|
ServiceName string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,13 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !no_jaeger_exporter
|
||||||
// +build !no_jaeger_exporter
|
// +build !no_jaeger_exporter
|
||||||
|
|
||||||
package root
|
package root
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"contrib.go.opencensus.io/exporter/jaeger"
|
"contrib.go.opencensus.io/exporter/jaeger"
|
||||||
@@ -32,7 +32,6 @@ func init() {
|
|||||||
// NewJaegerExporter creates a new opencensus tracing exporter.
|
// NewJaegerExporter creates a new opencensus tracing exporter.
|
||||||
func NewJaegerExporter(opts TracingExporterOptions) (trace.Exporter, error) {
|
func NewJaegerExporter(opts TracingExporterOptions) (trace.Exporter, error) {
|
||||||
jOpts := jaeger.Options{
|
jOpts := jaeger.Options{
|
||||||
Endpoint: os.Getenv("JAEGER_ENDPOINT"), // deprecated
|
|
||||||
CollectorEndpoint: os.Getenv("JAEGER_COLLECTOR_ENDPOINT"),
|
CollectorEndpoint: os.Getenv("JAEGER_COLLECTOR_ENDPOINT"),
|
||||||
AgentEndpoint: os.Getenv("JAEGER_AGENT_ENDPOINT"),
|
AgentEndpoint: os.Getenv("JAEGER_AGENT_ENDPOINT"),
|
||||||
Username: os.Getenv("JAEGER_USER"),
|
Username: os.Getenv("JAEGER_USER"),
|
||||||
@@ -42,11 +41,8 @@ func NewJaegerExporter(opts TracingExporterOptions) (trace.Exporter, error) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if jOpts.Endpoint != "" && jOpts.CollectorEndpoint == "" { // nolintlint:staticcheck
|
|
||||||
jOpts.CollectorEndpoint = fmt.Sprintf("%s/api/traces", jOpts.Endpoint) // nolintlint:staticcheck
|
|
||||||
}
|
|
||||||
if jOpts.CollectorEndpoint == "" && jOpts.AgentEndpoint == "" { // nolintlint:staticcheck
|
if jOpts.CollectorEndpoint == "" && jOpts.AgentEndpoint == "" { // nolintlint:staticcheck
|
||||||
return nil, errors.New("Must specify either JAEGER_COLLECTOR_ENDPOINT or JAEGER_AGENT_ENDPOINT")
|
return nil, errors.New("must specify either JAEGER_COLLECTOR_ENDPOINT or JAEGER_AGENT_ENDPOINT")
|
||||||
}
|
}
|
||||||
|
|
||||||
for k, v := range opts.Tags {
|
for k, v := range opts.Tags {
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
// See the License for the specific language governing permissions and
|
// See the License for the specific language governing permissions and
|
||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build !no_ocagent_exporter
|
||||||
// +build !no_ocagent_exporter
|
// +build !no_ocagent_exporter
|
||||||
|
|
||||||
package root
|
package root
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ var (
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
// MockProvider implements the virtual-kubelet provider interface and stores pods in memory.
|
// MockProvider implements the virtual-kubelet provider interface and stores pods in memory.
|
||||||
type MockProvider struct { // nolint:golint
|
type MockProvider struct { //nolint:golint
|
||||||
nodeName string
|
nodeName string
|
||||||
operatingSystem string
|
operatingSystem string
|
||||||
internalIP string
|
internalIP string
|
||||||
@@ -54,7 +54,7 @@ type MockProvider struct { // nolint:golint
|
|||||||
}
|
}
|
||||||
|
|
||||||
// MockConfig contains a mock virtual-kubelet's configurable parameters.
|
// MockConfig contains a mock virtual-kubelet's configurable parameters.
|
||||||
type MockConfig struct { // nolint:golint
|
type MockConfig struct { //nolint:golint
|
||||||
CPU string `json:"cpu,omitempty"`
|
CPU string `json:"cpu,omitempty"`
|
||||||
Memory string `json:"memory,omitempty"`
|
Memory string `json:"memory,omitempty"`
|
||||||
Pods string `json:"pods,omitempty"`
|
Pods string `json:"pods,omitempty"`
|
||||||
@@ -328,8 +328,8 @@ func (p *MockProvider) GetPods(ctx context.Context) ([]*v1.Pod, error) {
|
|||||||
return pods, nil
|
return pods, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *MockProvider) ConfigureNode(ctx context.Context, n *v1.Node) { // nolint:golint
|
func (p *MockProvider) ConfigureNode(ctx context.Context, n *v1.Node) { //nolint:golint
|
||||||
ctx, span := trace.StartSpan(ctx, "mock.ConfigureNode") // nolint:staticcheck,ineffassign
|
ctx, span := trace.StartSpan(ctx, "mock.ConfigureNode") //nolint:staticcheck,ineffassign
|
||||||
defer span.End()
|
defer span.End()
|
||||||
|
|
||||||
n.Status.Capacity = p.capacity()
|
n.Status.Capacity = p.capacity()
|
||||||
@@ -467,10 +467,14 @@ func (p *MockProvider) GetStatsSummary(ctx context.Context) (*stats.Summary, err
|
|||||||
for _, container := range pod.Spec.Containers {
|
for _, container := range pod.Spec.Containers {
|
||||||
// Grab a dummy value to be used as the total CPU usage.
|
// Grab a dummy value to be used as the total CPU usage.
|
||||||
// The value should fit a uint32 in order to avoid overflows later on when computing pod stats.
|
// The value should fit a uint32 in order to avoid overflows later on when computing pod stats.
|
||||||
|
|
||||||
|
/* #nosec */
|
||||||
dummyUsageNanoCores := uint64(rand.Uint32())
|
dummyUsageNanoCores := uint64(rand.Uint32())
|
||||||
totalUsageNanoCores += dummyUsageNanoCores
|
totalUsageNanoCores += dummyUsageNanoCores
|
||||||
// Create a dummy value to be used as the total RAM usage.
|
// Create a dummy value to be used as the total RAM usage.
|
||||||
// The value should fit a uint32 in order to avoid overflows later on when computing pod stats.
|
// The value should fit a uint32 in order to avoid overflows later on when computing pod stats.
|
||||||
|
|
||||||
|
/* #nosec */
|
||||||
dummyUsageBytes := uint64(rand.Uint32())
|
dummyUsageBytes := uint64(rand.Uint32())
|
||||||
totalUsageBytes += dummyUsageBytes
|
totalUsageBytes += dummyUsageBytes
|
||||||
// Append a ContainerStats object containing the dummy stats to the PodStats object.
|
// Append a ContainerStats object containing the dummy stats to the PodStats object.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ type Store struct {
|
|||||||
ls map[string]InitFunc
|
ls map[string]InitFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStore() *Store { // nolint:golint
|
func NewStore() *Store { //nolint:golint
|
||||||
return &Store{
|
return &Store{
|
||||||
ls: make(map[string]InitFunc),
|
ls: make(map[string]InitFunc),
|
||||||
}
|
}
|
||||||
@@ -71,4 +71,4 @@ type InitConfig struct {
|
|||||||
ResourceManager *manager.ResourceManager
|
ResourceManager *manager.ResourceManager
|
||||||
}
|
}
|
||||||
|
|
||||||
type InitFunc func(InitConfig) (Provider, error) // nolint:golint
|
type InitFunc func(InitConfig) (Provider, error) //nolint:golint
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const (
|
|||||||
OperatingSystemWindows = "windows"
|
OperatingSystemWindows = "windows"
|
||||||
)
|
)
|
||||||
|
|
||||||
type OperatingSystems map[string]bool // nolint:golint
|
type OperatingSystems map[string]bool //nolint:golint
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ValidOperatingSystems defines the group of operating systems
|
// ValidOperatingSystems defines the group of operating systems
|
||||||
@@ -18,7 +18,7 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (o OperatingSystems) Names() []string { // nolint:golint
|
func (o OperatingSystems) Names() []string { //nolint:golint
|
||||||
keys := make([]string, 0, len(o))
|
keys := make([]string, 0, len(o))
|
||||||
for k := range o {
|
for k := range o {
|
||||||
keys = append(keys, k)
|
keys = append(keys, k)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func registerMock(s *provider.Store) {
|
func registerMock(s *provider.Store) {
|
||||||
|
/* #nosec */
|
||||||
s.Register("mock", func(cfg provider.InitConfig) (provider.Provider, error) { //nolint:errcheck
|
s.Register("mock", func(cfg provider.InitConfig) (provider.Provider, error) { //nolint:errcheck
|
||||||
return mock.NewMockProvider(
|
return mock.NewMockProvider(
|
||||||
cfg.ConfigPath,
|
cfg.ConfigPath,
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ func TestGetConfigMap(t *testing.T) {
|
|||||||
}
|
}
|
||||||
value := configMap.Data["key-0"]
|
value := configMap.Data["key-0"]
|
||||||
if value != "val-0" {
|
if value != "val-0" {
|
||||||
t.Fatal("got unexpected value", string(value))
|
t.Fatal("got unexpected value", value)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to get a configmap that does not exist, and make sure we've got a "not found" error as a response.
|
// Try to get a configmap that does not exist, and make sure we've got a "not found" error as a response.
|
||||||
|
|||||||
@@ -33,7 +33,9 @@ func handleError(f handlerFunc) http.HandlerFunc {
|
|||||||
|
|
||||||
code := httpStatusCode(err)
|
code := httpStatusCode(err)
|
||||||
w.WriteHeader(code)
|
w.WriteHeader(code)
|
||||||
io.WriteString(w, err.Error()) //nolint:errcheck
|
if _, err := io.WriteString(w, err.Error()); err != nil {
|
||||||
|
log.G(req.Context()).WithError(err).Error("error writing error response")
|
||||||
|
}
|
||||||
logger := log.G(req.Context()).WithError(err).WithField("httpStatusCode", code)
|
logger := log.G(req.Context()).WithError(err).WithField("httpStatusCode", code)
|
||||||
|
|
||||||
if code >= 500 {
|
if code >= 500 {
|
||||||
|
|||||||
@@ -24,14 +24,15 @@ import (
|
|||||||
"k8s.io/apimachinery/pkg/runtime/serializer"
|
"k8s.io/apimachinery/pkg/runtime/serializer"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PodListerFunc func(context.Context) ([]*v1.Pod, error) // nolint:golint
|
type PodListerFunc func(context.Context) ([]*v1.Pod, error) //nolint:golint
|
||||||
|
|
||||||
func HandleRunningPods(getPods PodListerFunc) http.HandlerFunc { // nolint:golint
|
func HandleRunningPods(getPods PodListerFunc) http.HandlerFunc { //nolint:golint
|
||||||
if getPods == nil {
|
if getPods == nil {
|
||||||
return NotImplemented
|
return NotImplemented
|
||||||
}
|
}
|
||||||
|
|
||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
|
/* #nosec */
|
||||||
v1.SchemeBuilder.AddToScheme(scheme) //nolint:errcheck
|
v1.SchemeBuilder.AddToScheme(scheme) //nolint:errcheck
|
||||||
codecs := serializer.NewCodecFactory(scheme)
|
codecs := serializer.NewCodecFactory(scheme)
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ type ServeMux interface {
|
|||||||
Handle(path string, h http.Handler)
|
Handle(path string, h http.Handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
type PodHandlerConfig struct { // nolint:golint
|
type PodHandlerConfig struct { //nolint:golint
|
||||||
RunInContainer ContainerExecHandlerFunc
|
RunInContainer ContainerExecHandlerFunc
|
||||||
GetContainerLogs ContainerLogsHandlerFunc
|
GetContainerLogs ContainerLogsHandlerFunc
|
||||||
// GetPods is meant to enumerate the pods that the provider knows about
|
// GetPods is meant to enumerate the pods that the provider knows about
|
||||||
|
|||||||
@@ -333,7 +333,7 @@ func (e *nodeNotReadyError) Is(target error) bool {
|
|||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *nodeNotReadyError) As(target error) bool {
|
func (e *nodeNotReadyError) As(target interface{}) bool {
|
||||||
val, ok := target.(*nodeNotReadyError)
|
val, ok := target.(*nodeNotReadyError)
|
||||||
if ok {
|
if ok {
|
||||||
*val = *e
|
*val = *e
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ var (
|
|||||||
const (
|
const (
|
||||||
// There might be a constant we can already leverage here
|
// There might be a constant we can already leverage here
|
||||||
testNamespace = "default"
|
testNamespace = "default"
|
||||||
informerResyncPeriod = time.Duration(1 * time.Second)
|
informerResyncPeriod = 1 * time.Second
|
||||||
testNodeName = "testnode"
|
testNodeName = "testnode"
|
||||||
podSyncWorkers = 3
|
podSyncWorkers = 3
|
||||||
)
|
)
|
||||||
@@ -232,7 +232,7 @@ type system struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *system) start(ctx context.Context) error {
|
func (s *system) start(ctx context.Context) error {
|
||||||
go s.pc.Run(ctx, podSyncWorkers) // nolint:errcheck
|
go s.pc.Run(ctx, podSyncWorkers) //nolint:errcheck
|
||||||
select {
|
select {
|
||||||
case <-s.pc.Ready():
|
case <-s.pc.Ready():
|
||||||
case <-s.pc.Done():
|
case <-s.pc.Done():
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ var (
|
|||||||
//
|
//
|
||||||
// Note: Implementers can choose to manage a node themselves, in which case
|
// Note: Implementers can choose to manage a node themselves, in which case
|
||||||
// it is not needed to provide an implementation for this interface.
|
// it is not needed to provide an implementation for this interface.
|
||||||
type NodeProvider interface { // nolint:golint
|
type NodeProvider interface { //nolint:revive
|
||||||
// Ping checks if the node is still active.
|
// Ping checks if the node is still active.
|
||||||
// This is intended to be lightweight as it will be called periodically as a
|
// This is intended to be lightweight as it will be called periodically as a
|
||||||
// heartbeat to keep the node marked as ready in Kubernetes.
|
// heartbeat to keep the node marked as ready in Kubernetes.
|
||||||
@@ -105,7 +105,7 @@ func NewNodeController(p NodeProvider, node *corev1.Node, nodes v1.NodeInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NodeControllerOpt are the functional options used for configuring a node
|
// NodeControllerOpt are the functional options used for configuring a node
|
||||||
type NodeControllerOpt func(*NodeController) error // nolint:golint
|
type NodeControllerOpt func(*NodeController) error //nolint:revive
|
||||||
|
|
||||||
// WithNodeEnableLeaseV1 enables support for v1 leases.
|
// WithNodeEnableLeaseV1 enables support for v1 leases.
|
||||||
// V1 Leases share all the same properties as v1beta1 leases, except they do not fallback like
|
// V1 Leases share all the same properties as v1beta1 leases, except they do not fallback like
|
||||||
@@ -208,7 +208,7 @@ type ErrorHandler func(context.Context, error) error
|
|||||||
// NodeController deals with creating and managing a node object in Kubernetes.
|
// NodeController deals with creating and managing a node object in Kubernetes.
|
||||||
// It can register a node with Kubernetes and periodically update its status.
|
// It can register a node with Kubernetes and periodically update its status.
|
||||||
// NodeController manages a single node entity.
|
// NodeController manages a single node entity.
|
||||||
type NodeController struct { // nolint:golint
|
type NodeController struct { //nolint:revive
|
||||||
p NodeProvider
|
p NodeProvider
|
||||||
|
|
||||||
// serverNode must be updated each time it is updated in API Server
|
// serverNode must be updated each time it is updated in API Server
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ func testNodeRun(t *testing.T, enableLease bool) {
|
|||||||
assert.NilError(t, node.Err())
|
assert.NilError(t, node.Err())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go node.Run(ctx) // nolint:errcheck
|
go node.Run(ctx) //nolint:errcheck
|
||||||
|
|
||||||
nw := makeWatch(ctx, t, nodes, testNodeCopy.Name)
|
nw := makeWatch(ctx, t, nodes, testNodeCopy.Name)
|
||||||
defer nw.Stop()
|
defer nw.Stop()
|
||||||
@@ -189,7 +189,7 @@ func TestNodeCustomUpdateStatusErrorHandler(t *testing.T) {
|
|||||||
)
|
)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
go node.Run(ctx) // nolint:errcheck
|
go node.Run(ctx) //nolint:errcheck
|
||||||
|
|
||||||
timer := time.NewTimer(10 * time.Second)
|
timer := time.NewTimer(10 * time.Second)
|
||||||
defer timer.Stop()
|
defer timer.Stop()
|
||||||
@@ -295,7 +295,7 @@ func TestPingAfterStatusUpdate(t *testing.T) {
|
|||||||
node, err := NewNodeController(testP, testNode, nodes, opts...)
|
node, err := NewNodeController(testP, testNode, nodes, opts...)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
go node.Run(ctx) // nolint:errcheck
|
go node.Run(ctx) //nolint:errcheck
|
||||||
defer func() {
|
defer func() {
|
||||||
cancel()
|
cancel()
|
||||||
<-node.Done()
|
<-node.Done()
|
||||||
@@ -363,7 +363,7 @@ func TestBeforeAnnotationsPreserved(t *testing.T) {
|
|||||||
assert.NilError(t, node.Err())
|
assert.NilError(t, node.Err())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go node.Run(ctx) // nolint:errcheck
|
go node.Run(ctx) //nolint:errcheck
|
||||||
|
|
||||||
nw := makeWatch(ctx, t, nodes, testNodeCopy.Name)
|
nw := makeWatch(ctx, t, nodes, testNodeCopy.Name)
|
||||||
defer nw.Stop()
|
defer nw.Stop()
|
||||||
@@ -427,7 +427,7 @@ func TestManualConditionsPreserved(t *testing.T) {
|
|||||||
assert.NilError(t, node.Err())
|
assert.NilError(t, node.Err())
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go node.Run(ctx) // nolint:errcheck
|
go node.Run(ctx) //nolint:errcheck
|
||||||
|
|
||||||
nw := makeWatch(ctx, t, nodes, testNodeCopy.Name)
|
nw := makeWatch(ctx, t, nodes, testNodeCopy.Name)
|
||||||
defer nw.Stop()
|
defer nw.Stop()
|
||||||
|
|||||||
@@ -78,12 +78,14 @@ func (n *Node) runHTTP(ctx context.Context) (func(), error) {
|
|||||||
|
|
||||||
log.G(ctx).Debug("Started TLS listener")
|
log.G(ctx).Debug("Started TLS listener")
|
||||||
|
|
||||||
srv := &http.Server{Handler: n.h, TLSConfig: n.tlsConfig}
|
srv := &http.Server{Handler: n.h, TLSConfig: n.tlsConfig, ReadHeaderTimeout: 30 * time.Second}
|
||||||
go srv.Serve(l) //nolint:errcheck
|
go srv.Serve(l) //nolint:errcheck
|
||||||
log.G(ctx).Debug("HTTP server running")
|
log.G(ctx).Debug("HTTP server running")
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
|
/* #nosec */
|
||||||
srv.Close()
|
srv.Close()
|
||||||
|
/* #nosec */
|
||||||
l.Close()
|
l.Close()
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
@@ -275,7 +277,6 @@ func WithClient(c kubernetes.Interface) NodeOpt {
|
|||||||
// Some basic values are set for node status, you'll almost certainly want to modify it.
|
// Some basic values are set for node status, you'll almost certainly want to modify it.
|
||||||
//
|
//
|
||||||
// If client is nil, this will construct a client using ClientsetFromEnv
|
// If client is nil, this will construct a client using ClientsetFromEnv
|
||||||
//
|
|
||||||
// It is up to the caller to configure auth on the HTTP handler.
|
// It is up to the caller to configure auth on the HTTP handler.
|
||||||
func NewNode(name string, newProvider NewProviderFunc, opts ...NodeOpt) (*Node, error) {
|
func NewNode(name string, newProvider NewProviderFunc, opts ...NodeOpt) (*Node, error) {
|
||||||
cfg := NodeConfig{
|
cfg := NodeConfig{
|
||||||
|
|||||||
@@ -403,7 +403,7 @@ func (ts *EndToEndTestSuite) TestCreatePodWithMandatoryInexistentConfigMap(t *te
|
|||||||
// It returns an error if the specified pod is not found.
|
// It returns an error if the specified pod is not found.
|
||||||
func findPodInPodStats(summary *stats.Summary, pod *v1.Pod) (int, error) {
|
func findPodInPodStats(summary *stats.Summary, pod *v1.Pod) (int, error) {
|
||||||
for i, p := range summary.Pods {
|
for i, p := range summary.Pods {
|
||||||
if p.PodRef.Namespace == pod.Namespace && p.PodRef.Name == pod.Name && string(p.PodRef.UID) == string(pod.UID) {
|
if p.PodRef.Namespace == pod.Namespace && p.PodRef.Name == pod.Name && p.PodRef.UID == string(pod.UID) {
|
||||||
return i, nil
|
return i, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user