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

Change subject: check_private_data.py: Add socket parameter
......................................................................


check_private_data.py: Add socket parameter

The script check_private_data right now assumes that /tmp/mysql.sock is
the default socket.
This works on labs hosts because they are mutisource, but for
sanitarium (to be decommissioned) and sanitarium3 it fails because we
use multi-instance.

With this change, by default it will assume the host uses
/tmp/mysql.sock unless specified otherwise with the "-S" parameter

root@db1102:/home/marostegui# ./check_private_data.py -h
usage: check_private_data.py [-h] [-S MYSQL_SOCKET]

optional arguments:
  -h, --help       show this help message and exit
  -S MYSQL_SOCKET  Set MySQL socket file

And if specified, it will just run:
root@db1102:/home/marostegui# ./check_private_data.py -S
/tmp/mysql.s6.sock
-- Non-public databases that are present:
-- Non-public tables that are present:
-- Unfiltered columns that are present:

Bug: T153743
Change-Id: I741c10d4c57ea51cd820af4a7da7a9efeb3812e1
---
M modules/role/files/mariadb/check_private_data.py
1 file changed, 9 insertions(+), 3 deletions(-)

Approvals:
  Marostegui: Looks good to me, approved
  jenkins-bot: Verified
  Jcrespo: Looks good to me, but someone else must approve



diff --git a/modules/role/files/mariadb/check_private_data.py 
b/modules/role/files/mariadb/check_private_data.py
index 475fa6c..1d7ae45 100644
--- a/modules/role/files/mariadb/check_private_data.py
+++ b/modules/role/files/mariadb/check_private_data.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 
+import argparse
 import csv
 import os
 import re
@@ -183,14 +184,14 @@
                "   SET `{}` = NULL;").format(col[0], col[1], col[2]))
 
 
-def main():
+def main(mysql_socket):
     (private_dblist, private_tables, filtered_tables, public_wiki_dbs,
      public_view_dbs, public_dbs) = get_lists(all_dblist_path,
                                               private_dblist_path,
                                               deleted_dblist_path,
                                               filtered_tables_path)
     db = pymysql.connect(host='localhost', user='root',
-                         unix_socket='/tmp/mysql.sock')
+                         unix_socket=mysql_socket)
 
     print('-- Non-public databases that are present:')
     private_databases_present = get_private_databases(db, public_dbs,
@@ -211,4 +212,9 @@
 
 
 if __name__ == "__main__":
-    main()
+    parser = argparse.ArgumentParser()
+    parser.add_argument('-S', action='store', dest='mysql_socket',
+                        default='/tmp/mysql.sock',
+                        help='Set MySQL socket file')
+    results = parser.parse_args()
+    main(results.mysql_socket)

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I741c10d4c57ea51cd820af4a7da7a9efeb3812e1
Gerrit-PatchSet: 3
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Marostegui <[email protected]>
Gerrit-Reviewer: Giuseppe Lavagetto <[email protected]>
Gerrit-Reviewer: Jcrespo <[email protected]>
Gerrit-Reviewer: Marostegui <[email protected]>
Gerrit-Reviewer: Volans <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to