Skip to content

Commit bcff570

Browse files
saschagrunertk8s-ci-robot
authored andcommitted
Fix build in CI
Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
1 parent 7902b9d commit bcff570

32 files changed

+122
-16
lines changed

.golangci.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ run:
55
linters:
66
default: none
77
enable:
8+
- arangolint
89
- asasalint
910
- asciicheck
1011
- bidichk
@@ -59,7 +60,6 @@ linters:
5960
- nilnesserr
6061
- nilnil
6162
- nlreturn
62-
- noctx
6363
- nolintlint
6464
- nosprintfhostport
6565
- paralleltest
@@ -89,10 +89,11 @@ linters:
8989
- usetesting
9090
- wastedassign
9191
- whitespace
92-
- wsl
92+
- wsl_v5
9393
- zerologlint
9494
# - cyclop
9595
# - depguard
96+
# - embeddedstructfieldcheck
9697
# - err113
9798
# - exhaustruct
9899
# - forbidigo
@@ -105,6 +106,8 @@ linters:
105106
# - ireturn
106107
# - maintidx
107108
# - mnd
109+
# - noctx
110+
# - noinlineerr
108111
# - nonamedreturns
109112
# - testpackage
110113
# - varnamelen
@@ -136,6 +139,10 @@ linters:
136139
rules:
137140
- name: unused-parameter
138141
disabled: true
142+
wsl_v5:
143+
allow-first-in-block: true
144+
allow-whole-block: false
145+
branch-max-lines: 2
139146
exclusions:
140147
generated: lax
141148
presets:

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
GO ?= go
1616

17-
GOLANGCI_LINT_VERSION = v2.1.6
17+
GOLANGCI_LINT_VERSION = v2.4.0
1818
REPO_INFRA_VERSION = v0.2.5
1919
KUSTOMIZE_VERSION = 5.5.0
2020
OPERATOR_SDK_VERSION ?= v1.37.0

dependencies.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
dependencies:
22
- name: golangci-lint
3-
version: 2.1.6
3+
version: 2.4.0
44
refPaths:
55
- path: Makefile
66
match: GOLANGCI_LINT_VERSION
@@ -115,6 +115,12 @@ dependencies:
115115
- path: hack/install-libbpf.sh
116116
match: VERSION
117117

118+
- name: libelf
119+
version: 0.193
120+
refPaths:
121+
- path: hack/install-libelf.sh
122+
match: VERSION
123+
118124
- name: debian-vmlinux
119125
version: trixie
120126
refPaths:
@@ -174,11 +180,6 @@ dependencies:
174180
match: llvmPackages_\d+.clang-unwrapped
175181
- path: nix/derivation-bpf.nix
176182
match: llvm_\d+
177-
178-
# TODO: update to the latest clang of debian 12 packages are available.
179-
- name: clang-debian-12
180-
version: 16
181-
refPaths:
182183
- path: hack/pull-security-profiles-operator-verify
183184
match: CLANG_VERSION
184185

hack/install-libelf.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2025 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
set -euo pipefail
17+
18+
# TODO: remove this script once the debian image (via golang:1.25 or higher) ships
19+
# the fixed libelf version.
20+
#
21+
apt-get install -y \
22+
bzip2 \
23+
m4 \
24+
zlib1g-dev
25+
26+
VERSION=0.193
27+
curl -sSfL --retry 5 --retry-delay 3 \
28+
"https://sourceware.org/elfutils/ftp/$VERSION/elfutils-$VERSION.tar.bz2" -o- |
29+
tar xfj -
30+
31+
DIR="elfutils-$VERSION"
32+
trap 'rm -rf -- "$DIR"' EXIT
33+
34+
pushd "$DIR"
35+
./configure --prefix=/usr
36+
make install -j8
37+
popd

hack/install-packages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ set -euo pipefail
55
apt-get update
66
apt-get install -y \
77
libapparmor-dev \
8-
libelf-dev \
98
libseccomp-dev \
109
libzstd-dev
1110

11+
./hack/install-libelf.sh
1212
./hack/install-libbpf.sh

hack/pull-security-profiles-operator-verify

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ set -euo pipefail
33

44
./hack/install-packages
55

6-
CLANG_VERSION=16
7-
apt-get install -y software-properties-common
6+
CLANG_VERSION=18
7+
apt-get install -y lsb-release
88
curl -sSfL --retry 5 --retry-delay 3 https://apt.llvm.org/llvm.sh | bash -s -- $CLANG_VERSION all
99
ln -sf /usr/bin/clang-format-$CLANG_VERSION /usr/bin/clang-format
1010

internal/pkg/bimap/bimap.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ func (m *BiMap[K, V]) ExistsBackwards(v V) bool {
7676
func (m *BiMap[K, V]) Get(k K) (V, bool) {
7777
m.l.RLock()
7878
defer m.l.RUnlock()
79+
7980
v, ok := m.forward[k]
8081

8182
return v, ok
@@ -85,6 +86,7 @@ func (m *BiMap[K, V]) Get(k K) (V, bool) {
8586
func (m *BiMap[K, V]) GetBackwards(v V) (K, bool) {
8687
m.l.RLock()
8788
defer m.l.RUnlock()
89+
8890
k, ok := m.backward[v]
8991

9092
return k, ok
@@ -99,6 +101,7 @@ func (m *BiMap[K, V]) Delete(k K) {
99101

100102
m.l.Lock()
101103
defer m.l.Unlock()
104+
102105
delete(m.forward, k)
103106
delete(m.backward, v)
104107
}
@@ -112,6 +115,7 @@ func (m *BiMap[K, V]) DeleteBackwards(v V) {
112115

113116
m.l.Lock()
114117
defer m.l.Unlock()
118+
115119
delete(m.forward, k)
116120
delete(m.backward, v)
117121
}

internal/pkg/cli/runner/runner_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ func TestStartEnricher(t *testing.T) {
300300
sut.impl = mock
301301

302302
go sut.startEnricher()
303+
303304
assert(mock, lineChan)
304305
})
305306
}

internal/pkg/daemon/bpfrecorder/bpfrecorder.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -613,6 +613,7 @@ func (b *BpfRecorder) loadPrograms(programNames []string) error {
613613
func (b *BpfRecorder) StartRecording() (err error) {
614614
b.attachUnattachMutex.Lock()
615615
defer b.attachUnattachMutex.Unlock()
616+
616617
b.logger.Info("Start BPF recording...")
617618

618619
if b.module == nil {
@@ -650,6 +651,7 @@ func (b *BpfRecorder) StartRecording() (err error) {
650651
func (b *BpfRecorder) StopRecording() error {
651652
b.attachUnattachMutex.Lock()
652653
defer b.attachUnattachMutex.Unlock()
654+
653655
b.logger.Info("Stop BPF recording: Detaching all programs...")
654656

655657
if err := b.UpdateValue(b.isRecordingBpfMap, 0, []byte{1}); err != nil {
@@ -868,6 +870,7 @@ func (b *BpfRecorder) handleExitEvent(exitEvent *bpfEvent) {
868870

869871
return
870872
}
873+
871874
select {
872875
case <-done:
873876
// already closed

internal/pkg/daemon/bpfrecorder/bpfrecorder_apparmor.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,10 @@ func (b *AppArmorRecorder) StartRecording(r *BpfRecorder) error {
142142
func (b *AppArmorRecorder) StopRecording(r *BpfRecorder) error {
143143
b.lockRecordedSocketsUse.Lock()
144144
defer b.lockRecordedSocketsUse.Unlock()
145+
145146
b.lockRecordedCapabilities.Lock()
146147
defer b.lockRecordedCapabilities.Unlock()
148+
147149
b.lockRecordedFiles.Lock()
148150
defer b.lockRecordedFiles.Unlock()
149151

@@ -239,8 +241,10 @@ func (b *AppArmorRecorder) handleCapabilityEvent(capEvent *bpfEvent) {
239241
func (b *AppArmorRecorder) clearMntns(event *bpfEvent) {
240242
b.lockRecordedFiles.Lock()
241243
defer b.lockRecordedFiles.Unlock()
244+
242245
b.lockRecordedCapabilities.Lock()
243246
defer b.lockRecordedCapabilities.Unlock()
247+
244248
b.lockRecordedSocketsUse.Lock()
245249
defer b.lockRecordedSocketsUse.Unlock()
246250

@@ -254,8 +258,10 @@ func (b *AppArmorRecorder) clearMntns(event *bpfEvent) {
254258
func (b *AppArmorRecorder) GetKnownMntns() []mntnsID {
255259
b.lockRecordedFiles.Lock()
256260
defer b.lockRecordedFiles.Unlock()
261+
257262
b.lockRecordedCapabilities.Lock()
258263
defer b.lockRecordedCapabilities.Unlock()
264+
259265
b.lockRecordedSocketsUse.Lock()
260266
defer b.lockRecordedSocketsUse.Unlock()
261267

0 commit comments

Comments
 (0)