Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
ca78265
fix: enable lll linter and format long function signatures
thevilledev Feb 1, 2025
dd685be
ci: revisit Go linter
pires May 29, 2025
0a453f9
Check for EphemeralContainers changes in pod compare
galal-hussein May 14, 2025
65f6275
build(deps): bump golang.org/x/net from 0.34.0 to 0.38.0
dependabot[bot] May 29, 2025
c9f64e8
build(deps): bump github.com/prometheus/common from 0.61.0 to 0.63.0
dependabot[bot] May 29, 2025
4ce429e
added envtest
enrichman Jun 6, 2025
adde4a8
build(deps): bump go.opentelemetry.io/otel from 1.33.0 to 1.36.0
dependabot[bot] Jun 11, 2025
84502b7
build(deps): bump go.opentelemetry.io/otel/sdk from 1.33.0 to 1.36.0
dependabot[bot] Jun 11, 2025
44fa1bc
Fix potential NPE on pod status updates
tskillian Sep 5, 2025
7b6f50c
build(deps): bump sigs.k8s.io/controller-runtime from 0.19.4 to 0.22.1
dependabot[bot] Sep 9, 2025
7d09c07
build(deps): bump actions/checkout from 4 to 5
dependabot[bot] Sep 9, 2025
8026f0f
build(deps): bump golang.org/x/sync from 0.14.0 to 0.17.0
dependabot[bot] Sep 9, 2025
1595a69
fix: do not register `nil` loggers
twelho Oct 31, 2024
c1efbd1
ci: bump Kubernetes to v1.33 and Go to 1.24
pires Sep 9, 2025
a4ecc3e
build(deps): bump go.opentelemetry.io/otel/sdk from 1.36.0 to 1.38.0
dependabot[bot] Sep 9, 2025
2456b12
build(deps): bump golang.org/x/time from 0.9.0 to 0.13.0
dependabot[bot] Sep 9, 2025
2a49e3a
build(deps): bump k8s.io/kubelet from 0.31.4 to 0.34.0
dependabot[bot] Sep 9, 2025
811c028
build(deps): bump github.com/spf13/pflag from 1.0.6 to 1.0.10
dependabot[bot] Sep 9, 2025
c485b29
deps: fix Prometheus bump proposed by dependabot
pires Sep 9, 2025
40cc429
queue: Use generic key type
saleemrashid Apr 26, 2025
31ffa20
node: Add PodUIDLifecycleHandler
saleemrashid Apr 26, 2025
bb96588
node: Track pods by UID instead of only namespace/name
saleemrashid Apr 26, 2025
11bbe25
node: Implement PodUIDLifecycleHandler for mockProvider
saleemrashid Apr 26, 2025
dfe615f
node: Add comments explaining uidProviderWrapper/syncProviderWrapper …
saleemrashid Sep 22, 2025
7be255c
node: Add UIDBasedProvider wrapper for legacy PodLifecycleHandler met…
saleemrashid Sep 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,75 +13,75 @@ permissions:
contents: read

env:
GO_VERSION: "1.23"
GO_VERSION: "1.24"

jobs:
lint:
name: Lint
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-go@v5
uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
cache: false
- uses: actions/checkout@v4
- uses: golangci/golangci-lint-action@v6
- uses: actions/checkout@v5
- uses: golangci/golangci-lint-action@v8
with:
version: v1.63.4
version: v2.4
args: --timeout=15m --config=.golangci.yml
skip-cache: true

unit-tests:
name: Unit Tests
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-go@v5
uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Run Tests
run: make test

env-tests:
name: Envtest Tests
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-go@v5
uses: actions/checkout@v5
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Run Tests
run: make envtest

e2e:
name: E2E
runs-on: ubuntu-22.04
runs-on: ubuntu-latest
timeout-minutes: 20
env:
CHANGE_MINIKUBE_NONE_USER: true
KUBERNETES_VERSION: v1.31
KUBERNETES_VERSION: v1.33
MINIKUBE_HOME: /home/runner
MINIKUBE_VERSION: v1.34.0
MINIKUBE_VERSION: v1.36.0
MINIKUBE_WANTUPDATENOTIFICATION: false
MINIKUBE_WANTREPORTERRORPROMPT: false
SKAFFOLD_VERSION: v2.13.2
GO111MODULE: "on"

steps:
- uses: actions/setup-go@v5
- uses: actions/setup-go@v6
with:
go-version: ${{ env.GO_VERSION }}
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5
- name: Install Skaffold
run: |
curl -sLo skaffold https://storage.googleapis.com/skaffold/releases/${SKAFFOLD_VERSION}/skaffold-linux-amd64
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v4
uses: actions/checkout@v5

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ credentials.json
# Test loganalytics file
loganalytics.json

# Envtest
.envtest/

# VS Code files
.vscode/

Expand Down
34 changes: 34 additions & 0 deletions .golangci.bck.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
issues:
exclude-use-default: false
exclude:
# 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|Errors unhandled)

exclude-dirs:
# This directory contains copy code from upstream kubernetes/kubernetes, skip it.
- internal/kubernetes
# This is mostly copied from upstream, rather than fixing that code here just ignore the errors.
- internal/podutils

linters:
enable:
- errcheck
- staticcheck
- unconvert
- gofmt
- goimports
- ineffassign
- govet
- unused
- misspell
- gosec
- copyloopvar # Checks for pointers to enclosing loop variables
- tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17
- lll

linters-settings:
gosec:
excludes:
- G304 # Potential file inclusion via variable
lll:
line-length: 200
76 changes: 45 additions & 31 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
linter-settings:
lll:
line-length: 200

timeout: 10m

issues:
exclude-use-default: false
exclude:
# 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|Errors unhandled)

exclude-dirs:
# This directory contains copy code from upstream kubernetes/kubernetes, skip it.
- internal/kubernetes
# This is mostly copied from upstream, rather than fixing that code here just ignore the errors.
- internal/podutils

version: "2"
linters:
enable:
- errcheck
- staticcheck
- copyloopvar
- gosec
- lll
- misspell
- unconvert
settings:
gosec:
excludes:
- G304
lll:
line-length: 200
exclusions:
generated: lax
rules:
- path: (.+)\.go$
text: Error return value of .((os\.)?std(out|err)\..*|.*Close|.*Flush|os\.Remove(All)?|.*print(f|ln)?|os\.(Un)?Setenv). (is not checked|Errors unhandled)
paths:
- internal/kubernetes
- internal/podutils
- third_party$
- builtin$
- examples$
formatters:
enable:
- gofmt
- goimports
- ineffassign
- govet
- unused
- misspell
- gosec
- copyloopvar # Checks for pointers to enclosing loop variables
- tenv # Detects using os.Setenv instead of t.Setenv since Go 1.17
exclusions:
generated: lax
paths:
- internal/kubernetes
- internal/podutils
- third_party$
- builtin$
- examples$
issues:
# Maximum issues count per one linter.
# Set to 0 to disable.
# Default: 50
max-issues-per-linter: 0

# Maximum count of issues with the same text.
# Set to 0 to disable.
# Default: 3
max-same-issues: 0

linters-settings:
gosec:
excludes:
- G304 # Potential file inclusion via variable
# Make issues output unique by line.
# Default: true
uniq-by-line: false
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG GOLANG_CI_LINT_VERSION

FROM golang:1.23 as builder
FROM golang:1.24 as builder
ENV PATH /go/bin:/usr/local/go/bin:$PATH
ENV GOPATH /go
COPY . /go/src/github.com/virtual-kubelet/virtual-kubelet
Expand Down
17 changes: 8 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,19 +165,18 @@ authors:
rm -f NEWAUTHORS
rm -f GITAUTHORS

checksums_2.3.1.txt:
curl -o checksums_2.3.1.txt -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/checksums.txt
kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}.tar.gz:
curl -C - -O -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}.tar.gz
kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}: kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}.tar.gz checksums_2.3.1.txt
sha256sum -c --ignore-missing checksums_2.3.1.txt
tar -xvf kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}.tar.gz
SETUP_ENVTEST_VERSION ?= v0.0.0-20250604165838-d6126d850224
ENVTEST_K8S_VERSION := 1.31.x

ENVTEST ?= go run sigs.k8s.io/controller-runtime/tools/setup-envtest@$(SETUP_ENVTEST_VERSION)
ENVTEST_DIR ?= $(shell pwd)/.envtest
export KUBEBUILDER_ASSETS ?= $(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(ENVTEST_DIR) -p path)

.PHONY: envtest
envtest: kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}
envtest:
# You can add klog flags for debugging, like: -klog.v=10 -klog.logtostderr
# klogv2 flags just wraps our existing logrus.
KUBEBUILDER_ASSETS=$(PWD)/kubebuilder_2.3.1_${TEST_OS}_${TEST_ARCH}/bin $(GOTEST) -run=TestEnvtest ./node -envtest=true
$(GOTEST) -run=TestEnvtest ./node -envtest=true

.PHONY: fmt
fmt:
Expand Down
24 changes: 12 additions & 12 deletions cmd/virtual-kubelet/internal/provider/mock/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var (
*/

// MockProvider implements the virtual-kubelet provider interface and stores pods in memory.
type MockProvider struct { //nolint:golint
type MockProvider struct {
nodeName string
operatingSystem string
internalIP string
Expand All @@ -55,7 +55,7 @@ type MockProvider struct { //nolint:golint
}

// MockConfig contains a mock virtual-kubelet's configurable parameters.
type MockConfig struct { //nolint:golint
type MockConfig struct {
CPU string `json:"cpu,omitempty"`
Memory string `json:"memory,omitempty"`
Pods string `json:"pods,omitempty"`
Expand Down Expand Up @@ -123,17 +123,17 @@ func loadConfig(providerConfig, nodeName string) (config MockConfig, err error)
}

if _, err = resource.ParseQuantity(config.CPU); err != nil {
return config, fmt.Errorf("Invalid CPU value %v", config.CPU)
return config, fmt.Errorf("invalid CPU value %v", config.CPU)
}
if _, err = resource.ParseQuantity(config.Memory); err != nil {
return config, fmt.Errorf("Invalid memory value %v", config.Memory)
return config, fmt.Errorf("invalid memory value %v", config.Memory)
}
if _, err = resource.ParseQuantity(config.Pods); err != nil {
return config, fmt.Errorf("Invalid pods value %v", config.Pods)
return config, fmt.Errorf("invalid pods value %v", config.Pods)
}
for _, v := range config.Others {
if _, err = resource.ParseQuantity(v); err != nil {
return config, fmt.Errorf("Invalid other value %v", v)
return config, fmt.Errorf("invalid other value %v", v)
}
}
return config, nil
Expand Down Expand Up @@ -349,7 +349,7 @@ func (p *MockProvider) GetPods(ctx context.Context) ([]*v1.Pod, error) {
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) {
ctx, span := trace.StartSpan(ctx, "mock.ConfigureNode") //nolint:staticcheck,ineffassign
defer span.End()

Expand All @@ -367,8 +367,8 @@ func (p *MockProvider) ConfigureNode(ctx context.Context, n *v1.Node) { //nolint
}
n.Status.NodeInfo.OperatingSystem = os
n.Status.NodeInfo.Architecture = "amd64"
n.ObjectMeta.Labels["alpha.service-controller.kubernetes.io/exclude-balancer"] = "true"
n.ObjectMeta.Labels["node.kubernetes.io/exclude-from-external-load-balancers"] = "true"
n.Labels["alpha.service-controller.kubernetes.io/exclude-balancer"] = "true"
n.Labels["node.kubernetes.io/exclude-from-external-load-balancers"] = "true"
}

// Capacity returns a resource list containing the capacity limits.
Expand Down Expand Up @@ -671,15 +671,15 @@ func buildKeyFromNames(namespace string, name string) (string, error) {

// buildKey is a helper for building the "key" for the providers pod store.
func buildKey(pod *v1.Pod) (string, error) {
if pod.ObjectMeta.Namespace == "" {
if pod.Namespace == "" {
return "", fmt.Errorf("pod namespace not found")
}

if pod.ObjectMeta.Name == "" {
if pod.Name == "" {
return "", fmt.Errorf("pod name not found")
}

return buildKeyFromNames(pod.ObjectMeta.Namespace, pod.ObjectMeta.Name)
return buildKeyFromNames(pod.Namespace, pod.Name)
}

// addAttributes adds the specified attributes to the provided span.
Expand Down
4 changes: 2 additions & 2 deletions cmd/virtual-kubelet/internal/provider/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type Store struct {
ls map[string]InitFunc
}

func NewStore() *Store { //nolint:golint
func NewStore() *Store {
return &Store{
ls: make(map[string]InitFunc),
}
Expand Down Expand Up @@ -71,4 +71,4 @@ type InitConfig struct {
ResourceManager *manager.ResourceManager
}

type InitFunc func(InitConfig) (Provider, error) //nolint:golint
type InitFunc func(InitConfig) (Provider, error)
4 changes: 2 additions & 2 deletions cmd/virtual-kubelet/internal/provider/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const (
OperatingSystemWindows = "windows"
)

type OperatingSystems map[string]bool //nolint:golint
type OperatingSystems map[string]bool

var (
// ValidOperatingSystems defines the group of operating systems
Expand All @@ -18,7 +18,7 @@ var (
}
)

func (o OperatingSystems) Names() []string { //nolint:golint
func (o OperatingSystems) Names() []string {
keys := make([]string, 0, len(o))
for k := range o {
keys = append(keys, k)
Expand Down
Loading
Loading