Skip to content

Commit

Permalink
Add log-rotation-size
Browse files Browse the repository at this point in the history
  • Loading branch information
yamatcha committed Nov 29, 2024
1 parent 389ae12 commit 71dc62b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions api/v1beta2/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,11 @@ type MySQLClusterSpec struct {
// +optional
LogRotationSchedule string `json:"logRotationSchedule,omitempty"`

// LogRotationSize specifies the size to rotate MySQL logs
// If not set, size-based log rotation is disabled by default
// +optional
LogRotationSize int `json:"logRotationSize,omitempty"`

// The name of BackupPolicy custom resource in the same namespace.
// If this is set, MOCO creates a CronJob to take backup of this MySQL cluster periodically.
// +nullable
Expand Down
3 changes: 3 additions & 0 deletions controllers/mysql_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ func (r *MySQLClusterReconciler) makeV1AgentContainer(cluster *mocov1beta2.MySQL
if cluster.Spec.LogRotationSchedule != "" {
c.WithArgs("--log-rotation-schedule", cluster.Spec.LogRotationSchedule)
}
if cluster.Spec.LogRotationSize > 0 {
c.WithArgs("--log-rotation-size", fmt.Sprintf("%d", cluster.Spec.LogRotationSize))
}

if cluster.Spec.AgentUseLocalhost {
c.WithArgs(constants.MocoMySQLDLocalhostFlag, strconv.FormatBool(cluster.Spec.AgentUseLocalhost))
Expand Down
1 change: 1 addition & 0 deletions docs/crd_mysqlcluster_v1beta2.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ MySQLClusterSpec defines the desired state of MySQLCluster
| maxDelaySecondsForPodDeletion | MaxDelaySecondsForPodDeletion configures the maximum allowed replication delay before a Pod deletion is blocked. If the replication delay exceeds this threshold, deletion of the primary pod will be prevented. The default is 0 seconds. Setting this field to 0 disables the delay check for pod deletion. | int64 | false |
| startupWaitSeconds | StartupWaitSeconds is the maximum duration to wait for `mysqld` container to start working. The default is 3600 seconds. | int32 | false |
| logRotationSchedule | LogRotationSchedule specifies the schedule to rotate MySQL logs. If not set, the default is to rotate logs every 5 minutes. See https://pkg.go.dev/github.com/robfig/cron/v3#hdr-CRON_Expression_Format for the field format. | string | false |
| logRotationSize | LogRotationSize specifies the size to rotate MySQL logs If not set, size-based log rotation is disabled by default | int | false |
| backupPolicyName | The name of BackupPolicy custom resource in the same namespace. If this is set, MOCO creates a CronJob to take backup of this MySQL cluster periodically. | *string | false |
| restore | Restore is the specification to perform Point-in-Time-Recovery from existing cluster. If this field is not null, MOCO restores the data as specified and create a new cluster with the data. This field is not editable. | *[RestoreSpec](#restorespec) | false |
| disableSlowQueryLogContainer | DisableSlowQueryLogContainer controls whether to add a sidecar container named \"slow-log\" to output slow logs as the containers output. If set to true, the sidecar container is not added. The default is false. | bool | false |
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.17.18
github.com/aws/aws-sdk-go-v2/service/s3 v1.61.2
// Do not update moco-agent until changes that will cause StatefulSet to restart are made.
github.com/cybozu-go/moco-agent v0.12.1
github.com/cybozu-go/moco-agent v0.13.0
github.com/go-logr/logr v1.4.2
github.com/go-logr/stdr v1.2.2
github.com/go-sql-driver/mysql v1.8.1
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ github.com/creack/pty v1.1.18 h1:n56/Zwd5o6whRC5PMGretI4IdRLlmBXYNjScPaBgsbY=
github.com/creack/pty v1.1.18/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/cybozu-go/moco-agent v0.12.1 h1:Wp3S5whb9b3nD4cNvtJohJ/yBu6TtE7X3Md7WSIK/fw=
github.com/cybozu-go/moco-agent v0.12.1/go.mod h1:qea2oTno2dEpLLHHi/GiY8T0x+Aw6373aGbfk0fA5Bc=
github.com/cybozu-go/moco-agent v0.12.2 h1:6TrXM0q061R/jOEIg6eLfWDhzMe1h2xwWmJdwhkFgxA=
github.com/cybozu-go/moco-agent v0.12.2/go.mod h1:47vPiMsxKFf0spqts4z1AWKTRIbqAwVOtPcA6q+39zI=
github.com/cybozu-go/moco-agent v0.13.0 h1:74S52H9VhJ1ZnZyB4wPL+PIPRTMS1vjPBmbGtgCrapo=
github.com/cybozu-go/moco-agent v0.13.0/go.mod h1:47vPiMsxKFf0spqts4z1AWKTRIbqAwVOtPcA6q+39zI=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM=
Expand Down

0 comments on commit 71dc62b

Please sign in to comment.