Skip to content

Commit 88e6db2

Browse files
authored
Merge pull request #50 from parth-gr/logrotate-feature
logrotate: add logrotate functionality for csi
2 parents 0babd70 + 9667889 commit 88e6db2

File tree

8 files changed

+273
-33
lines changed

8 files changed

+273
-33
lines changed

api/v1alpha1/driver_types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ const (
3333
MonthlyPeriod PeriodicityType = "monthly"
3434
)
3535

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

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

5052
// LogHostPath is the prefix directory path for the csi log files
53+
// Default to /var/lib/cephcsi
5154
//+kubebuilder:validation:Optional
5255
LogHostPath string `json:"logHostPath,omitempty"`
5356
}

config/crd/bases/csi.ceph.io_drivers.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,11 +3542,14 @@ spec:
35423542
description: log rotation for csi pods
35433543
properties:
35443544
logHostPath:
3545-
description: LogHostPath is the prefix directory path for
3546-
the csi log files
3545+
description: |-
3546+
LogHostPath is the prefix directory path for the csi log files
3547+
Default to /var/lib/cephcsi
35473548
type: string
35483549
maxFiles:
3549-
description: MaxFiles is the number of logrtoate files
3550+
description: |-
3551+
MaxFiles is the number of logrtoate files
3552+
Default to 7
35503553
type: integer
35513554
maxLogSize:
35523555
anyOf:
@@ -3565,6 +3568,9 @@ spec:
35653568
- monthly
35663569
type: string
35673570
type: object
3571+
x-kubernetes-validations:
3572+
- message: Either maxLogSize or periodicity must be set
3573+
rule: (has(self.maxLogSize)) || (has(self.periodicity))
35683574
verbosity:
35693575
description: |-
35703576
Log verbosity level for driver pods,

config/crd/bases/csi.ceph.io_operatorconfigs.yaml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3581,11 +3581,14 @@ spec:
35813581
description: log rotation for csi pods
35823582
properties:
35833583
logHostPath:
3584-
description: LogHostPath is the prefix directory path
3585-
for the csi log files
3584+
description: |-
3585+
LogHostPath is the prefix directory path for the csi log files
3586+
Default to /var/lib/cephcsi
35863587
type: string
35873588
maxFiles:
3588-
description: MaxFiles is the number of logrtoate files
3589+
description: |-
3590+
MaxFiles is the number of logrtoate files
3591+
Default to 7
35893592
type: integer
35903593
maxLogSize:
35913594
anyOf:
@@ -3605,6 +3608,9 @@ spec:
36053608
- monthly
36063609
type: string
36073610
type: object
3611+
x-kubernetes-validations:
3612+
- message: Either maxLogSize or periodicity must be set
3613+
rule: (has(self.maxLogSize)) || (has(self.periodicity))
36083614
verbosity:
36093615
description: |-
36103616
Log verbosity level for driver pods,

docs/design/logrotate.md

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ apiVersion: csi.ceph.io/v1alpha1
1313
spec:
1414
log:
1515
verbosity: 1
16-
driverSpecDefaults:
16+
driverSpecDefaults:
1717
log:
1818
verbosity: 5
1919
rotation:
2020
# one of: hourly, daily, weekly, monthly
2121
periodicity: daily
2222
maxLogSize: 500M
23-
maxFiles: 5
23+
maxFiles: 7
2424
logHostPath: /var/lib/cephcsi
2525
```
2626
@@ -35,14 +35,14 @@ metadata:
3535
spec:
3636
log:
3737
verbosity: 1
38-
driverSpecDefaults:
38+
driverSpecDefaults:
3939
log:
4040
verbosity: 5
4141
rotation:
4242
# one of: hourly, daily, weekly, monthly
4343
periodicity: daily
4444
maxLogSize: 500M
45-
maxFiles: 5
45+
maxFiles: 7
4646
logHostPath: /var/lib/cephcsi
4747
```
4848

@@ -51,20 +51,24 @@ Logrotator sidecar container cpu and memory usage can configured by,
5151
`OperatorConfig CRD`:
5252
```yaml
5353
spec:
54-
provisioner:
55-
logRotator:
56-
cpu: "100m"
57-
memory: "32Mi"
58-
plugin:
59-
logRotator:
60-
cpu: "100m"
61-
memory: "32Mi"
54+
driverSpecDefaults:
55+
controllerPlugin:
56+
resources:
57+
logRotator:
58+
cpu: "100m"
59+
memory: "32Mi"
60+
nodePlugin:
61+
resources:
62+
logRotator:
63+
cpu: "100m"
64+
memory: "32Mi"
6265
```
6366

64-
For systems where SELinux is enabled (e.g. OpenShift),start plugin-controller as privileged that mount a host path.
67+
For systems where SELinux is enabled (e.g. OpenShift), start plugin-controller as privileged that mount a host path.
6568
`OperatorConfig CRD`:
6669
```yaml
6770
spec:
68-
provisioner:
69-
privileged: true
71+
driverSpecDefaults:
72+
controllerPlugin:
73+
privileged: true
7074
```

docs/design/operator.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ spec:
9292
# one of: hourly, daily, weekly, monthly
9393
periodicity: daily
9494
maxLogSize: 500M
95-
maxFiles: 5
95+
maxFiles: 7
9696
logHostPath: /var/lib/cephcsi
9797
clusterName: 5c63ad7e-74fe-4724-a511-4ccdc560da56
9898
enableMetadata: true

internal/controller/defaults.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ var imageDefaults = map[string]string{
3838
}
3939

4040
const (
41-
defaultGRrpcTimeout = 150
42-
defaultKubeletDirPath = "/var/lib/kubelet"
41+
defaultGRrpcTimeout = 150
42+
defaultKubeletDirPath = "/var/lib/kubelet"
43+
defaultLogHostPath = "/var/lib/cephcsi"
44+
defaultLogRotateMaxFiles = 7
4345
)
4446

4547
var defaultLeaderElection = csiv1a1.LeaderElectionSpec{

0 commit comments

Comments
 (0)