Skip to content

Commit 3a587fc

Browse files
committed
fix: do not ever skip updates which have remove flag
For remove we don't care about what's set in the current peers. Otherwise it leads to remove event being skipped if the same values for the address or keep alive interval are passed. Signed-off-by: Artem Chernyshev <artem.chernyshev@talos-systems.com>
1 parent be00ff5 commit 3a587fc

File tree

6 files changed

+165
-40
lines changed

6 files changed

+165
-40
lines changed

.github/workflows/ci.yaml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-05-13T15:08:28Z by kres ce88e1c.
3+
# Generated on 2024-05-27T16:57:15Z by kres bcb280a.
44

55
name: default
66
concurrency:
@@ -29,16 +29,32 @@ jobs:
2929
- self-hosted
3030
- generic
3131
if: (!startsWith(github.head_ref, 'renovate/') && !startsWith(github.head_ref, 'dependabot/'))
32-
services:
33-
buildkitd:
34-
image: moby/buildkit:v0.13.2
35-
options: --privileged
36-
ports:
37-
- 1234:1234
38-
volumes:
39-
- /var/lib/buildkit/${{ github.repository }}:/var/lib/buildkit
40-
- /usr/etc/buildkit/buildkitd.toml:/etc/buildkit/buildkitd.toml
4132
steps:
33+
- name: gather-system-info
34+
id: system-info
35+
uses: kenchan0130/actions-system-info@v1.3.0
36+
continue-on-error: true
37+
- name: print-system-info
38+
run: |
39+
MEMORY_GB=$((${{ steps.system-info.outputs.totalmem }}/1024/1024/1024))
40+
41+
OUTPUTS=(
42+
"CPU Core: ${{ steps.system-info.outputs.cpu-core }}"
43+
"CPU Model: ${{ steps.system-info.outputs.cpu-model }}"
44+
"Hostname: ${{ steps.system-info.outputs.hostname }}"
45+
"NodeName: ${NODE_NAME}"
46+
"Kernel release: ${{ steps.system-info.outputs.kernel-release }}"
47+
"Kernel version: ${{ steps.system-info.outputs.kernel-version }}"
48+
"Name: ${{ steps.system-info.outputs.name }}"
49+
"Platform: ${{ steps.system-info.outputs.platform }}"
50+
"Release: ${{ steps.system-info.outputs.release }}"
51+
"Total memory: ${MEMORY_GB} GB"
52+
)
53+
54+
for OUTPUT in "${OUTPUTS[@]}";do
55+
echo "${OUTPUT}"
56+
done
57+
continue-on-error: true
4258
- name: checkout
4359
uses: actions/checkout@v4
4460
- name: Unshallow
@@ -49,7 +65,7 @@ jobs:
4965
uses: docker/setup-buildx-action@v3
5066
with:
5167
driver: remote
52-
endpoint: tcp://127.0.0.1:1234
68+
endpoint: tcp://buildkit-amd64.ci.svc.cluster.local:1234
5369
timeout-minutes: 10
5470
- name: base
5571
run: |

.golangci.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-05-13T15:08:28Z by kres ce88e1c.
3+
# Generated on 2024-05-27T16:57:15Z by kres bcb280a.
44

55
# options for analysis running
66
run:
@@ -35,7 +35,7 @@ linters-settings:
3535
sections:
3636
- standard # Standard section: captures all standard packages.
3737
- default # Default section: contains all imports that could not be matched to another section type.
38-
- prefix(github.com/siderolabs/siderolink/) # Custom section: groups all imports with the specified Prefix.
38+
- localmodule # Imports from the same module.
3939
gocognit:
4040
min-complexity: 30
4141
nestif:
@@ -51,8 +51,6 @@ linters-settings:
5151
scope: declarations
5252
gofmt:
5353
simplify: true
54-
goimports:
55-
local-prefixes: github.com/siderolabs/siderolink/
5654
gomodguard: { }
5755
govet:
5856
enable-all: true
@@ -145,6 +143,7 @@ linters:
145143
- varcheck
146144
# disabled as it seems to be broken - goes into imported libraries and reports issues there
147145
- musttag
146+
- goimports # same as gci
148147

149148
issues:
150149
exclude: [ ]

Dockerfile

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
44
#
5-
# Generated on 2024-05-13T15:08:28Z by kres ce88e1c.
5+
# Generated on 2024-05-27T16:57:15Z by kres bcb280a.
66

77
ARG TOOLCHAIN
88

99
# runs markdownlint
10-
FROM docker.io/node:21.7.3-alpine3.19 AS lint-markdown
10+
FROM docker.io/node:22.2.0-alpine3.19 AS lint-markdown
1111
WORKDIR /src
12-
RUN npm i -g markdownlint-cli@0.39.0
12+
RUN npm i -g markdownlint-cli@0.41.0
1313
RUN npm i sentences-per-line@0.2.1
1414
COPY .markdownlint.json .
1515
COPY ./README.md ./README.md
@@ -22,7 +22,7 @@ ADD api/siderolink/provision.proto /api/siderolink/
2222
ADD api/siderolink/wireguard.proto /api/siderolink/
2323

2424
# base toolchain image
25-
FROM ${TOOLCHAIN} AS toolchain
25+
FROM --platform=${BUILDPLATFORM} ${TOOLCHAIN} AS toolchain
2626
RUN apk --update --no-cache add bash curl build-base protoc protobuf-dev
2727

2828
# build tools
@@ -44,6 +44,9 @@ RUN mv /go/bin/protoc-gen-go-grpc /bin
4444
ARG GRPC_GATEWAY_VERSION
4545
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v${GRPC_GATEWAY_VERSION}
4646
RUN mv /go/bin/protoc-gen-grpc-gateway /bin
47+
ARG GOIMPORTS_VERSION
48+
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/tools/cmd/goimports@v${GOIMPORTS_VERSION}
49+
RUN mv /go/bin/goimports /bin
4750
ARG VTPROTOBUF_VERSION
4851
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install github.com/planetscale/vtprotobuf/cmd/protoc-gen-go-vtproto@v${VTPROTOBUF_VERSION}
4952
RUN mv /go/bin/protoc-gen-go-vtproto /bin
@@ -55,9 +58,6 @@ RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/g
5558
&& mv /go/bin/golangci-lint /bin/golangci-lint
5659
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/vuln/cmd/govulncheck@latest \
5760
&& mv /go/bin/govulncheck /bin/govulncheck
58-
ARG GOIMPORTS_VERSION
59-
RUN --mount=type=cache,target=/root/.cache/go-build --mount=type=cache,target=/go/pkg go install golang.org/x/tools/cmd/goimports@${GOIMPORTS_VERSION} \
60-
&& mv /go/bin/goimports /bin/goimports
6161
ARG GOFUMPT_VERSION
6262
RUN go install mvdan.cc/gofumpt@${GOFUMPT_VERSION} \
6363
&& mv /go/bin/gofumpt /bin/gofumpt
@@ -90,10 +90,6 @@ RUN gofumpt -w /api
9090
FROM base AS lint-gofumpt
9191
RUN FILES="$(gofumpt -l .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'gofumpt -w .':\n${FILES}"; exit 1)
9292

93-
# runs goimports
94-
FROM base AS lint-goimports
95-
RUN FILES="$(goimports -l -local github.com/siderolabs/siderolink/ .)" && test -z "${FILES}" || (echo -e "Source code is not formatted with 'goimports -w -local github.com/siderolabs/siderolink/ .':\n${FILES}"; exit 1)
96-
9793
# runs golangci-lint
9894
FROM base AS lint-golangci-lint
9995
WORKDIR /src

Makefile

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# THIS FILE WAS AUTOMATICALLY GENERATED, PLEASE DO NOT EDIT.
22
#
3-
# Generated on 2024-05-13T15:08:28Z by kres ce88e1c.
3+
# Generated on 2024-05-27T16:57:15Z by kres bcb280a.
44

55
# common variables
66

@@ -10,20 +10,22 @@ ABBREV_TAG := $(shell git describe --tags >/dev/null 2>/dev/null && git describe
1010
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
1111
ARTIFACTS := _out
1212
IMAGE_TAG ?= $(TAG)
13+
OPERATING_SYSTEM := $(shell uname -s | tr '[:upper:]' '[:lower:]')
14+
GOARCH := $(shell uname -m | sed 's/x86_64/amd64/' | sed 's/aarch64/arm64/')
1315
WITH_DEBUG ?= false
1416
WITH_RACE ?= false
1517
REGISTRY ?= ghcr.io
1618
USERNAME ?= siderolabs
1719
REGISTRY_AND_USERNAME ?= $(REGISTRY)/$(USERNAME)
18-
PROTOBUF_GO_VERSION ?= 1.33.0
20+
PROTOBUF_GO_VERSION ?= 1.34.1
1921
GRPC_GO_VERSION ?= 1.3.0
20-
GRPC_GATEWAY_VERSION ?= 2.19.1
22+
GRPC_GATEWAY_VERSION ?= 2.20.0
2123
VTPROTOBUF_VERSION ?= 0.6.0
24+
GOIMPORTS_VERSION ?= 0.21.0
2225
DEEPCOPY_VERSION ?= v0.5.6
23-
GOLANGCILINT_VERSION ?= v1.58.0
26+
GOLANGCILINT_VERSION ?= v1.59.0
2427
GOFUMPT_VERSION ?= v0.6.0
2528
GO_VERSION ?= 1.22.3
26-
GOIMPORTS_VERSION ?= v0.20.0
2729
GO_BUILDFLAGS ?=
2830
GO_LDFLAGS ?=
2931
CGO_ENABLED ?= 0
@@ -60,9 +62,9 @@ COMMON_ARGS += --build-arg=PROTOBUF_GO_VERSION="$(PROTOBUF_GO_VERSION)"
6062
COMMON_ARGS += --build-arg=GRPC_GO_VERSION="$(GRPC_GO_VERSION)"
6163
COMMON_ARGS += --build-arg=GRPC_GATEWAY_VERSION="$(GRPC_GATEWAY_VERSION)"
6264
COMMON_ARGS += --build-arg=VTPROTOBUF_VERSION="$(VTPROTOBUF_VERSION)"
65+
COMMON_ARGS += --build-arg=GOIMPORTS_VERSION="$(GOIMPORTS_VERSION)"
6366
COMMON_ARGS += --build-arg=DEEPCOPY_VERSION="$(DEEPCOPY_VERSION)"
6467
COMMON_ARGS += --build-arg=GOLANGCILINT_VERSION="$(GOLANGCILINT_VERSION)"
65-
COMMON_ARGS += --build-arg=GOIMPORTS_VERSION="$(GOIMPORTS_VERSION)"
6668
COMMON_ARGS += --build-arg=GOFUMPT_VERSION="$(GOFUMPT_VERSION)"
6769
COMMON_ARGS += --build-arg=TESTPKGS="$(TESTPKGS)"
6870
TOOLCHAIN ?= docker.io/golang:1.22-alpine
@@ -131,6 +133,9 @@ endif
131133

132134
all: unit-tests siderolink-agent lint
133135

136+
$(ARTIFACTS): ## Creates artifacts directory.
137+
@mkdir -p $(ARTIFACTS)
138+
134139
.PHONY: clean
135140
clean: ## Cleans up all artifacts.
136141
@rm -rf $(ARTIFACTS)
@@ -161,9 +166,6 @@ fmt: ## Formats the source code
161166
lint-govulncheck: ## Runs govulncheck linter.
162167
@$(MAKE) target-$@
163168

164-
lint-goimports: ## Runs goimports linter.
165-
@$(MAKE) target-$@
166-
167169
.PHONY: base
168170
base: ## Prepare base toolchain
169171
@$(MAKE) target-$@
@@ -226,7 +228,7 @@ lint-markdown: ## Runs markdownlint.
226228
@$(MAKE) target-$@
227229

228230
.PHONY: lint
229-
lint: lint-golangci-lint lint-gofumpt lint-govulncheck lint-goimports lint-markdown ## Run all linters for the project.
231+
lint: lint-golangci-lint lint-gofumpt lint-govulncheck lint-markdown ## Run all linters for the project.
230232

231233
.PHONY: rekres
232234
rekres:
@@ -239,8 +241,7 @@ help: ## This help menu.
239241
@grep -E '^[a-zA-Z%_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
240242

241243
.PHONY: release-notes
242-
release-notes:
243-
mkdir -p $(ARTIFACTS)
244+
release-notes: $(ARTIFACTS)
244245
@ARTIFACTS=$(ARTIFACTS) ./hack/release.sh $@ $(ARTIFACTS)/RELEASE_NOTES.md $(TAG)
245246

246247
.PHONY: conformance

pkg/wireguard/wireguard.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,10 @@ func checkDuplicateUpdates(seq iter.Seq[PeerEvent], oldCfg *wgtypes.Device, logg
561561
break
562562
}
563563

564+
if peerEvent.Remove {
565+
return true
566+
}
567+
564568
if prefix, ok := netipx.FromStdIPNet(&oldPeer.AllowedIPs[0]); ok {
565569
if prefix.Addr() == peerEvent.Address && // check address match & keepalive settings match
566570
(peerEvent.PersistentKeepAliveInterval == nil || pointer.SafeDeref(peerEvent.PersistentKeepAliveInterval) == oldPeer.PersistentKeepaliveInterval) {
@@ -575,6 +579,13 @@ func checkDuplicateUpdates(seq iter.Seq[PeerEvent], oldCfg *wgtypes.Device, logg
575579
}
576580
}
577581

582+
// the peer wasn't found in the existing peers, so skip it
583+
if peerEvent.Remove {
584+
logger.Info("skipping peer remove", zap.String("public_key", pubKey))
585+
586+
return false
587+
}
588+
578589
return true
579590
})
580591
}

0 commit comments

Comments
 (0)