Skip to content

Commit

Permalink
Merge pull request ceph#26 from parth-gr/logrotate-downstream-add1
Browse files Browse the repository at this point in the history
Bug 2307835: Add log rotation for the CephCSI pods
  • Loading branch information
openshift-merge-bot[bot] authored Aug 27, 2024
2 parents fb535da + 0f17116 commit 266961d
Show file tree
Hide file tree
Showing 8 changed files with 278 additions and 39 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/driver_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ const (
MonthlyPeriod PeriodicityType = "monthly"
)

// +kubebuilder:validation:XValidation:message="Either maxLogSize or periodicity must be set",rule="(has(self.maxLogSize)) || (has(self.periodicity))"
type LogRotationSpec struct {
// MaxFiles is the number of logrtoate files
// Default to 7
//+kubebuilder:validation:Optional
MaxFiles int `json:"maxFiles,omitempty"`

Expand All @@ -48,6 +50,7 @@ type LogRotationSpec struct {
Periodicity PeriodicityType `json:"periodicity,omitempty"`

// LogHostPath is the prefix directory path for the csi log files
// Default to /var/lib/cephcsi
//+kubebuilder:validation:Optional
LogHostPath string `json:"logHostPath,omitempty"`
}
Expand Down
12 changes: 9 additions & 3 deletions config/crd/bases/csi.ceph.io_drivers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3542,11 +3542,14 @@ spec:
description: log rotation for csi pods
properties:
logHostPath:
description: LogHostPath is the prefix directory path for
the csi log files
description: |-
LogHostPath is the prefix directory path for the csi log files
Default to /var/lib/cephcsi
type: string
maxFiles:
description: MaxFiles is the number of logrtoate files
description: |-
MaxFiles is the number of logrtoate files
Default to 7
type: integer
maxLogSize:
anyOf:
Expand All @@ -3565,6 +3568,9 @@ spec:
- monthly
type: string
type: object
x-kubernetes-validations:
- message: Either maxLogSize or periodicity must be set
rule: (has(self.maxLogSize)) || (has(self.periodicity))
verbosity:
description: |-
Log verbosity level for driver pods,
Expand Down
12 changes: 9 additions & 3 deletions config/crd/bases/csi.ceph.io_operatorconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3581,11 +3581,14 @@ spec:
description: log rotation for csi pods
properties:
logHostPath:
description: LogHostPath is the prefix directory path
for the csi log files
description: |-
LogHostPath is the prefix directory path for the csi log files
Default to /var/lib/cephcsi
type: string
maxFiles:
description: MaxFiles is the number of logrtoate files
description: |-
MaxFiles is the number of logrtoate files
Default to 7
type: integer
maxLogSize:
anyOf:
Expand All @@ -3605,6 +3608,9 @@ spec:
- monthly
type: string
type: object
x-kubernetes-validations:
- message: Either maxLogSize or periodicity must be set
rule: (has(self.maxLogSize)) || (has(self.periodicity))
verbosity:
description: |-
Log verbosity level for driver pods,
Expand Down
46 changes: 25 additions & 21 deletions docs/design/logrotate.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,67 +4,71 @@ Log rotation involves managing log files by controlling their size. This feature

Logroate configuration,

`CephCSIOperatorConfig CRD`:
`OperatorConfig CRD`:

```yaml
kind: CephCSIOperatorConfig
kind: OperatorConfig
apiVersion: csi.ceph.io/v1alpha1
….
spec:
log:
verbosity: 1
driverSpecDefaults:
driverSpecDefaults:
log:
verbosity: 5
rotation:
# one of: hourly, daily, weekly, monthly
periodicity: daily
maxLogSize: 500M
maxFiles: 5
maxFiles: 7
logHostPath: /var/lib/cephcsi
```
Similar settings will be overridden by `CephCSIDriver CRD`:
Similar settings will be overridden by `Driver CRD`:

```yaml
kind: CephCSIDriver
kind: Driver
apiVersion: csi.ceph.io/v1alpha1
metadata:
name: "<prefix>.<driver_type>.csi.ceph.com"
namespace: <operator-namespace>
spec:
log:
verbosity: 1
driverSpecDefaults:
driverSpecDefaults:
log:
verbosity: 5
rotation:
# one of: hourly, daily, weekly, monthly
periodicity: daily
maxLogSize: 500M
maxFiles: 5
maxFiles: 7
logHostPath: /var/lib/cephcsi
```

Logrotator sidecar container cpu and memory usage can configured by,

`CephCSIOperatorConfig CRD`:
`OperatorConfig CRD`:
```yaml
spec:
provisioner:
logRotator:
cpu: "100m"
memory: "32Mi"
plugin:
logRotator:
cpu: "100m"
memory: "32Mi"
driverSpecDefaults:
controllerPlugin:
resources:
logRotator:
cpu: "100m"
memory: "32Mi"
nodePlugin:
resources:
logRotator:
cpu: "100m"
memory: "32Mi"
```

For systems where SELinux is enabled (e.g. OpenShift),start plugin-controller as privileged that mount a host path.
`CephCSIOperatorConfig CRD`:
For systems where SELinux is enabled (e.g. OpenShift), start plugin-controller as privileged that mount a host path.
`OperatorConfig CRD`:
```yaml
spec:
provisioner:
privileged: true
driverSpecDefaults:
controllerPlugin:
privileged: true
```
2 changes: 1 addition & 1 deletion docs/design/operator.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ spec:
# one of: hourly, daily, weekly, monthly
periodicity: daily
maxLogSize: 500M
maxFiles: 5
maxFiles: 7
logHostPath: /var/lib/cephcsi
clusterName: 5c63ad7e-74fe-4724-a511-4ccdc560da56
enableMetadata: true
Expand Down
6 changes: 4 additions & 2 deletions internal/controller/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ var imageDefaults = map[string]string{
}

const (
defaultGRrpcTimeout = 150
defaultKubeletDirPath = "/var/lib/kubelet"
defaultGRrpcTimeout = 150
defaultKubeletDirPath = "/var/lib/kubelet"
defaultLogHostPath = "/var/lib/cephcsi"
defaultLogRotateMaxFiles = 7
)

var defaultLeaderElection = csiv1a1.LeaderElectionSpec{
Expand Down
Loading

0 comments on commit 266961d

Please sign in to comment.