Skip to content

Commit

Permalink
controllers: Update code to match updated dependencies APIs
Browse files Browse the repository at this point in the history
Signed-off-by: Leela Venkaiah G <[email protected]>
  • Loading branch information
leelavg committed Oct 5, 2023
1 parent 2a05d8d commit 691410f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 32 deletions.
5 changes: 2 additions & 3 deletions controllers/clusterversion_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

//go:embed pvc-rules.yaml
Expand Down Expand Up @@ -93,7 +92,7 @@ func (c *ClusterVersionReconciler) SetupWithManager(mgr ctrl.Manager) error {
)
// Reconcile the ClusterVersion object when the operator config map is updated
enqueueClusterVersionRequest := handler.EnqueueRequestsFromMapFunc(
func(client client.Object) []reconcile.Request {
func(_ context.Context, client client.Object) []reconcile.Request {
return []reconcile.Request{{
NamespacedName: types.NamespacedName{
Name: clusterVersionName,
Expand All @@ -104,7 +103,7 @@ func (c *ClusterVersionReconciler) SetupWithManager(mgr ctrl.Manager) error {

return ctrl.NewControllerManagedBy(mgr).
For(&configv1.ClusterVersion{}, clusterVersionPredicates).
Watches(&source.Kind{Type: &corev1.ConfigMap{}}, enqueueClusterVersionRequest, configMapPredicates).
Watches(&corev1.ConfigMap{}, enqueueClusterVersionRequest, configMapPredicates).
Complete(c)
}

Expand Down
7 changes: 3 additions & 4 deletions controllers/storageclassclaim_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ import (
ctrllog "sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

const (
Expand All @@ -69,7 +68,7 @@ type StorageClassClaimReconciler struct {
// SetupWithManager sets up the controller with the Manager.
func (r *StorageClassClaimReconciler) SetupWithManager(mgr ctrl.Manager) error {
enqueueStorageConsumerRequest := handler.EnqueueRequestsFromMapFunc(
func(obj client.Object) []reconcile.Request {
func(_ context.Context, obj client.Object) []reconcile.Request {
annotations := obj.GetAnnotations()
if _, found := annotations[storageClassClaimAnnotation]; found {
return []reconcile.Request{{
Expand All @@ -84,8 +83,8 @@ func (r *StorageClassClaimReconciler) SetupWithManager(mgr ctrl.Manager) error {
For(&v1alpha1.StorageClassClaim{}, builder.WithPredicates(
predicate.GenerationChangedPredicate{},
)).
Watches(&source.Kind{Type: &storagev1.StorageClass{}}, enqueueStorageConsumerRequest).
Watches(&source.Kind{Type: &snapapi.VolumeSnapshotClass{}}, enqueueStorageConsumerRequest).
Watches(&storagev1.StorageClass{}, enqueueStorageConsumerRequest).
Watches(&snapapi.VolumeSnapshotClass{}, enqueueStorageConsumerRequest).
Complete(r)
}

Expand Down
5 changes: 2 additions & 3 deletions controllers/storageclient_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/log"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/controller-runtime/pkg/source"
)

const (
Expand Down Expand Up @@ -88,7 +87,7 @@ func (s *StorageClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
return res
})
enqueueStorageClientRequest := handler.EnqueueRequestsFromMapFunc(
func(obj client.Object) []reconcile.Request {
func(_ context.Context, obj client.Object) []reconcile.Request {
annotations := obj.GetAnnotations()
if _, found := annotations[storageClassClaimAnnotation]; found {
return []reconcile.Request{{
Expand All @@ -102,7 +101,7 @@ func (s *StorageClientReconciler) SetupWithManager(mgr ctrl.Manager) error {
s.recorder = utils.NewEventReporter(mgr.GetEventRecorderFor("controller_storageclient"))
return ctrl.NewControllerManagedBy(mgr).
For(&v1alpha1.StorageClient{}).
Watches(&source.Kind{Type: &v1alpha1.StorageClassClaim{}}, enqueueStorageClientRequest).
Watches(&v1alpha1.StorageClassClaim{}, enqueueStorageClientRequest).
Complete(s)
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/csi/cephfsdaemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -77,8 +77,8 @@ func GetCephFSDaemonSet(namespace string) *appsv1.DaemonSet {
Image: sidecarImages.ContainerImages.CephCSIImageURL,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(true),
Privileged: ptr.To(true),
AllowPrivilegeEscalation: ptr.To(true),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{
"SYS_ADMIN",
Expand Down
4 changes: 2 additions & 2 deletions pkg/csi/cephfsdeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

const (
Expand Down Expand Up @@ -68,7 +68,7 @@ func GetCephFSDeployment(namespace string) *appsv1.Deployment {
Labels: cephfsDeploymentLabels,
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(2),
Replicas: ptr.To(int32(2)),
Selector: &metav1.LabelSelector{
MatchLabels: cephfsDeploymentLabels,
},
Expand Down
12 changes: 6 additions & 6 deletions pkg/csi/rbddaemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var (
Expand Down Expand Up @@ -90,8 +90,8 @@ func GetRBDDaemonSet(namespace string) *appsv1.DaemonSet {
Image: sidecarImages.ContainerImages.CephCSIImageURL,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(true),
Privileged: ptr.To(true),
AllowPrivilegeEscalation: ptr.To(true),
Capabilities: &corev1.Capabilities{
Add: []corev1.Capability{
"SYS_ADMIN",
Expand Down Expand Up @@ -201,8 +201,8 @@ func GetRBDDaemonSet(namespace string) *appsv1.DaemonSet {
Image: sidecarImages.ContainerImages.CSIADDONSImageURL,
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(true),
Privileged: ptr.To(true),
AllowPrivilegeEscalation: ptr.To(true),
},
Args: []string{
"--node-id=$(NODE_ID)",
Expand Down Expand Up @@ -381,7 +381,7 @@ func GetRBDDaemonSet(namespace string) *appsv1.DaemonSet {
{
ServiceAccountToken: &corev1.ServiceAccountTokenProjection{
Path: "oidc-token",
ExpirationSeconds: pointer.Int64(3600),
ExpirationSeconds: ptr.To(int64(3600)),
Audience: "ceph-csi-kms",
},
},
Expand Down
6 changes: 3 additions & 3 deletions pkg/csi/rbddeployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var rbdDeploymentLabels = map[string]string{
Expand Down Expand Up @@ -67,7 +67,7 @@ func GetRBDDeployment(namespace string) *appsv1.Deployment {
Labels: rbdDeploymentLabels,
},
Spec: appsv1.DeploymentSpec{
Replicas: pointer.Int32(2),
Replicas: ptr.To(int32(2)),
Selector: &metav1.LabelSelector{
MatchLabels: rbdDeploymentLabels,
},
Expand Down Expand Up @@ -238,7 +238,7 @@ func GetRBDDeployment(namespace string) *appsv1.Deployment {
{
ServiceAccountToken: &corev1.ServiceAccountTokenProjection{
Path: "oidc-token",
ExpirationSeconds: pointer.Int64(3600),
ExpirationSeconds: ptr.To(int64(3600)),
Audience: "ceph-csi-kms",
},
},
Expand Down
10 changes: 5 additions & 5 deletions pkg/templates/csidriver.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package templates

import (
v1k8scsi "k8s.io/api/storage/v1"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var (
Expand All @@ -27,16 +27,16 @@ var (

var CephFSCSIDriver = &v1k8scsi.CSIDriver{
Spec: v1k8scsi.CSIDriverSpec{
AttachRequired: pointer.Bool(true),
PodInfoOnMount: pointer.Bool(false),
AttachRequired: ptr.To(true),
PodInfoOnMount: ptr.To(false),
FSGroupPolicy: &fileFSGroupPolicy,
},
}

var RbdCSIDriver = &v1k8scsi.CSIDriver{
Spec: v1k8scsi.CSIDriverSpec{
AttachRequired: pointer.Bool(true),
PodInfoOnMount: pointer.Bool(false),
AttachRequired: ptr.To(true),
PodInfoOnMount: ptr.To(false),
FSGroupPolicy: &fileFSGroupPolicy,
},
}
6 changes: 3 additions & 3 deletions pkg/templates/csisidecars.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"
)

var ProvisionerContainer = &corev1.Container{
Expand Down Expand Up @@ -147,8 +147,8 @@ var DriverRegistrar = &corev1.Container{
Name: "csi-driver-registrar",
ImagePullPolicy: corev1.PullIfNotPresent,
SecurityContext: &corev1.SecurityContext{
Privileged: pointer.Bool(true),
AllowPrivilegeEscalation: pointer.Bool(true),
Privileged: ptr.To(true),
AllowPrivilegeEscalation: ptr.To(true),
},
Args: []string{
fmt.Sprintf("--csi-address=%s", DefaultPluginSocketPath),
Expand Down

0 comments on commit 691410f

Please sign in to comment.