Merge branch 'master' into no-kubernetes
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
version: 2
|
||||
version: 2.0
|
||||
jobs:
|
||||
validate:
|
||||
resource_class: xlarge
|
||||
docker:
|
||||
- image: circleci/golang:1.13
|
||||
- image: circleci/golang:1.15
|
||||
environment:
|
||||
GO111MODULE: "on"
|
||||
GOPROXY: https://proxy.golang.org
|
||||
@@ -30,7 +30,7 @@ jobs:
|
||||
test:
|
||||
resource_class: xlarge
|
||||
docker:
|
||||
- image: circleci/golang:1.13
|
||||
- image: circleci/golang:1.15
|
||||
environment:
|
||||
GO111MODULE: "on"
|
||||
working_directory: /go/src/github.com/virtual-kubelet/virtual-kubelet
|
||||
@@ -52,18 +52,18 @@ jobs:
|
||||
|
||||
e2e:
|
||||
machine:
|
||||
image: circleci/classic:201808-01
|
||||
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.17.6
|
||||
KUBERNETES_VERSION: v1.20.1
|
||||
MINIKUBE_HOME: /home/circleci
|
||||
MINIKUBE_VERSION: v1.2.0
|
||||
MINIKUBE_VERSION: v1.16.0
|
||||
MINIKUBE_WANTUPDATENOTIFICATION: false
|
||||
MINIKUBE_WANTREPORTERRORPROMPT: false
|
||||
SKAFFOLD_VERSION: v0.33.0
|
||||
SKAFFOLD_VERSION: v1.17.2
|
||||
GO111MODULE: "on"
|
||||
steps:
|
||||
- checkout
|
||||
@@ -81,6 +81,16 @@ jobs:
|
||||
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: |
|
||||
@@ -114,7 +124,7 @@ jobs:
|
||||
command: |
|
||||
mkdir $HOME/.go
|
||||
export PATH=$HOME/.go/bin:${PATH}
|
||||
curl -fsSL -o "/tmp/go.tar.gz" "https://dl.google.com/go/go1.13.12.linux-amd64.tar.gz"
|
||||
curl -fsSL -o "/tmp/go.tar.gz" "https://dl.google.com/go/go1.15.6.linux-amd64.tar.gz"
|
||||
tar -C $HOME/.go --strip-components=1 -xzf "/tmp/go.tar.gz"
|
||||
go version
|
||||
make e2e
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM golang:1.13 as builder
|
||||
FROM golang:1.15 as builder
|
||||
ENV PATH /go/bin:/usr/local/go/bin:$PATH
|
||||
ENV GOPATH /go
|
||||
COPY . /go/src/github.com/virtual-kubelet/virtual-kubelet
|
||||
|
||||
2
Makefile
2
Makefile
@@ -13,7 +13,7 @@ include Makefile.e2e
|
||||
# Also, we will want to lock our tool versions using go mod:
|
||||
# https://github.com/golang/go/wiki/Modules#how-can-i-track-tool-dependencies-for-a-module
|
||||
gobin_tool ?= $(shell which gobin || echo $(GOPATH)/bin/gobin)
|
||||
goimports := golang.org/x/tools/cmd/goimports@release-branch.go1.13
|
||||
goimports := golang.org/x/tools/cmd/goimports@release-branch.go1.15
|
||||
gocovmerge := github.com/wadey/gocovmerge@b5bfa59ec0adc420475f97f89b58045c721d761c
|
||||
goreleaser := github.com/goreleaser/goreleaser@v0.82.2
|
||||
gox := github.com/mitchellh/gox@v1.0.1
|
||||
|
||||
2
go.mod
2
go.mod
@@ -1,6 +1,6 @@
|
||||
module github.com/virtual-kubelet/virtual-kubelet
|
||||
|
||||
go 1.13
|
||||
go 1.15
|
||||
|
||||
require (
|
||||
contrib.go.opencensus.io/exporter/jaeger v0.1.0
|
||||
|
||||
1
go.sum
1
go.sum
@@ -645,6 +645,7 @@ golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTk
|
||||
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422 h1:QzoH/1pFpZguR8NrRHLcO6jKqfv2zpuSqZLgdm7ZmjI=
|
||||
golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
apiVersion: skaffold/v1beta12
|
||||
apiVersion: skaffold/v2beta10
|
||||
kind: Config
|
||||
build:
|
||||
artifacts:
|
||||
|
||||
@@ -124,7 +124,7 @@ func (q *Queue) Run(ctx context.Context, workers int) {
|
||||
func (q *Queue) worker(ctx context.Context, i int) {
|
||||
ctx = log.WithLogger(ctx, log.G(ctx).WithFields(map[string]interface{}{
|
||||
"workerId": i,
|
||||
"Queue": q.name,
|
||||
"queue": q.name,
|
||||
}))
|
||||
for q.handleQueueItem(ctx) {
|
||||
}
|
||||
|
||||
98
log/klogv2/klogv2.go
Normal file
98
log/klogv2/klogv2.go
Normal file
@@ -0,0 +1,98 @@
|
||||
// Copyright © 2021 The virtual-kubelet authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
// Package klogv2 implements a virtual-kubelet/log.Logger using klogv2 as a backend
|
||||
//
|
||||
// You can use this by creating a klogv2 logger and calling `FromKlogv2(fields)`.
|
||||
// If you want this to be the default logger for virtual-kubelet, set `log.L` to the value returned by `FromKlogv2`
|
||||
//
|
||||
// We recommend reading the klog conventions to build a better understanding of levels and when they should apply
|
||||
// https://github.com/kubernetes/community/blob/master/contributors/devel/sig-instrumentation/logging.md
|
||||
package klogv2
|
||||
|
||||
import (
|
||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||
"k8s.io/klog/v2"
|
||||
)
|
||||
|
||||
// Ensure log.Logger is fully implemented during compile time.
|
||||
var _ log.Logger = (*adapter)(nil)
|
||||
|
||||
// adapter implements the `log.Logger` interface for klogv2
|
||||
type adapter struct {
|
||||
fields map[string]interface{}
|
||||
}
|
||||
|
||||
// FromKlogv2 creates a new `log.Logger` from the provided entry
|
||||
func FromKlogv2(fields map[string]interface{}) log.Logger {
|
||||
return &adapter{fields}
|
||||
}
|
||||
|
||||
func (l *adapter) Debug(args ...interface{}) {
|
||||
klog.V(4).Info(args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Debugf(format string, args ...interface{}) {
|
||||
klog.V(4).Infof(format, args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Info(args ...interface{}) {
|
||||
klog.Info(args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Infof(format string, args ...interface{}) {
|
||||
klog.Infof(format, args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Warn(args ...interface{}) {
|
||||
klog.Warning(args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Warnf(format string, args ...interface{}) {
|
||||
klog.Warningf(format, args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Error(args ...interface{}) {
|
||||
klog.Error(args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Errorf(format string, args ...interface{}) {
|
||||
klog.Errorf(format, args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Fatal(args ...interface{}) {
|
||||
klog.Fatal(args, l.fields)
|
||||
}
|
||||
|
||||
func (l *adapter) Fatalf(format string, args ...interface{}) {
|
||||
klog.Fatalf(format, args, l.fields)
|
||||
}
|
||||
|
||||
// WithField adds a field to the log entry.
|
||||
func (l *adapter) WithField(key string, val interface{}) log.Logger {
|
||||
fields := map[string]interface{}{
|
||||
key: val,
|
||||
}
|
||||
return FromKlogv2(fields)
|
||||
}
|
||||
|
||||
// WithFields adds multiple fields to a log entry.
|
||||
func (l *adapter) WithFields(fields log.Fields) log.Logger {
|
||||
return FromKlogv2(fields)
|
||||
}
|
||||
|
||||
// WithError adds an error to the log entry
|
||||
func (l *adapter) WithError(err error) log.Logger {
|
||||
return l.WithField("err", err)
|
||||
}
|
||||
@@ -22,27 +22,30 @@ import (
|
||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||
)
|
||||
|
||||
// Adapter implements the `log.Logger` interface for logrus
|
||||
type Adapter struct {
|
||||
// Ensure log.Logger is fully implemented during compile time.
|
||||
var _ log.Logger = (*adapter)(nil)
|
||||
|
||||
// adapter implements the `log.Logger` interface for logrus
|
||||
type adapter struct {
|
||||
*logrus.Entry
|
||||
}
|
||||
|
||||
// FromLogrus creates a new `log.Logger` from the provided entry
|
||||
func FromLogrus(entry *logrus.Entry) log.Logger {
|
||||
return &Adapter{entry}
|
||||
return &adapter{entry}
|
||||
}
|
||||
|
||||
// WithField adds a field to the log entry.
|
||||
func (l *Adapter) WithField(key string, val interface{}) log.Logger {
|
||||
func (l *adapter) WithField(key string, val interface{}) log.Logger {
|
||||
return FromLogrus(l.Entry.WithField(key, val))
|
||||
}
|
||||
|
||||
// WithFields adds multiple fields to a log entry.
|
||||
func (l *Adapter) WithFields(f log.Fields) log.Logger {
|
||||
func (l *adapter) WithFields(f log.Fields) log.Logger {
|
||||
return FromLogrus(l.Entry.WithFields(logrus.Fields(f)))
|
||||
}
|
||||
|
||||
// WithError adds an error to the log entry
|
||||
func (l *Adapter) WithError(err error) log.Logger {
|
||||
func (l *adapter) WithError(err error) log.Logger {
|
||||
return FromLogrus(l.Entry.WithError(err))
|
||||
}
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
// Copyright © 2017 The virtual-kubelet authors
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package logrus
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/virtual-kubelet/virtual-kubelet/log"
|
||||
)
|
||||
|
||||
func TestImplementsLoggerInterface(t *testing.T) {
|
||||
l := FromLogrus(&logrus.Entry{})
|
||||
|
||||
if _, ok := l.(log.Logger); !ok {
|
||||
t.Fatal("does not implement log.Logger interface")
|
||||
}
|
||||
}
|
||||
@@ -169,30 +169,39 @@ You can see from the console output whether the tests in the test suite pass or
|
||||
```console
|
||||
...
|
||||
=== RUN TestEndToEnd
|
||||
Setting up end-to-end test suite for mock provider...
|
||||
suite.go:62: True
|
||||
=== RUN TestEndToEnd/TestCreatePodWithMandatoryInexistentConfigMap
|
||||
=== RUN TestEndToEnd/TestCreatePodWithMandatoryInexistentSecrets
|
||||
=== RUN TestEndToEnd/TestCreatePodWithOptionalInexistentConfigMap
|
||||
=== RUN TestEndToEnd/TestCreatePodWithOptionalInexistentSecrets
|
||||
=== RUN TestEndToEnd/TestGetPods
|
||||
basic.go:40: Created pod: nginx-testgetpods-g9s42
|
||||
basic.go:46: Pod nginx-testgetpods-g9s42 ready
|
||||
=== RUN TestEndToEnd/TestGetStatsSummary
|
||||
=== RUN TestEndToEnd/TestNodeCreateAfterDelete
|
||||
=== RUN TestEndToEnd/TestPodLifecycleForceDelete
|
||||
basic.go:208: Created pod: nginx-testpodlifecycleforcedelete-wrjgk
|
||||
basic.go:214: Pod nginx-testpodlifecycleforcedelete-wrjgk ready
|
||||
basic.go:247: Force deleted pod: nginx-testpodlifecycleforcedelete-wrjgk
|
||||
basic.go:264: Pod ended as phase: Running
|
||||
=== RUN TestEndToEnd/TestPodLifecycleGracefulDelete
|
||||
--- PASS: TestEndToEnd (21.93s)
|
||||
--- PASS: TestEndToEnd/TestCreatePodWithMandatoryInexistentConfigMap (0.03s)
|
||||
basic.go:135: Created pod: nginx-testpodlifecyclegracefuldelete-tp49x
|
||||
basic.go:141: Pod nginx-testpodlifecyclegracefuldelete-tp49x ready
|
||||
basic.go:168: Deleted pod: nginx-testpodlifecyclegracefuldelete-tp49x
|
||||
Tearing down end-to-end test suite for mock provider...
|
||||
--- PASS: TestEndToEnd (11.75s)
|
||||
--- PASS: TestEndToEnd/TestCreatePodWithMandatoryInexistentConfigMap (0.04s)
|
||||
--- PASS: TestEndToEnd/TestCreatePodWithMandatoryInexistentSecrets (0.03s)
|
||||
--- PASS: TestEndToEnd/TestCreatePodWithOptionalInexistentConfigMap (0.55s)
|
||||
--- PASS: TestEndToEnd/TestCreatePodWithOptionalInexistentSecrets (0.99s)
|
||||
--- PASS: TestEndToEnd/TestCreatePodWithOptionalInexistentConfigMap (0.73s)
|
||||
--- PASS: TestEndToEnd/TestCreatePodWithOptionalInexistentSecrets (1.00s)
|
||||
--- PASS: TestEndToEnd/TestGetPods (0.80s)
|
||||
--- PASS: TestEndToEnd/TestGetStatsSummary (0.80s)
|
||||
--- PASS: TestEndToEnd/TestNodeCreateAfterDelete (9.63s)
|
||||
--- PASS: TestEndToEnd/TestNodeCreateAfterDelete (5.25s)
|
||||
--- PASS: TestEndToEnd/TestPodLifecycleForceDelete (2.05s)
|
||||
basic.go:158: Created pod: nginx-testpodlifecycleforcedelete-jz84g
|
||||
basic.go:164: Pod nginx-testpodlifecycleforcedelete-jz84g ready
|
||||
basic.go:197: Force deleted pod: nginx-testpodlifecycleforcedelete-jz84g
|
||||
basic.go:214: Pod ended as phase: Running
|
||||
--- PASS: TestEndToEnd/TestPodLifecycleGracefulDelete (1.04s)
|
||||
basic.go:87: Created pod: nginx-testpodlifecyclegracefuldelete-r84v7
|
||||
basic.go:93: Pod nginx-testpodlifecyclegracefuldelete-r84v7 ready
|
||||
basic.go:120: Deleted pod: nginx-testpodlifecyclegracefuldelete-r84v7
|
||||
--- PASS: TestEndToEnd/TestPodLifecycleGracefulDelete (1.05s)
|
||||
PASS
|
||||
ok github.com/virtual-kubelet/virtual-kubelet/internal/test/e2e 12.298s
|
||||
? github.com/virtual-kubelet/virtual-kubelet/internal/test/e2e/framework [no test files]
|
||||
...
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user