Skip to content

Commit

Permalink
[ISSUE-221] dependencies upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalw82 authored Apr 4, 2024
1 parent 178c50f commit b69a72b
Show file tree
Hide file tree
Showing 12 changed files with 278 additions and 1,358 deletions.
4 changes: 3 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ linters-settings:
- k8s.io/client-go/util/workqueue
- k8s.io/kube-scheduler/extender/v1
- k8s.io/utils/keymutex
- k8s.io/utils/pointer
- k8s.io/utils/ptr
- sigs.k8s.io/controller-runtime
- sigs.k8s.io/controller-runtime/pkg/cache
- sigs.k8s.io/controller-runtime/pkg/client
Expand All @@ -100,6 +100,8 @@ linters-settings:
- sigs.k8s.io/controller-runtime/pkg/source
- sigs.k8s.io/controller-runtime/pkg/reconcile
- sigs.k8s.io/controller-runtime/pkg/log/zap
- sigs.k8s.io/controller-runtime/pkg/metrics/server
- sigs.k8s.io/controller-runtime/pkg/webhook
test:
files:
- "$test"
Expand Down
4 changes: 3 additions & 1 deletion api/v1/components/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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
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,
Expand All @@ -27,4 +27,6 @@ type ResourceRequirements struct {
// +nullable
// +optional
Requests corev1.ResourceList `json:"requests,omitempty"`
// +optional
Claims []corev1.ResourceClaim `json:"claims,omitempty" protobuf:"bytes,3,opt,name=claims"`
}
49 changes: 19 additions & 30 deletions controllers/deployment_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,39 +133,32 @@ func (r *DeploymentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
return err
}

err = c.Watch(&source.Kind{Type: &csibaremetalv1.Deployment{}}, &handler.EnqueueRequestForObject{})
err = c.Watch(source.Kind(mgr.GetCache(), &csibaremetalv1.Deployment{}), &handler.EnqueueRequestForObject{})
if err != nil {
return err
}

err = c.Watch(&source.Kind{Type: &appsv1.Deployment{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &csibaremetalv1.Deployment{},
})
err = c.Watch(source.Kind(mgr.GetCache(), &appsv1.Deployment{}),
handler.EnqueueRequestForOwner(r.Scheme, mgr.GetRESTMapper(), &csibaremetalv1.Deployment{}, handler.OnlyControllerOwner()))
if err != nil {
return err
}

err = c.Watch(&source.Kind{Type: &appsv1.DaemonSet{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &csibaremetalv1.Deployment{},
})
err = c.Watch(source.Kind(mgr.GetCache(), &appsv1.DaemonSet{}),
handler.EnqueueRequestForOwner(r.Scheme, mgr.GetRESTMapper(), &csibaremetalv1.Deployment{}, handler.OnlyControllerOwner()))
if err != nil {
return err
}

err = c.Watch(&source.Kind{Type: &corev1.ConfigMap{}}, &handler.EnqueueRequestForOwner{
IsController: true,
OwnerType: &csibaremetalv1.Deployment{},
})
err = c.Watch(source.Kind(mgr.GetCache(), &corev1.ConfigMap{}),
handler.EnqueueRequestForOwner(r.Scheme, mgr.GetRESTMapper(), &csibaremetalv1.Deployment{}, handler.OnlyControllerOwner()))
if err != nil {
return err
}

// reconcile CSI Deployment if kube-scheduler or openshift secondary-scheduler pods were changed
err = c.Watch(&source.Kind{Type: &corev1.Pod{}}, handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Pod{}), handler.EnqueueRequestsFromMapFunc(handler.MapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
var (
ctx = context.Background()
deployments = &csibaremetalv1.DeploymentList{}
pod *corev1.Pod
ok bool
Expand Down Expand Up @@ -204,15 +197,14 @@ func (r *DeploymentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
}

return requests
}))
})))
if err != nil {
return err
}

// reconcile CSI Deployment if node was creates, node kernel-version or label were changed
err = c.Watch(&source.Kind{Type: &corev1.Node{}}, handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
err = c.Watch(source.Kind(mgr.GetCache(), &corev1.Node{}), handler.EnqueueRequestsFromMapFunc(handler.MapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
var (
ctx = context.Background()
deployments = &csibaremetalv1.DeploymentList{}
node *corev1.Node
ok bool
Expand Down Expand Up @@ -246,7 +238,7 @@ func (r *DeploymentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
}

return requests
}), predicate.Or(predicate.Funcs{
})), predicate.Or(predicate.Funcs{
UpdateFunc: func(updateEvent event.UpdateEvent) bool {
return isNodeChanged(updateEvent.ObjectOld, updateEvent.ObjectNew)
},
Expand All @@ -255,11 +247,11 @@ func (r *DeploymentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma
return err
}

if err = watchRole(c, r.Client, r.Matcher, r.MatchPodSecurityPolicyTemplate, r.MatchSecurityContextConstraintsPolicies, r.Log); err != nil {
if err = watchRole(c, r.Client, r.Matcher, r.MatchPodSecurityPolicyTemplate, r.MatchSecurityContextConstraintsPolicies, r.Log, mgr); err != nil {
return err
}

if err = watchRoleBinding(c, r.Client, r.Matcher, r.Log); err != nil {
if err = watchRoleBinding(c, r.Client, r.Matcher, r.Log, mgr); err != nil {
return err
}

Expand All @@ -275,11 +267,9 @@ func (r *DeploymentReconciler) SetupWithManager(ctx context.Context, mgr ctrl.Ma

func watchRole(c controller.Controller, cl client.Client, m rbac.Matcher,
matchPodSecurityPolicyTemplate rbacv1.PolicyRule, matchSecurityContextConstraintsPolicies []rbacv1.PolicyRule,
log *logrus.Entry,
) error {
return c.Watch(&source.Kind{Type: &rbacv1.Role{}}, handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
log *logrus.Entry, mgr ctrl.Manager) error {
return c.Watch(source.Kind(mgr.GetCache(), &rbacv1.Role{}), handler.EnqueueRequestsFromMapFunc(handler.MapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
var (
ctx = context.Background()
deployments = &csibaremetalv1.DeploymentList{}
role = &rbacv1.Role{}
ok bool
Expand Down Expand Up @@ -335,13 +325,12 @@ func watchRole(c controller.Controller, cl client.Client, m rbac.Matcher,
},
},
}
}))
})))
}

func watchRoleBinding(c controller.Controller, cl client.Client, m rbac.Matcher, log *logrus.Entry) error {
return c.Watch(&source.Kind{Type: &rbacv1.RoleBinding{}}, handler.EnqueueRequestsFromMapFunc(func(obj client.Object) []reconcile.Request {
func watchRoleBinding(c controller.Controller, cl client.Client, m rbac.Matcher, log *logrus.Entry, mgr ctrl.Manager) error {
return c.Watch(source.Kind(mgr.GetCache(), &rbacv1.RoleBinding{}), handler.EnqueueRequestsFromMapFunc(handler.MapFunc(func(ctx context.Context, obj client.Object) []reconcile.Request {
var (
ctx = context.Background()
deployments = &csibaremetalv1.DeploymentList{}
roleBinding = &rbacv1.RoleBinding{}
ok bool
Expand Down Expand Up @@ -394,7 +383,7 @@ func watchRoleBinding(c controller.Controller, cl client.Client, m rbac.Matcher,
},
},
}
}))
})))
}

func isNodeChanged(old runtime.Object, new runtime.Object) bool {
Expand Down
126 changes: 61 additions & 65 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,89 +4,85 @@ go 1.21

require (
github.com/Masterminds/semver v1.5.0 // indirect
github.com/dell/csi-baremetal v1.3.0
github.com/go-logr/logr v1.2.3 // indirect
github.com/dell/csi-baremetal v1.6.2
github.com/go-logr/logr v1.4.1 // indirect
github.com/masterminds/semver v1.5.0
github.com/openshift/api v0.0.0-20211214190212-1a67f3bd14ec
github.com/openshift/secondary-scheduler-operator v0.0.0-20220920094845-c6fe67f922d6
github.com/sirupsen/logrus v1.8.1
github.com/stretchr/testify v1.8.0
github.com/openshift/api v0.0.0-20240326215622-ff84c2c73227
github.com/openshift/secondary-scheduler-operator v0.0.0-20240308133249-89eae2bb67cb
github.com/sirupsen/logrus v1.9.3
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/api v0.25.15
k8s.io/apimachinery v0.25.15
k8s.io/client-go v0.25.15
k8s.io/utils v0.0.0-20220728103510-ee6ede2d64ed
sigs.k8s.io/controller-runtime v0.11.1
sigs.k8s.io/controller-tools v0.6.1
k8s.io/api v0.29.3
k8s.io/apimachinery v0.29.3
k8s.io/client-go v0.29.3
k8s.io/utils v0.0.0-20240310230437-4693a0247e57
sigs.k8s.io/controller-runtime v0.17.2
sigs.k8s.io/controller-tools v0.11.2
)

require (
cloud.google.com/go/compute v1.23.0 // indirect
cloud.google.com/go/compute/metadata v0.2.3 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.8.0 // indirect
github.com/evanphx/json-patch v4.12.0+incompatible // indirect
github.com/fatih/color v1.12.0 // indirect
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/go-logr/zapr v1.2.0 // indirect
github.com/go-openapi/jsonpointer v0.19.5 // indirect
github.com/go-openapi/jsonreference v0.19.5 // indirect
github.com/go-openapi/swag v0.19.14 // indirect
github.com/gobuffalo/flect v0.2.3 // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/color v1.13.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/zapr v1.3.0 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/gobuffalo/flect v0.3.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.5.7-v3refs // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/gnostic-models v0.6.9-0.20230804172637-c7be7c783f49 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/mattn/go-isatty v0.0.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/prometheus/client_golang v1.13.0 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/spf13/cobra v1.2.1 // indirect
github.com/prometheus/client_golang v1.19.0 // indirect
github.com/prometheus/client_model v0.6.0 // indirect
github.com/prometheus/common v0.51.1 // indirect
github.com/prometheus/procfs v0.13.0 // indirect
github.com/spf13/cobra v1.7.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/stretchr/objx v0.4.0 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
go.uber.org/zap v1.19.1 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/term v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
golang.org/x/tools v0.6.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
github.com/stretchr/objx v0.5.2 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.27.0 // indirect
golang.org/x/exp v0.0.0-20240325151524-a685a6edb6d8 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/oauth2 v0.18.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.19.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240325203815-454cdb8f5daa // indirect
google.golang.org/grpc v1.62.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/apiextensions-apiserver v0.23.0 // indirect
k8s.io/component-base v0.23.4 // indirect
k8s.io/klog/v2 v2.70.1 // indirect
k8s.io/kube-openapi v0.0.0-20220803162953-67bda5d908f1 // indirect
sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.3.0 // indirect
k8s.io/apiextensions-apiserver v0.29.3 // indirect
k8s.io/component-base v0.29.3 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240322212309-b815d8309940 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
Loading

0 comments on commit b69a72b

Please sign in to comment.