diff --git a/config.yaml b/config.yaml index 63cb1dc67..98391fb88 100644 --- a/config.yaml +++ b/config.yaml @@ -13,7 +13,7 @@ options: profile: description: | profile representing the scope of deployment, and used to be able to enable high-level - high-level customisation of sysconfigs, resource checks/allocation, warning levels, etc. + customisation of sysconfigs, resource checks/allocation, warning levels, etc. Allowed values are: “production” and “testing”. type: string default: production diff --git a/lib/charms/mysql/v0/mysql.py b/lib/charms/mysql/v0/mysql.py index 17c263b40..92c3be5a3 100644 --- a/lib/charms/mysql/v0/mysql.py +++ b/lib/charms/mysql/v0/mysql.py @@ -134,7 +134,7 @@ def wait_until_mysql_connection(self) -> None: # Increment this major API version when introducing breaking changes LIBAPI = 0 -LIBPATCH = 77 +LIBPATCH = 79 UNIT_TEARDOWN_LOCKNAME = "unit-teardown" UNIT_ADD_LOCKNAME = "unit-add" @@ -1003,10 +1003,11 @@ def render_mysqld_configuration( # noqa: C901 "innodb_buffer_pool_size": str(innodb_buffer_pool_size), "log_error_services": "log_filter_internal;log_sink_internal", "log_error": f"{snap_common}/var/log/mysql/error.log", - "general_log": "ON", + "general_log": "OFF", "general_log_file": f"{snap_common}/var/log/mysql/general.log", - "slow_query_log_file": f"{snap_common}/var/log/mysql/slowquery.log", + "slow_query_log_file": f"{snap_common}/var/log/mysql/slow.log", "binlog_expire_logs_seconds": f"{binlog_retention_seconds}", + "loose-audit_log_filter": "OFF", "loose-audit_log_policy": "LOGINS", "loose-audit_log_file": f"{snap_common}/var/log/mysql/audit.log", } @@ -2281,28 +2282,6 @@ def set_cluster_primary(self, new_primary_address: str) -> None: logger.exception("Failed to set cluster primary") raise MySQLSetClusterPrimaryError(e.message) - def get_cluster_members_addresses(self) -> Optional[Iterable[str]]: - """Get the addresses of the cluster's members.""" - get_cluster_members_commands = ( - f"shell.connect('{self.instance_def(self.server_config_user)}')", - f"cluster = dba.get_cluster('{self.cluster_name}')", - "members = ','.join((member['address'] for member in cluster.describe()['defaultReplicaSet']['topology']))", - "print(f'{members}')", - ) - - try: - output = self._run_mysqlsh_script("\n".join(get_cluster_members_commands)) - except MySQLClientError as e: - logger.warning("Failed to get cluster members addresses", exc_info=e) - raise MySQLGetClusterMembersAddressesError(e.message) - - matches = re.search(r"(.+)", output) - - if not matches: - return None - - return set(matches.group(1).split(",")) - def verify_server_upgradable(self, instance: Optional[str] = None) -> None: """Wrapper for API check_for_server_upgrade.""" # use cluster admin user to enforce standard port usage @@ -2446,14 +2425,6 @@ def is_cluster_replica(self, from_instance: Optional[str] = None) -> Optional[bo return cs_status["clusters"][self.cluster_name.lower()]["clusterrole"] == "replica" - def cluster_set_cluster_count(self, from_instance: Optional[str] = None) -> int: - """Get the number of clusters in the cluster set.""" - cs_status = self.get_cluster_set_status(extended=0, from_instance=from_instance) - if not cs_status: - return 0 - - return len(cs_status["clusters"]) - def get_cluster_set_name(self, from_instance: Optional[str] = None) -> Optional[str]: """Get cluster set name.""" cs_status = self.get_cluster_set_status(extended=0, from_instance=from_instance) diff --git a/templates/logrotate.j2 b/templates/logrotate.j2 index 29b92fe31..85983b726 100644 --- a/templates/logrotate.j2 +++ b/templates/logrotate.j2 @@ -29,8 +29,8 @@ nocopytruncate olddir archive_general } -/var/log/mysql/slowquery.log { - olddir archive_slowquery +/var/log/mysql/slow.log { + olddir archive_slow } /var/log/mysql/audit.log { diff --git a/tests/integration/high_availability/test_log_rotation.py b/tests/integration/high_availability/test_log_rotation.py index d34dfa73f..e83fd5c73 100644 --- a/tests/integration/high_availability/test_log_rotation.py +++ b/tests/integration/high_availability/test_log_rotation.py @@ -40,13 +40,12 @@ async def test_log_rotation( logger.info("Extending update-status-hook-interval to 60m") await ops_test.model.set_config({"update-status-hook-interval": "60m"}) - # Exclude slowquery log files as slowquery logs are not enabled by default - log_types = ["error", "general", "audit"] - log_files = ["error.log", "general.log", "audit.log"] + # Exclude slow log files as slow logs are not enabled by default + log_types = ["error", "audit"] + log_files = ["error.log", "audit.log"] archive_directories = [ "archive_error", - "archive_general", - "archive_slowquery", + "archive_slow", "archive_audit", ] @@ -105,7 +104,7 @@ async def test_log_rotation( ), f"❌ unexpected files/directories in log directory: {ls_output}" logger.info("Ensuring log files were rotated") - # Exclude checking slowquery log rotation as slowquery logs are disabled by default + # Exclude checking slow log rotation as slow logs are disabled by default for log in set(log_types): file_contents = read_contents_from_file_in_unit( ops_test, unit, f"/var/log/mysql/{log}.log" diff --git a/tests/unit/test_mysql_k8s_helpers.py b/tests/unit/test_mysql_k8s_helpers.py index 5fb0a5c35..05fc76dc0 100644 --- a/tests/unit/test_mysql_k8s_helpers.py +++ b/tests/unit/test_mysql_k8s_helpers.py @@ -326,9 +326,10 @@ def test_log_rotate_config(self, _container): " rotation\nhourly\nmaxage 7\nrotate 10800\n\n# Naming of rotated files should be in" " the format:\ndateext\ndateformat -%Y%m%d_%H%M\n\n# Settings to prevent" " misconfigurations and unwanted behaviours\nifempty\nmissingok\nnocompress\nnomail\n" - "nosharedscripts\nnocopytruncate\n\n/var/log/mysql/error.log {\n olddir" - " archive_error\n}\n\n/var/log/mysql/general.log {\n olddir archive_general\n}\n\n" - "/var/log/mysql/slowquery.log {\n olddir archive_slowquery\n}\n\n" + "nosharedscripts\nnocopytruncate\n\n" + "/var/log/mysql/error.log {\n olddir archive_error\n}\n\n" + "/var/log/mysql/general.log {\n olddir archive_general\n}\n\n" + "/var/log/mysql/slow.log {\n olddir archive_slow\n}\n\n" "/var/log/mysql/audit.log {\n olddir archive_audit\n}" )