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

Fix error naming example #101

Merged
merged 5 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
6 changes: 3 additions & 3 deletions lib/charms/operator_libs_linux/v0/sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def _on_install(self, _):

try:
self.sysctl.configure(config=sysctl_data)
except (sysctl.SysctlPermissionError, sysctl.ValidationError) as e:
except (sysctl.ApplyError, sysctl.ValidationError) as e:
logger.error(f"Error setting values on sysctl: {e.message}")
self.unit.status = BlockedStatus("Sysctl config not possible")
except sysctl.SysctlError:
except sysctl.CommandError:
logger.error("Error on sysctl")

def _on_remove(self, _):
Expand All @@ -84,7 +84,7 @@ def _on_remove(self, _):

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 2
LIBPATCH = 3

CHARM_FILENAME_PREFIX = "90-juju-"
SYSCTL_DIRECTORY = Path("/etc/sysctl.d")
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/test_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from charms.operator_libs_linux.v0 import sysctl

EXPECTED_MERGED_RESULT = """# This config file was produced by sysctl lib v0.2
EXPECTED_MERGED_RESULT = """# This config file was produced by sysctl lib v0.3
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use v{LIBAPI}.{LIBPATCH} here (and below), to avoid having to update this every update?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is much better.

#
# This file represents the output of the sysctl lib, which can combine multiple
# configurations into a single file like.
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/test_sysctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@
vm.swappiness=60
net.ipv4.tcp_max_syn_backlog=4096
"""
TEST_OTHER_CHARM_MERGED = """# This config file was produced by sysctl lib v0.2
TEST_OTHER_CHARM_MERGED = """# This config file was produced by sysctl lib v0.3
#
# This file represents the output of the sysctl lib, which can combine multiple
# configurations into a single file like.
# othercharm
vm.swappiness=60
net.ipv4.tcp_max_syn_backlog=4096
"""
TEST_MERGED_FILE = """# This config file was produced by sysctl lib v0.2
TEST_MERGED_FILE = """# This config file was produced by sysctl lib v0.3
#
# This file represents the output of the sysctl lib, which can combine multiple
# configurations into a single file like.
vm.max_map_count = 262144
vm.swappiness=0
"""
TEST_UPDATE_MERGED_FILE = """# This config file was produced by sysctl lib v0.2
TEST_UPDATE_MERGED_FILE = """# This config file was produced by sysctl lib v0.3
#
# This file represents the output of the sysctl lib, which can combine multiple
# configurations into a single file like.
Expand Down