-
Notifications
You must be signed in to change notification settings - Fork 20
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
[DPE-5324] Increase linting rules #740
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #740 +/- ##
==========================================
+ Coverage 75.48% 75.57% +0.09%
==========================================
Files 12 12
Lines 3121 3108 -13
Branches 475 464 -11
==========================================
- Hits 2356 2349 -7
+ Misses 622 620 -2
+ Partials 143 139 -4 ☔ View full report in Codecov by Sentry. |
cursor.execute( | ||
SQL("SELECT datname FROM pg_database WHERE datname={};").format(Literal(database)) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bandit checks don't like rendering directly in the SQL string.
return not ( | ||
not self.charm._patroni.member_started | ||
and ( | ||
(len(self.charm._peers.data.keys()) == 2) | ||
or ( | ||
"tls" not in self.charm.unit_peer_data | ||
and any("tls" in unit_data for _, unit_data in self.charm._peers.data.items()) | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ugly
@@ -28,6 +28,7 @@ | |||
from constants import POSTGRESQL_LOGS_PATH, POSTGRESQL_LOGS_PATTERN, REWIND_USER, TLS_CA_FILE | |||
|
|||
RUNNING_STATES = ["running", "streaming"] | |||
PATRONI_TIMEOUT = 10 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Arbitrary timeout for REST calls. IIRC otherwise TCP defaults are used.
@@ -109,14 +108,14 @@ def __init__( | |||
user: str, | |||
password: str, | |||
database: str, | |||
system_users: List[str] = [], | |||
system_users: Optional[list[str]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't use implicit union (list[str] | None
) for compatibility with focal (Python 3.8)
@@ -10,7 +10,8 @@ | |||
def main(): | |||
"""Main loop that calls logrotate.""" | |||
while True: | |||
subprocess.run(["logrotate", "-f", "/etc/logrotate.d/pgbackrest.logrotate"]) | |||
# Command is hardcoded | |||
subprocess.run(["/usr/sbin/logrotate", "-f", "/etc/logrotate.d/pgbackrest.logrotate"]) # noqa: S603 | |||
|
|||
# Wait 60 seconds before executing logrotate again. | |||
time.sleep(60) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can most probably use pebble backoff to do the same
patch( | ||
"relations.async_replication.PostgreSQLAsyncReplication._get_unit_ip", | ||
return_value="1.1.1.1", | ||
) as _get_unit_ip, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fails on non-Ubutu hosts without the patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The great about of work and passion invested here.
LGTM and thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the great work, Dragomir!
Add more linting rules and change and suppress the reported issues. Added rules are: