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

[MISC] Bump mysql charm lib version #563

Merged
merged 3 commits into from
Jan 22, 2025
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
2 changes: 1 addition & 1 deletion config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 4 additions & 33 deletions lib/charms/mysql/v0/mysql.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
}
Expand Down Expand Up @@ -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>{members}</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"<MEMBERS>(.+)</MEMBERS>", 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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions templates/logrotate.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 5 additions & 6 deletions tests/integration/high_availability/test_log_rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]

Expand Down Expand Up @@ -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"
Expand Down
7 changes: 4 additions & 3 deletions tests/unit/test_mysql_k8s_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
)

Expand Down
Loading