Skip to content

Commit

Permalink
Add StorageCluster.spec.nfs.LogLevel in storagecluster CR
Browse files Browse the repository at this point in the history
This commit introduces a new parameter, `spec.nfs.LogLevel`,
to the StorageCluster CR. The `LogLevel` parameter allows users
to configure the log level for NFS, improving flexibility and
control over logging behavior.

This addition aims to enhance the user experience by enabling
finer-grained logging settings for debugging and monitoring purposes.

Signed-off-by: Oded Viner <[email protected]>
  • Loading branch information
OdedViner committed Jan 9, 2025
1 parent 8561dee commit 10b5526
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/v1/storagecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,11 @@ type NFSSpec struct {
// +kubebuilder:validation:MaxLength=253
// +kubebuilder:validation:Pattern=^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$
StorageClassName string `json:"storageClassName,omitempty"`
// LogLevel set logging level
// Log levels: NIV_NULL | NIV_FATAL | NIV_MAJ | NIV_CRIT | NIV_WARN | NIV_EVENT | NIV_INFO | NIV_DEBUG | NIV_MID_DEBUG | NIV_FULL_DEBUG | NB_LOG_LEVEL
// +optional
LogLevel string `json:"logLevel,omitempty"`
ReconcileStrategy string `json:"reconcileStrategy,omitempty"`
}

// MonitoringSpec controls the configuration of resources for exposing OCS metrics
Expand Down
5 changes: 5 additions & 0 deletions config/crd/bases/ocs.openshift.io_storageclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2618,6 +2618,11 @@ spec:
enable:
description: Enable specifies whether to enable NFS.
type: boolean
logLevel:
description: LogLevel set logging level
type: string
reconcileStrategy:
type: string
storageClassName:
description: StorageClassName specifies the name of the storage
class created for NFS
Expand Down
8 changes: 8 additions & 0 deletions controllers/storagecluster/cephnfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ func (r *StorageClusterReconciler) newCephNFSInstances(initData *ocsv1.StorageCl
// set high PriorityClassName for the NFS pods, since this will block io for
// pods using NFS volumes.
PriorityClassName: openshiftUserCritical,
LogLevel: initData.Spec.NFS.LogLevel,
},
},
},
Expand All @@ -52,6 +53,10 @@ func (r *StorageClusterReconciler) newCephNFSInstances(initData *ocsv1.StorageCl

// ensureCreated ensures that cephNFS resource exist in the desired state.
func (obj *ocsCephNFS) ensureCreated(r *StorageClusterReconciler, instance *ocsv1.StorageCluster) (reconcile.Result, error) {
reconcileStrategy := ReconcileStrategy(instance.Spec.NFS.ReconcileStrategy)
if reconcileStrategy == ReconcileStrategyIgnore {
return reconcile.Result{}, nil
}
if instance.Spec.NFS == nil || !instance.Spec.NFS.Enable {
return reconcile.Result{}, nil
}
Expand All @@ -74,6 +79,9 @@ func (obj *ocsCephNFS) ensureCreated(r *StorageClusterReconciler, instance *ocsv
r.Log.Info("Restoring original CephNFS.", "CephNFS", klog.KRef(cephNFS.Namespace, cephNFS.Name))
existingCephNFS.ObjectMeta.OwnerReferences = cephNFS.ObjectMeta.OwnerReferences
existingCephNFS.Spec = cephNFS.Spec
if instance.Spec.NFS.LogLevel != "" {
existingCephNFS.Spec.Server.LogLevel = instance.Spec.NFS.LogLevel
}
err = r.Client.Update(ctxTODO, &existingCephNFS)
if err != nil {
r.Log.Error(err, "Unable to update CephNFS.", "CephNFS", klog.KRef(cephNFS.Namespace, cephNFS.Name))
Expand Down
10 changes: 10 additions & 0 deletions controllers/storagecluster/cephnfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,13 @@ func assertCephNFSService(t *testing.T, reconciler StorageClusterReconciler, cr
assert.Equal(t, expectedAf[0].ObjectMeta.Name, actualNFSService.ObjectMeta.Name)
assert.Equal(t, expectedAf[0].Spec, actualNFSService.Spec)
}

func TestNfsLogLevelParam(t *testing.T) {
var objects []client.Object
t, reconciler, cr, _ := initStorageClusterResourceCreateUpdateTest(t, objects, nil)
cr.Spec.NFS = &api.NFSSpec{
LogLevel: "NIV_DEBUG",
}
expectedAf, _ := reconciler.newCephNFSInstances(cr)
assert.Equal(t, "NIV_DEBUG", expectedAf[0].Spec.Server.LogLevel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -2618,6 +2618,11 @@ spec:
enable:
description: Enable specifies whether to enable NFS.
type: boolean
logLevel:
description: LogLevel set logging level
type: string
reconcileStrategy:
type: string
storageClassName:
description: StorageClassName specifies the name of the storage
class created for NFS
Expand Down
5 changes: 5 additions & 0 deletions deploy/ocs-operator/manifests/storagecluster.crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2618,6 +2618,11 @@ spec:
enable:
description: Enable specifies whether to enable NFS.
type: boolean
logLevel:
description: LogLevel set logging level
type: string
reconcileStrategy:
type: string
storageClassName:
description: StorageClassName specifies the name of the storage
class created for NFS
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 10b5526

Please sign in to comment.