Skip to content

Commit

Permalink
logrotate: add logrotate functionality for csi
Browse files Browse the repository at this point in the history
1) Make main container and csi addons container
   log to a file(dependency on klog)

2) Add a log-rotate sidecar container,
   so it can rotate the logs

3) Added other volume and volumemounts as needed

4) Added the privileged option for controllerplugin

5) Add resources to the logrotate container

6) make the api change in the merge function

Signed-off-by: parth-gr <[email protected]>
  • Loading branch information
parth-gr committed Aug 14, 2024
1 parent 0648b5e commit 86b1cb3
Show file tree
Hide file tree
Showing 6 changed files with 266 additions and 29 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="Atleast any one of MaxLogSize or Periodicity should be set",rule="(has(self.MaxLogSize)) || (has(self.Periodicity))"

Check failure on line 36 in api/v1alpha1/driver_types.go

View workflow job for this annotation

GitHub Actions / codespell

Atleast ==> At least
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
13 changes: 10 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,10 @@ spec:
- monthly
type: string
type: object
x-kubernetes-validations:
- message: Atleast any one of MaxLogSize or Periodicity should

Check failure on line 3572 in config/crd/bases/csi.ceph.io_drivers.yaml

View workflow job for this annotation

GitHub Actions / codespell

Atleast ==> At least
be set
rule: (has(self.MaxLogSize)) || (has(self.Periodicity))
verbosity:
description: |-
Log verbosity level for driver pods,
Expand Down
13 changes: 10 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,10 @@ spec:
- monthly
type: string
type: object
x-kubernetes-validations:
- message: Atleast any one of MaxLogSize or Periodicity should

Check failure on line 3612 in config/crd/bases/csi.ceph.io_operatorconfigs.yaml

View workflow job for this annotation

GitHub Actions / codespell

Atleast ==> At least
be set
rule: (has(self.MaxLogSize)) || (has(self.Periodicity))
verbosity:
description: |-
Log verbosity level for driver pods,
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 86b1cb3

Please sign in to comment.