diff --git a/api/v1beta2/mysqlcluster_types.go b/api/v1beta2/mysqlcluster_types.go index a4092330..014cdc6b 100644 --- a/api/v1beta2/mysqlcluster_types.go +++ b/api/v1beta2/mysqlcluster_types.go @@ -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 diff --git a/controllers/mysql_container.go b/controllers/mysql_container.go index a8463b35..44e84752 100644 --- a/controllers/mysql_container.go +++ b/controllers/mysql_container.go @@ -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)) diff --git a/docs/crd_mysqlcluster_v1beta2.md b/docs/crd_mysqlcluster_v1beta2.md index e89a8ebe..8e9c589b 100644 --- a/docs/crd_mysqlcluster_v1beta2.md +++ b/docs/crd_mysqlcluster_v1beta2.md @@ -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 | diff --git a/go.mod b/go.mod index 90e3a296..2a0441bd 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index f533d562..8f6caa0a 100644 --- a/go.sum +++ b/go.sum @@ -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=