Skip to content

Commit 8e91d9e

Browse files
authored
Upgrade Kubernetes runtime and tooling dependencies (#999)
* chore(vendor): update all vendor dependencies Updates all vendor dependencies following the sync-dependencies script execution to ensure consistency across the codebase. Jira: CHAOSPLT-1244
1 parent 33a8324 commit 8e91d9e

File tree

5,567 files changed

+456912
-230569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

5,567 files changed

+456912
-230569
lines changed

.circleci/config.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ commands:
3131
name: Install Python requirements
3232
command: pip3 install -r tasks/requirements.txt
3333
ubuntu_install_python:
34-
description: Install python3.10
34+
description: Install python3.12
3535
steps:
3636
- run:
37-
name: Install python 3.10
38-
command: sudo apt update && sudo apt install python3.10 python3.10-venv
37+
name: Install python 3.12
38+
command: sudo apt update && sudo apt install python3.12 python3.12-venv
3939
alpine_install_git:
4040
description: Install required dependencies
4141
steps:
@@ -86,7 +86,7 @@ executors:
8686
docker:
8787
# This is circle ci images, provides default tool installed (like docker) to ease step definition and avoid apt-get/update things
8888
# https://circleci.com/docs/circleci-images/#next-gen-language-images
89-
- image: cimg/go:1.23.1
89+
- image: cimg/go:1.24.7
9090
resource_class: 2xlarge
9191
python:
9292
<<: *working_directory

.golangci.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ linters:
3939
- gocritic
4040
issues:
4141
exclude-use-default: false
42+
exclude-dirs:
43+
- mocks
44+
exclude-files:
45+
- ".*mock.*\\.go$"
4246
exclude:
4347
# gosec
4448
- Subprocess launch(ed with variable|ing should be audited)

.vendor.mockery.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ packages:
3939
Informer:
4040
config:
4141
mockname: CacheInformerMock
42+
Cache:
43+
config:
44+
mockname: CacheCacheMock
4245
sigs.k8s.io/controller-runtime/pkg/source:
4346
interfaces:
4447
SyncingSource:

LICENSE-3rdparty.csv

Lines changed: 302 additions & 131 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GOARCH = $(shell go env GOARCH)
88

99
# change also circleci go build version "cimb/go:" if you change the version below
1010
# https://github.com/DataDog/chaos-controller/blob/main/.circleci/config.yml#L85
11-
BUILDGOVERSION = 1.23.1
11+
BUILDGOVERSION = 1.25.3
1212

1313
# GOBIN can be provided (gitlab), defined (custom user setup), or empty/guessed (default go setup)
1414
GOBIN ?= $(shell go env GOBIN)
@@ -56,18 +56,17 @@ PROTOC_ZIP = protoc-${PROTOC_VERSION}-${PROTOC_OS}-x86_64.zip
5656
# you might also want to change ~/lima.yaml k3s version
5757
KUBERNETES_MAJOR_VERSION ?= 1.28
5858
KUBERNETES_VERSION ?= v$(KUBERNETES_MAJOR_VERSION).0
59-
KUBEBUILDER_VERSION ?= 3.1.0
6059
USE_VOLUMES ?= false
6160

6261
HELM_VALUES ?= dev.yaml
63-
HELM_VERSION = v3.11.3
62+
HELM_VERSION = v3.19.0
6463
HELM_INSTALLED_VERSION = $(shell (helm version --template="{{ .Version }}" || echo "") | awk '{ print $$1 }')
6564

6665
# TODO: reenable depguard in .golangci.yml after upgrading golangci-lint again
67-
GOLANGCI_LINT_VERSION = 1.61.0
66+
GOLANGCI_LINT_VERSION = 1.64.8
6867
GOLANGCI_LINT_INSTALLED_VERSION = $(shell (golangci-lint --version || echo "") | sed -E 's/.*version ([^ ]+).*/\1/')
6968

70-
CONTROLLER_GEN_VERSION = v0.14.0
69+
CONTROLLER_GEN_VERSION = v0.19.0
7170
CONTROLLER_GEN_INSTALLED_VERSION = $(shell (controller-gen --version || echo "") | awk '{ print $$2 }')
7271

7372
MOCKERY_VERSION = 2.53.5
@@ -304,7 +303,7 @@ vet:
304303
lint: install-golangci-lint
305304
# By using GOOS=linux we aim to validate files as if we were on linux
306305
# you can use a similar trick with gopls to have vs-code linting your linux platform files instead of darwin
307-
GOOS=linux golangci-lint run --no-config -E ginkgolinter ./...
306+
GOOS=linux golangci-lint run -E ginkgolinter ./...
308307
GOOS=linux golangci-lint run
309308

310309
## Generate code

api/v1beta1/disruption_cron_types.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99
"fmt"
1010
"time"
1111

12-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
13-
1412
tagutil "github.com/DataDog/chaos-controller/o11y/tags"
13+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1514
)
1615

1716
func init() {

api/v1beta1/disruption_cron_webhook.go

Lines changed: 76 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/robfig/cron"
1616
"go.uber.org/zap"
17+
"golang.org/x/net/context"
1718
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
1819
"k8s.io/apimachinery/pkg/labels"
1920
"k8s.io/apimachinery/pkg/runtime"
@@ -65,40 +66,61 @@ func (d *DisruptionCron) SetupWebhookWithManager(setupWebhookConfig utils.SetupW
6566
defaultDuration = setupWebhookConfig.DefaultDurationFlag
6667

6768
return ctrl.NewWebhookManagedBy(setupWebhookConfig.Manager).
69+
WithDefaulter(&DisruptionCron{}).
70+
WithValidator(&DisruptionCron{}).
6871
For(d).
6972
Complete()
7073
}
7174

7275
//+kubebuilder:webhook:webhookVersions={v1},path=/mutate-chaos-datadoghq-com-v1beta1-disruptioncron,mutating=true,failurePolicy=fail,sideEffects=None,groups=chaos.datadoghq.com,resources=disruptioncrons,verbs=create;update,versions=v1beta1,name=mdisruptioncron.kb.io,admissionReviewVersions={v1,v1beta1}
7376

74-
var _ webhook.Defaulter = &DisruptionCron{}
77+
var _ webhook.CustomDefaulter = &DisruptionCron{}
7578

76-
// Default implements webhook.Defaulter so a webhook will be registered for the type
77-
func (d *DisruptionCron) Default() {
78-
if d.Spec.DelayedStartTolerance.Duration() == 0 {
79-
logger.Infow(fmt.Sprintf("setting default delayedStartTolerance of %s in disruptionCron", defaultCronDelayedStartTolerance),
80-
tagutil.DisruptionCronNameKey, d.Name,
81-
tagutil.DisruptionCronNamespaceKey, d.Namespace,
79+
// Default implements webhook.CustomDefaulter so a webhook will be registered for the type
80+
func (d *DisruptionCron) Default(_ context.Context, obj runtime.Object) error {
81+
disruptionCronObj, ok := obj.(*DisruptionCron)
82+
if !ok {
83+
return fmt.Errorf("expected *DisruptionCron, got %T", obj)
84+
}
85+
86+
log := disruptionCronWebhookLogger.With(
87+
tagutil.DisruptionCronNameKey, disruptionCronObj.Name,
88+
tagutil.DisruptionCronNamespaceKey, disruptionCronObj.Namespace,
89+
)
90+
91+
log.Infow("defaulting disruption cron", tagutil.SpecKey, disruptionCronObj.Spec)
92+
93+
if disruptionCronObj.Spec.DelayedStartTolerance.Duration() == 0 {
94+
log.Infow(fmt.Sprintf("setting default delayedStartTolerance of %s in disruptionCron", defaultCronDelayedStartTolerance),
95+
tagutil.DisruptionCronNameKey, disruptionCronObj.Name,
96+
tagutil.DisruptionCronNamespaceKey, disruptionCronObj.Namespace,
8297
)
8398

84-
d.Spec.DelayedStartTolerance = DisruptionDuration(defaultCronDelayedStartTolerance.String())
99+
disruptionCronObj.Spec.DelayedStartTolerance = DisruptionDuration(defaultCronDelayedStartTolerance.String())
85100
}
101+
102+
return nil
86103
}
87104

88105
//+kubebuilder:webhook:webhookVersions={v1},path=/validate-chaos-datadoghq-com-v1beta1-disruptioncron,mutating=false,failurePolicy=fail,sideEffects=None,groups=chaos.datadoghq.com,resources=disruptioncrons,verbs=create;update;delete,versions=v1beta1,name=vdisruptioncron.kb.io,admissionReviewVersions={v1,v1beta1}
89106

90-
var _ webhook.Validator = &DisruptionCron{}
107+
var _ webhook.CustomValidator = &DisruptionCron{}
108+
109+
// ValidateCreate implements webhook.CustomValidator so a webhook will be registered for the type
110+
func (d *DisruptionCron) ValidateCreate(_ context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
111+
disruptionCronObj, ok := obj.(*DisruptionCron)
112+
if !ok {
113+
return nil, fmt.Errorf("expected *DisruptionCron, got %T", obj)
114+
}
91115

92-
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type
93-
func (d *DisruptionCron) ValidateCreate() (_ admission.Warnings, err error) {
94116
log := disruptionCronWebhookLogger.With(
95-
tagutil.DisruptionCronNameKey, d.Name,
96-
tagutil.DisruptionCronNamespaceKey, d.Namespace,
117+
tagutil.DisruptionCronNameKey, disruptionCronObj.Name,
118+
tagutil.DisruptionCronNamespaceKey, disruptionCronObj.Namespace,
97119
)
98120

99-
log.Infow("validating created disruption cron", tagutil.SpecKey, d.Spec)
121+
log.Infow("validating created disruption cron", tagutil.SpecKey, disruptionCronObj.Spec)
100122

101-
metricTags := d.getMetricsTags()
123+
metricTags := disruptionCronObj.getMetricsTags()
102124

103125
defer func() {
104126
if err != nil {
@@ -113,19 +135,19 @@ func (d *DisruptionCron) ValidateCreate() (_ admission.Warnings, err error) {
113135
return nil, errors.New("the controller is currently in delete-only mode, you can't create new disruption cron for now")
114136
}
115137

116-
if err = validateUserInfoGroup(d, disruptionCronPermittedUserGroups, disruptionCronPermittedUserGroupString); err != nil {
138+
if err = validateUserInfoGroup(disruptionCronObj, disruptionCronPermittedUserGroups, disruptionCronPermittedUserGroupString); err != nil {
117139
return nil, err
118140
}
119141

120-
if err = d.validateDisruptionCronName(); err != nil {
142+
if err = disruptionCronObj.validateDisruptionCronName(); err != nil {
121143
return nil, err
122144
}
123145

124-
if err = d.validateDisruptionCronSpec(); err != nil {
146+
if err = disruptionCronObj.validateDisruptionCronSpec(); err != nil {
125147
return nil, err
126148
}
127149

128-
if err = d.validateMinimumFrequency(minimumCronFrequency); err != nil {
150+
if err = disruptionCronObj.validateMinimumFrequency(minimumCronFrequency); err != nil {
129151
return nil, err
130152
}
131153

@@ -134,19 +156,30 @@ func (d *DisruptionCron) ValidateCreate() (_ admission.Warnings, err error) {
134156
}
135157

136158
// send informative event to disruption cron to broadcast
137-
d.emitEvent(EventDisruptionCronCreated)
159+
disruptionCronObj.emitEvent(EventDisruptionCronCreated)
138160

139161
return nil, nil
140162
}
141163

142-
func (d *DisruptionCron) ValidateUpdate(oldObject runtime.Object) (_ admission.Warnings, err error) {
143-
log := logger.With(
144-
tagutil.DisruptionCronNameKey, d.Name, tagutil.DisruptionCronNamespaceKey, d.Namespace,
164+
func (d *DisruptionCron) ValidateUpdate(_ context.Context, oldObj, newObj runtime.Object) (warnings admission.Warnings, err error) {
165+
newDisruptionCronObj, ok := newObj.(*DisruptionCron)
166+
if !ok {
167+
return nil, fmt.Errorf("expected *DisruptionCron, got %T", newObj)
168+
}
169+
170+
oldDisruptionCronObj, ok := oldObj.(*DisruptionCron)
171+
if !ok {
172+
return nil, fmt.Errorf("expected *DisruptionCron, got %T", oldObj)
173+
}
174+
175+
log := disruptionCronWebhookLogger.With(
176+
tagutil.DisruptionCronNameKey, newDisruptionCronObj.Name,
177+
tagutil.DisruptionCronNamespaceKey, newDisruptionCronObj.Namespace,
145178
)
146179

147-
log.Infow("validating updated disruption cron", tagutil.SpecKey, d.Spec)
180+
log.Infow("validating updated disruption cron", tagutil.SpecKey, newDisruptionCronObj.Spec)
148181

149-
metricTags := d.getMetricsTags()
182+
metricTags := newDisruptionCronObj.getMetricsTags()
150183

151184
defer func() {
152185
if err != nil {
@@ -156,23 +189,23 @@ func (d *DisruptionCron) ValidateUpdate(oldObject runtime.Object) (_ admission.W
156189
}
157190
}()
158191

159-
if err = validateUserInfoImmutable(oldObject.(*DisruptionCron), d); err != nil {
192+
if err = validateUserInfoImmutable(oldDisruptionCronObj, newDisruptionCronObj); err != nil {
160193
return nil, err
161194
}
162195

163-
if err = d.validateDisruptionCronName(); err != nil {
196+
if err = newDisruptionCronObj.validateDisruptionCronName(); err != nil {
164197
return nil, err
165198
}
166199

167-
if err = d.validateDisruptionCronSpec(); err != nil {
200+
if err = newDisruptionCronObj.validateDisruptionCronSpec(); err != nil {
168201
return nil, err
169202
}
170203

171204
// If a DisruptionCron is already more frequent than the minimum frequency, we don't want to
172205
// block updates on other parts of the spec or status. But if the schedule is being updated,
173206
// we do want to enforce that it happens more often than the minimum frequency
174-
if oldObject.(*DisruptionCron).Spec.Schedule != d.Spec.Schedule {
175-
if err := d.validateMinimumFrequency(minimumCronFrequency); err != nil {
207+
if oldDisruptionCronObj.Spec.Schedule != newDisruptionCronObj.Spec.Schedule {
208+
if err := newDisruptionCronObj.validateMinimumFrequency(minimumCronFrequency); err != nil {
176209
return nil, err
177210
}
178211
}
@@ -182,28 +215,33 @@ func (d *DisruptionCron) ValidateUpdate(oldObject runtime.Object) (_ admission.W
182215
}
183216

184217
// send informative event to disruption cron to broadcast
185-
d.emitEvent(EventDisruptionCronUpdated)
218+
newDisruptionCronObj.emitEvent(EventDisruptionCronUpdated)
186219

187220
return nil, nil
188221
}
189222

190-
func (d *DisruptionCron) ValidateDelete() (warnings admission.Warnings, err error) {
223+
func (d *DisruptionCron) ValidateDelete(_ context.Context, obj runtime.Object) (warnings admission.Warnings, err error) {
224+
disruptionCronObj, ok := obj.(*DisruptionCron)
225+
if !ok {
226+
return nil, fmt.Errorf("expected *DisruptionCron, got %T", obj)
227+
}
228+
191229
log := disruptionCronWebhookLogger.With(
192-
tagutil.DisruptionCronNameKey, d.Name,
193-
tagutil.DisruptionCronNamespaceKey, d.Namespace,
230+
tagutil.DisruptionCronNameKey, disruptionCronObj.Name,
231+
tagutil.DisruptionCronNamespaceKey, disruptionCronObj.Namespace,
194232
)
195233

196-
log.Infow("validating deleted disruption cron", tagutil.SpecKey, d.Spec)
234+
log.Infow("validating deleted disruption cron", tagutil.SpecKey, disruptionCronObj.Spec)
197235

198236
// During the validation of the deletion the timestamp does not exist so we need to set it before emitting the event
199-
d.DeletionTimestamp = &metav1.Time{Time: time.Now()}
237+
disruptionCronObj.DeletionTimestamp = &metav1.Time{Time: time.Now()}
200238

201-
if mErr := metricsSink.MetricValidationDeleted(d.getMetricsTags()); mErr != nil {
239+
if mErr := metricsSink.MetricValidationDeleted(disruptionCronObj.getMetricsTags()); mErr != nil {
202240
log.Errorw("error sending a metric", tagutil.ErrorKey, mErr)
203241
}
204242

205243
// send informative event to disruption cron to broadcast
206-
d.emitEvent(EventDisruptionCronDeleted)
244+
disruptionCronObj.emitEvent(EventDisruptionCronDeleted)
207245

208246
return nil, nil
209247
}

0 commit comments

Comments
 (0)