Skip to content

Commit

Permalink
Merge branch 'main' into ci-add-golangci-lint
Browse files Browse the repository at this point in the history
  • Loading branch information
jooseppi-luna authored Aug 4, 2023
2 parents 8d94477 + 1c44150 commit 0ebfb8e
Show file tree
Hide file tree
Showing 50 changed files with 5,070 additions and 269 deletions.
9 changes: 5 additions & 4 deletions bundle/manifests/dell-csm-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,10 @@ metadata:
"value": "debug"
}
],
"image": "dellemc/csi-powerstore:v2.7.0",
"image": "dellemc/csi-powerstore:v2.8.0",
"imagePullPolicy": "IfNotPresent"
},
"configVersion": "v2.7.0",
"configVersion": "v2.8.0",
"controller": {
"envs": [
{
Expand Down Expand Up @@ -736,7 +736,8 @@ metadata:
"tolerations": null
},
"csiDriverSpec": {
"fSGroupPolicy": "ReadWriteOnceWithFSType"
"fSGroupPolicy": "ReadWriteOnceWithFSType",
"storageCapacity": true
},
"csiDriverType": "unity",
"dnsPolicy": "ClusterFirstWithHostNet",
Expand Down Expand Up @@ -2345,7 +2346,7 @@ spec:
name: csi-powermax
- image: docker.io/dellemc/csipowermax-reverseproxy:v2.6.0
name: csipowermax-reverseproxy
- image: docker.io/dellemc/csi-powerstore:v2.7.0
- image: docker.io/dellemc/csi-powerstore:v2.8.0
name: csi-powerstore
- image: docker.io/dellemc/csi-unity:v2.7.0
name: csi-unity
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ spec:
name: csi-powermax
- image: docker.io/dellemc/csipowermax-reverseproxy:v2.6.0
name: csipowermax-reverseproxy
- image: docker.io/dellemc/csi-powerstore:v2.7.0
- image: docker.io/dellemc/csi-powerstore:v2.8.0
name: csi-powerstore
- image: docker.io/dellemc/csi-unity:v2.7.0
name: csi-unity
Expand Down
55 changes: 33 additions & 22 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ rules:
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
Expand Down Expand Up @@ -184,6 +185,7 @@ rules:
- orders
- orders/status
verbs:
- patch
- update
- apiGroups:
- acme.cert-manager.io
Expand Down Expand Up @@ -323,6 +325,7 @@ rules:
- certificaterequests/status
- certificates/status
verbs:
- patch
- update
- apiGroups:
- cert-manager.io
Expand All @@ -332,6 +335,7 @@ rules:
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
Expand All @@ -353,6 +357,7 @@ rules:
verbs:
- get
- list
- patch
- update
- watch
- apiGroups:
Expand All @@ -378,6 +383,7 @@ rules:
resources:
- certificatesigningrequests/status
verbs:
- patch
- update
- apiGroups:
- certificates.k8s.io
Expand Down Expand Up @@ -445,6 +451,33 @@ rules:
- get
- list
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- gateways
- httproutes
verbs:
- get
- list
- watch
- apiGroups:
- gateway.networking.k8s.io
resources:
- gateways/finalizers
- httproutes/finalizers
verbs:
- update
- apiGroups:
- gateway.networking.k8s.io
resources:
- httproutes
verbs:
- create
- delete
- get
- list
- update
- watch
- apiGroups:
- monitoring.coreos.com
resources:
Expand Down Expand Up @@ -484,28 +517,6 @@ rules:
- list
- update
- watch
- apiGroups:
- networking.x-k8s.io
resources:
- gateways
- httproutes
verbs:
- get
- list
- watch
- apiGroups:
- networking.x-k8s.io
resources:
- gateways/finalizers
- httproutes/finalizers
verbs:
- update
- apiGroups:
- networking.x-k8s.io
resources:
- httproutes
verbs:
- '*'
- apiGroups:
- rbac.authorization.k8s.io
resources:
Expand Down
10 changes: 10 additions & 0 deletions config/samples/storage_v1_csm_unity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ spec:
# Allowed values: ReadWriteOnceWithFSType, File , None
# Default value: ReadWriteOnceWithFSType
fSGroupPolicy: "ReadWriteOnceWithFSType"
# storageCapacity: Helps the scheduler to schedule the pod on a node satisfying the topology constraints, only if the requested capacity is available on the storage array
# Allowed values:
# true: enable storage capacity tracking
# false: disable storage capacity tracking
storageCapacity: true
# Config version for CSI Unity v2.8.0 driver
configVersion: v2.8.0
# Controller count
Expand Down Expand Up @@ -79,6 +84,11 @@ spec:
- name: external-health-monitor
enabled: false
args: ["--monitor-interval=60s"]
# Uncomment the following to configure how often external-provisioner polls the driver to detect changed capacity
# Configure when the storageCapacity is set as "true"
# Allowed values: 1m,2m,3m,...,10m,...,60m etc. Default value: 5m
#- name: provisioner
# args: ["--capacity-poll-interval=5m"]
controller:
envs:
# X_CSI_HEALTH_MONITOR_ENABLED: Enable/Disable health monitor of CSI volumes from Controller plugin - volume condition.
Expand Down
39 changes: 20 additions & 19 deletions controllers/csm_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ var (
// +kubebuilder:rbac:urls="/metrics",verbs=get
// +kubebuilder:rbac:groups="authentication.k8s.io",resources=tokenreviews,verbs=create
// +kubebuilder:rbac:groups="authorization.k8s.io",resources=subjectaccessreviews,verbs=create
// +kubebuilder:rbac:groups="cert-manager.io",resources=issuers;issuers/status,verbs=update;get;list;watch
// +kubebuilder:rbac:groups="cert-manager.io",resources=clusterissuers;clusterissuers/status,verbs=update;get;list;watch
// +kubebuilder:rbac:groups="cert-manager.io",resources=issuers;issuers/status,verbs=update;get;list;watch;patch
// +kubebuilder:rbac:groups="cert-manager.io",resources=clusterissuers;clusterissuers/status,verbs=update;get;list;watch;patch
// +kubebuilder:rbac:groups="cert-manager.io",resources=certificates;certificaterequests;clusterissuers;issuers,verbs=*
// +kubebuilder:rbac:groups="cert-manager.io",resources=certificates/finalizers;certificaterequests/finalizers,verbs=update
// +kubebuilder:rbac:groups="cert-manager.io",resources=certificates/status;certificaterequests/status,verbs=update
// +kubebuilder:rbac:groups="cert-manager.io",resources=certificates/status;certificaterequests/status,verbs=update;patch
// +kubebuilder:rbac:groups="cert-manager.io",resources=certificates;certificaterequests;issuers,verbs=create;delete;deletecollection;patch;update
// +kubebuilder:rbac:groups="cert-manager.io",resources=signers,resourceNames=issuers.cert-manager.io/*;clusterissuers.cert-manager.io/*,verbs=approve
// +kubebuilder:rbac:groups="cert-manager.io",resources=*/*,verbs=*
Expand All @@ -152,21 +152,21 @@ var (
// +kubebuilder:rbac:groups="coordination.k8s.io",resources=leases,resourceNames=cert-manager-controller,verbs=get;update;patch
// +kubebuilder:rbac:groups="coordination.k8s.io",resources=leases,verbs=create
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=orders,verbs=create;delete;get;list;watch
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=orders;orders/status,verbs=update
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=orders;orders/status,verbs=update;patch
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=orders;challenges,verbs=get;list;watch;create;delete;deletecollection;patch;update
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=clusterissuers;issuers,verbs=get;list;watch
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=challenges,verbs=create;delete
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=orders/finalizers,verbs=update
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=challenges;challenges/status,verbs=update;get;list;watch
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=challenges;challenges/status,verbs=update;get;list;watch;patch
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=challenges/finalizers,verbs=update
// +kubebuilder:rbac:groups="acme.cert-manager.io",resources=*/*,verbs=*
// +kubebuilder:rbac:groups="networking.k8s.io",resources=ingresses,verbs=*
// +kubebuilder:rbac:groups="networking.k8s.io",resources=ingresses/finalizers,verbs=update
// +kubebuilder:rbac:groups="networking.k8s.io",resources=ingressclasses,verbs=create;get;list;watch;update;delete
// +kubebuilder:rbac:groups="networking.k8s.io",resources=ingresses/status,verbs=update;get;list;watch
// +kubebuilder:rbac:groups="networking.x-k8s.io",resources=httproutes,verbs=*
// +kubebuilder:rbac:groups="networking.x-k8s.io",resources=httproutes;gateways,verbs=get;list;watch
// +kubebuilder:rbac:groups="networking.x-k8s.io",resources=gateways/finalizers;httproutes/finalizers,verbs=update
// +kubebuilder:rbac:groups="gateway.networking.k8s.io",resources=httproutes,verbs=get;list;watch;create;delete;update
// +kubebuilder:rbac:groups="gateway.networking.k8s.io",resources=httproutes;gateways,verbs=get;list;watch
// +kubebuilder:rbac:groups="gateway.networking.k8s.io",resources=gateways/finalizers;httproutes/finalizers,verbs=update
// +kubebuilder:rbac:groups="route.openshift.io",resources=routes/custom-host,verbs=create
// +kubebuilder:rbac:groups="admissionregistration.k8s.io",resources=validatingwebhookconfigurations;mutatingwebhookconfigurations,verbs=create;get;list;watch;update;delete;patch
// +kubebuilder:rbac:groups="apiregistration.k8s.io",resources=apiservices,verbs=get;list;watch;update
Expand All @@ -178,7 +178,7 @@ var (
// +kubebuilder:rbac:groups="coordination.k8s.io",resources=leases,resourceNames=cert-manager-cainjector-leader-election;cert-manager-cainjector-leader-election-core,verbs=get;update;patch
// +kubebuilder:rbac:groups="discovery.k8s.io",resources=endpointslices,verbs=list;watch;get
// +kubebuilder:rbac:groups="certificates.k8s.io",resources=certificatesigningrequests,verbs=get;list;watch;update
// +kubebuilder:rbac:groups="certificates.k8s.io",resources=certificatesigningrequests/status,verbs=update
// +kubebuilder:rbac:groups="certificates.k8s.io",resources=certificatesigningrequests/status,verbs=update;patch
// +kubebuilder:rbac:groups="certificates.k8s.io",resources=signers,resourceNames=issuers.cert-manager.io/*;clusterissuers.cert-manager.io/*,verbs=sign
// +kubebuilder:rbac:groups="",resources=configmaps,resourceNames=cert-manager-cainjector-leader-election;cert-manager-cainjector-leader-election-core;cert-manager-controller,verbs=get;update;patch
// +kubebuilder:rbac:groups="batch",resources=jobs,verbs=list;watch;create;update;delete
Expand Down Expand Up @@ -574,8 +574,8 @@ func (r *ContainerStorageModuleReconciler) oldStandAloneModuleCleanup(ctx contex
components := []string{}
if oldObservabilityEnabled && newObservabilityEnabled {
for _, comp := range oldObs.Components {
oldCompEnabled := utils.IsComponentEnabled(ctx, *oldCR, csmv1.Observability, comp.Name)
newCompEnabled := utils.IsComponentEnabled(ctx, *newCR, csmv1.Observability, comp.Name)
oldCompEnabled := utils.IsModuleComponentEnabled(ctx, *oldCR, csmv1.Observability, comp.Name)
newCompEnabled := utils.IsModuleComponentEnabled(ctx, *newCR, csmv1.Observability, comp.Name)
if oldCompEnabled && !newCompEnabled {
components = append(components, comp.Name)
}
Expand Down Expand Up @@ -797,15 +797,16 @@ func (r *ContainerStorageModuleReconciler) reconcileObservability(ctx context.Co
if len(components) == 0 {
if enabled, obs := utils.IsModuleEnabled(ctx, cr, csmv1.Observability); enabled {
for _, comp := range obs.Components {
if utils.IsComponentEnabled(ctx, cr, csmv1.Observability, comp.Name) {
if utils.IsModuleComponentEnabled(ctx, cr, csmv1.Observability, comp.Name) {
components = append(components, comp.Name)
}
}
}
}
comp2reconFunc := map[string]func(context.Context, bool, utils.OperatorConfig, csmv1.ContainerStorageModule, client.Client) error{
modules.ObservabilityTopologyName: modules.ObservabilityTopology,
modules.ObservabilityOtelCollectorName: modules.OtelCollector,
modules.ObservabilityTopologyName: modules.ObservabilityTopology,
modules.ObservabilityOtelCollectorName: modules.OtelCollector,
modules.ObservabilityCertManagerComponent: modules.CommonCertManager,
}
metricsComp2reconFunc := map[string]func(context.Context, bool, utils.OperatorConfig, csmv1.ContainerStorageModule, client.Client, kubernetes.Interface) error{
modules.ObservabilityMetricsPowerScaleName: modules.PowerScaleMetrics,
Expand All @@ -816,7 +817,7 @@ func (r *ContainerStorageModuleReconciler) reconcileObservability(ctx context.Co
log.Infow(fmt.Sprintf("reconcile %s", comp))
var err error
switch comp {
case modules.ObservabilityTopologyName, modules.ObservabilityOtelCollectorName:
case modules.ObservabilityTopologyName, modules.ObservabilityOtelCollectorName, modules.ObservabilityCertManagerComponent:
err = comp2reconFunc[comp](ctx, isDeleting, op, cr, ctrlClient)
case modules.ObservabilityMetricsPowerScaleName, modules.ObservabilityMetricsPowerFlexName:
err = metricsComp2reconFunc[comp](ctx, isDeleting, op, cr, ctrlClient, k8sClient)
Expand All @@ -835,7 +836,7 @@ func (r *ContainerStorageModuleReconciler) reconcileObservability(ctx context.Co
// reconcileAuthorization - deploy authorization proxy server
func (r *ContainerStorageModuleReconciler) reconcileAuthorization(ctx context.Context, isDeleting bool, op utils.OperatorConfig, cr csmv1.ContainerStorageModule, ctrlClient client.Client) error {
log := logger.GetLogger(ctx)
if utils.IsAuthorizationComponentEnabled(ctx, cr, r, csmv1.AuthorizationServer, modules.AuthProxyServerComponent) {
if utils.IsModuleComponentEnabled(ctx, cr, csmv1.AuthorizationServer, modules.AuthProxyServerComponent) {
log.Infow("Reconcile authorization proxy-server")
if err := modules.AuthorizationServerDeployment(ctx, isDeleting, op, cr, ctrlClient); err != nil {
return fmt.Errorf("unable to reconcile authorization proxy server: %v", err)
Expand All @@ -846,22 +847,22 @@ func (r *ContainerStorageModuleReconciler) reconcileAuthorization(ctx context.Co
}
}

if utils.IsAuthorizationComponentEnabled(ctx, cr, r, csmv1.AuthorizationServer, modules.AuthCertManagerComponent) {
if utils.IsModuleComponentEnabled(ctx, cr, csmv1.AuthorizationServer, modules.AuthCertManagerComponent) {
log.Infow("Reconcile authorization cert-manager")
if err := modules.CommonCertManager(ctx, isDeleting, op, cr, ctrlClient); err != nil {
return fmt.Errorf("unable to reconcile cert-manager for authorization: %v", err)
}
}

if utils.IsAuthorizationComponentEnabled(ctx, cr, r, csmv1.AuthorizationServer, modules.AuthNginxIngressComponent) {
if utils.IsModuleComponentEnabled(ctx, cr, csmv1.AuthorizationServer, modules.AuthNginxIngressComponent) {
log.Infow("Reconcile authorization nginx ingress controller")
if err := modules.NginxIngressController(ctx, isDeleting, op, cr, ctrlClient); err != nil {
return fmt.Errorf("unable to reconcile nginx ingress controller for authorization: %v", err)
}
}

// Authorization Ingress rules are applied after NGINX ingress controller is installed
if utils.IsAuthorizationComponentEnabled(ctx, cr, r, csmv1.AuthorizationServer, modules.AuthProxyServerComponent) {
if utils.IsModuleComponentEnabled(ctx, cr, csmv1.AuthorizationServer, modules.AuthProxyServerComponent) {
log.Infow("Reconcile authorization Ingresses")
if err := modules.AuthorizationIngress(ctx, isDeleting, op, cr, r, ctrlClient); err != nil {
return fmt.Errorf("unable to reconcile authorization ingress rules: %v", err)
Expand Down
3 changes: 3 additions & 0 deletions controllers/csm_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
storagev1 "k8s.io/api/storage/v1"
apiextv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -154,6 +155,8 @@ func (suite *CSMControllerTestSuite) SetupTest() {

csmv1.AddToScheme(scheme.Scheme)

apiextv1.AddToScheme(scheme.Scheme)

objects := map[shared.StorageKey]runtime.Object{}
suite.fakeClient = crclient.NewFakeClient(objects, suite)
suite.k8sClient = clientgoclient.NewFakeClient(suite.fakeClient)
Expand Down
Loading

0 comments on commit 0ebfb8e

Please sign in to comment.