Skip to content

Commit 180b9e5

Browse files
committed
rebase branch and resolve conflicts
Signed-off-by: Ashima-Ashima1 <[email protected]>
2 parents 2b7e8ac + 42d5c47 commit 180b9e5

14 files changed

+278
-331
lines changed

.secrets.baseline

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"files": "go.sum|^.secrets.baseline$",
44
"lines": null
55
},
6-
"generated_at": "2024-06-03T02:29:46Z",
6+
"generated_at": "2024-06-03T09:31:24Z",
77
"plugins_used": [
88
{
99
"name": "AWSKeyDetector"

pkg/config/constants.go renamed to controllers/constants/constants.go

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,24 @@
1-
// Package config ...
2-
package config
1+
// Package constants ...
2+
package constants
33

4-
import "time"
4+
import (
5+
"fmt"
6+
"time"
7+
)
58

6-
// Add a field here if it never changes, if it changes over time, put it to settings.go
79
const (
8-
APIGroup = "objectdriver.csi.ibm.com"
10+
APIGroup = "objectdriver.csi.ibm.com"
11+
912
APIVersion = "v1"
1013
CSIOperatorName = "ibm-object-csi-driver-operator"
1114
CSIDriverName = "ibm-object-csi-driver"
1215
DriverName = "cos.s3.csi.ibm.io"
13-
ProductName = "ibm-object-csi-driver"
1416

1517
RbacAuthorizationAPIGroup = "rbac.authorization.k8s.io"
1618
SecurityOpenshiftAPIGroup = "security.openshift.io"
1719
StorageAPIGroup = "storage.k8s.io"
1820

19-
CsiNodesResource = "csinodes"
21+
CSINodesResource = "csinodes"
2022
SecretsResource = "secrets"
2123
SecurityContextConstraintsResource = "securitycontextconstraints"
2224
StorageClassesResource = "storageclasses"
@@ -45,6 +47,38 @@ const (
4547
NodeRegistrarSocketPath = "/var/lib/kubelet/plugins/cos.s3.csi.ibm.io/csi.sock"
4648
CSIEndpoint = "unix:///var/lib/csi/sockets/pluginproxy/csi.sock"
4749
CSINodeEndpoint = "unix:///csi/csi.sock"
50+
RegistrationVolumeMountPath = "/registration"
51+
52+
NodeContainerName = "ibm-object-csi-node"
53+
ControllerContainerName = "ibm-object-csi-controller"
54+
55+
RegistrationVolumeName = "registration-dir"
56+
PluginVolumeName = "plugin-dir"
57+
SocketVolumeName = "socket-dir"
58+
59+
HealthPortName = "healthz"
60+
HealthPortNumber = 9808
61+
62+
DriverPrefix = "ibm-object-csi"
63+
64+
CSIController = "controller"
65+
CSINode = "node"
66+
CSIControllerServiceAccount = "controller-sa"
67+
CSINodeServiceAccount = "node-sa"
68+
ExternalProvisionerClusterRole = "external-provisioner-clusterrole"
69+
ExternalProvisionerClusterRoleBinding = "external-provisioner-clusterrolebinding"
70+
CSIControllerSCCClusterRole = "controller-scc-clusterrole"
71+
CSIControllerSCCClusterRoleBinding = "controller-scc-clusterrolebinding"
72+
CSINodeSCCClusterRole = "node-scc-clusterrole"
73+
CSINodeSCCClusterRoleBinding = "node-scc-clusterrolebinding"
74+
75+
StorageClassPrefix = "ibm-object-storage-"
76+
StorageClassSuffix = "-sc"
77+
78+
RcloneRetainStorageClass = StorageClassPrefix + "rclone-retain" + StorageClassSuffix
79+
RcloneStorageClass = StorageClassPrefix + "rclone" + StorageClassSuffix
80+
S3fsRetainStorageClass = StorageClassPrefix + "s3fs-retain" + StorageClassSuffix
81+
S3fsStorageClass = StorageClassPrefix + "s3fs" + StorageClassSuffix
4882

4983
DefaultLogTailLines = 300
5084
DefaultNamespace = "default"
@@ -56,3 +90,8 @@ var CommonCSIResourceLabels = map[string]string{
5690
"app.kubernetes.io/part-of": CSIDriverName,
5791
"app.kubernetes.io/managed-by": CSIOperatorName,
5892
}
93+
94+
// GetResourceName returns the name of a resource for a CSI driver
95+
func GetResourceName(name string) string {
96+
return fmt.Sprintf("%s-%s", DriverPrefix, name)
97+
}

controllers/ibmobjectcsi_controller.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import (
2525
"time"
2626

2727
objectdriverv1alpha1 "github.com/IBM/ibm-object-csi-driver-operator/api/v1alpha1"
28+
"github.com/IBM/ibm-object-csi-driver-operator/controllers/constants"
2829
crutils "github.com/IBM/ibm-object-csi-driver-operator/controllers/internal/crutils"
2930
clustersyncer "github.com/IBM/ibm-object-csi-driver-operator/controllers/syncer"
3031
"github.com/IBM/ibm-object-csi-driver-operator/controllers/util/common"
31-
oconfig "github.com/IBM/ibm-object-csi-driver-operator/pkg/config"
3232
oversion "github.com/IBM/ibm-object-csi-driver-operator/version"
3333
"github.com/go-logr/logr"
3434
"github.com/presslabs/controller-util/pkg/syncer"
@@ -279,7 +279,7 @@ func (r *IBMObjectCSIReconciler) isNodeReady(node *appsv1.DaemonSet) bool {
279279
func (r *IBMObjectCSIReconciler) getNodeDaemonSet(instance *crutils.IBMObjectCSI) (*appsv1.DaemonSet, error) {
280280
node := &appsv1.DaemonSet{}
281281
err := r.Get(context.TODO(), types.NamespacedName{
282-
Name: oconfig.GetNameForResource(oconfig.CSINode, oconfig.DriverPrefix),
282+
Name: constants.GetResourceName(constants.CSINode),
283283
Namespace: instance.Namespace,
284284
}, node)
285285
return node, err
@@ -288,7 +288,7 @@ func (r *IBMObjectCSIReconciler) getNodeDaemonSet(instance *crutils.IBMObjectCSI
288288
func (r *IBMObjectCSIReconciler) getControllerDeployment(instance *crutils.IBMObjectCSI) (*appsv1.Deployment, error) {
289289
controllerDeployment := &appsv1.Deployment{}
290290
err := r.Get(context.TODO(), types.NamespacedName{
291-
Name: oconfig.GetNameForResource(oconfig.CSIController, oconfig.DriverPrefix),
291+
Name: constants.GetResourceName(constants.CSIController),
292292
Namespace: instance.Namespace,
293293
}, controllerDeployment)
294294
return controllerDeployment, err
@@ -315,8 +315,8 @@ func (r *IBMObjectCSIReconciler) reconcileServiceAccount(instance *crutils.IBMOb
315315
controller := instance.GenerateControllerServiceAccount()
316316
node := instance.GenerateNodeServiceAccount()
317317

318-
controllerServiceAccountName := oconfig.GetNameForResource(oconfig.CSIControllerServiceAccount, oconfig.DriverPrefix)
319-
nodeServiceAccountName := oconfig.GetNameForResource(oconfig.CSINodeServiceAccount, oconfig.DriverPrefix)
318+
controllerServiceAccountName := constants.GetResourceName(constants.CSIControllerServiceAccount)
319+
nodeServiceAccountName := constants.GetResourceName(constants.CSINodeServiceAccount)
320320

321321
for _, sa := range []*corev1.ServiceAccount{
322322
controller,
@@ -370,7 +370,7 @@ func (r *IBMObjectCSIReconciler) reconcileServiceAccount(instance *crutils.IBMOb
370370
}
371371

372372
func (r *IBMObjectCSIReconciler) rolloutRestartNode(node *appsv1.DaemonSet) error {
373-
restartedAt := fmt.Sprintf("%s/restartedAt", oconfig.APIGroup)
373+
restartedAt := fmt.Sprintf("%s/restartedAt", constants.APIGroup)
374374
timestamp := time.Now().String()
375375
node.Spec.Template.ObjectMeta.Annotations[restartedAt] = timestamp
376376
return r.Update(context.TODO(), node)
@@ -469,11 +469,11 @@ func (r *IBMObjectCSIReconciler) getClusterRoleBindings(instance *crutils.IBMObj
469469
}
470470

471471
func (r *IBMObjectCSIReconciler) getStorageClasses(instance *crutils.IBMObjectCSI) []*storagev1.StorageClass {
472-
rcloneRetainSC := instance.GenerateRcloneSC(oconfig.RcloneRetainStorageClass, corev1.PersistentVolumeReclaimRetain)
473-
rcloneSC := instance.GenerateRcloneSC(oconfig.RcloneStorageClass, corev1.PersistentVolumeReclaimDelete)
472+
rcloneRetainSC := instance.GenerateRcloneSC(constants.RcloneRetainStorageClass, corev1.PersistentVolumeReclaimRetain)
473+
rcloneSC := instance.GenerateRcloneSC(constants.RcloneStorageClass, corev1.PersistentVolumeReclaimDelete)
474474

475-
s3fsRetainSC := instance.GenerateS3fsSC(oconfig.S3fsRetainStorageClass, corev1.PersistentVolumeReclaimRetain)
476-
s3fsSC := instance.GenerateS3fsSC(oconfig.S3fsStorageClass, corev1.PersistentVolumeReclaimDelete)
475+
s3fsRetainSC := instance.GenerateS3fsSC(constants.S3fsRetainStorageClass, corev1.PersistentVolumeReclaimRetain)
476+
s3fsSC := instance.GenerateS3fsSC(constants.S3fsStorageClass, corev1.PersistentVolumeReclaimDelete)
477477

478478
return []*storagev1.StorageClass{
479479
rcloneRetainSC,

0 commit comments

Comments
 (0)