Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logrotate: add logrotate functionality for csi #50

Merged
merged 2 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
nb-ohad marked this conversation as resolved.
Show resolved Hide resolved
//+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
34 changes: 19 additions & 15 deletions docs/design/logrotate.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ 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
```

Expand All @@ -35,14 +35,14 @@ metadata:
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
```

Expand All @@ -51,20 +51,24 @@ Logrotator sidecar container cpu and memory usage can configured by,
`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.
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
Loading