Elukey has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/364701 )

Change subject: eventlogging_cleaner.py: fix some runtime issues
......................................................................


eventlogging_cleaner.py: fix some runtime issues

After I tried to run the script on db1047 a couple of issues arose:
- the dbport should not be passed in case the unix_socket is used.
- os.getlogin() does not get the effective uid, and in [1] it is
  suggested to use pwd instead.

[1]: https://docs.python.org/3/library/os.html

Change-Id: Ifb384cf6cade5c7c9f008c4b6949cbce1103dcff
---
M modules/role/files/mariadb/eventlogging_cleaner.py
1 file changed, 5 insertions(+), 2 deletions(-)

Approvals:
  Elukey: Verified; Looks good to me, approved



diff --git a/modules/role/files/mariadb/eventlogging_cleaner.py 
b/modules/role/files/mariadb/eventlogging_cleaner.py
index 58eee6d..76e3f44 100644
--- a/modules/role/files/mariadb/eventlogging_cleaner.py
+++ b/modules/role/files/mariadb/eventlogging_cleaner.py
@@ -39,6 +39,7 @@
 import csv
 import logging
 import os
+import pwd
 import re
 import sys
 import time
@@ -495,8 +496,9 @@
         # Priority to the local unix socket, default to username/password
         try:
             unix_socket = config.get('client', 'socket')
-            db_user = os.getlogin()
+            db_user = pwd.getpwuid(os.getuid())[0]
             db_password = None
+            db_port = None
         except configparser.NoOptionError as e:
             log.info(
                 "No local unix socket configured for myql, default to 
username/password"
@@ -504,12 +506,13 @@
             unix_socket = None
             db_user = config.get('client', 'user')
             db_password = config.get('client', 'password')
+            db_port = args.dbport
 
         # Connect to the database in localhost (no other option
         # available). This is a design choice to simplify auth
         # and to restrict the actions taken to the local db only.
         database = Database('localhost', args.dbname, db_user, 
db_password=db_password,
-                            db_port=args.dbport, unix_socket=unix_socket)
+                            db_port=db_port, unix_socket=unix_socket)
 
         # Apply the retention policy to each table
         tables = database.get_all_tables()

-- 
To view, visit https://gerrit.wikimedia.org/r/364701
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifb384cf6cade5c7c9f008c4b6949cbce1103dcff
Gerrit-PatchSet: 2
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Elukey <ltosc...@wikimedia.org>
Gerrit-Reviewer: Elukey <ltosc...@wikimedia.org>
Gerrit-Reviewer: Mforns <mfo...@wikimedia.org>
Gerrit-Reviewer: Volans <rcocci...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to