Bug 45460 - [OX] create listener queue print tool
[OX] create listener queue print tool
Status: CLOSED FIXED
Product: Z_Internal OX development
Classification: Unclassified
Component: Listener
unspecified
Other Linux
: P5 normal with 2 votes (vote)
: 7.8.4-ucs8
Assigned To: Daniel Tröder
Sönke Schwardt-Krummrich
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2017-09-27 11:49 CEST by Daniel Tröder
Modified: 2017-11-17 13:06 CET (History)
1 user (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): Troubleshooting, Usability
Max CVSS v3 score:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Tröder univentionstaff 2017-09-27 11:49:41 CEST
The OX listener queue causes regularly problems. For the support and customers it is difficult to safely handle the queue files found in /var/spool/univention-directory-listener/ox-*. It is especially difficult to handle them selectively and not all at once.

Create a script that prints the current content of the ox listener queue:

type (user/group) | name (uid/cn) | operation (add/mod/del) | filename | DN

The script should be shipped somewhere below /usr/share/
Comment 1 Sönke Schwardt-Krummrich univentionstaff 2017-09-27 14:32:12 CEST
The tool should also contain an interactive mode, that allows archiving/removing some queue items.
Comment 2 Sönke Schwardt-Krummrich univentionstaff 2017-10-13 09:46:07 CEST
We need this tool badly to reduce overhead in support.
Comment 3 Daniel Tröder univentionstaff 2017-10-17 22:00:16 CEST
r82794: add interactive queue management tool

The dependency "python-pick" (https://github.com/wong2/pick), for a simple ncurses selection list, was added as a binary package (with sources) to ucs_4.2-0-ucs-school-4.2/{all,source}


Package: univention-ox
Version: 9.0.5-2A~4.2.0.201710172148
Branch: ucs_4.2-0
Scope: oxse4ucs
Comment 4 Daniel Tröder univentionstaff 2017-10-18 15:32:45 CEST
Add non-interactive features:
* --help
* --archive    : backup files found (optionally filter list)
* --delete     : delete files found (optionally filter list)
* --list       : print list to stdout: type|name|operation|filename|DN
* --filter $DN : optional filter for all other operations
* --filenames-only : option to use together with --list: only print a space separated list of filenames (to use with a pipe)
Comment 5 Daniel Tröder univentionstaff 2017-10-19 18:11:11 CEST
usage: manage_listener_queue [-h] [--archive] [--delete] [--list]
                             [--filter FILTER] [--wide] [--filenames-only]

Manage the OX listener queue

optional arguments:
  -h, --help        show this help message and exit
  --archive         Move queue files to /var/spool/univention-directory-
                    listener_backup.
  --delete          Delete queue files.
  --list            Print a list of queue files and related information.
  --filter FILTER   Optional regular expression to limit actions to only those
                    DNs that match (interactive and non-interactive), e.g.
                    'uid=alice,' or '^cn=.*,ou=myschool,'. Use single tick
                    quoting to prevent shell expansion.
  --wide            Also show the DN (very long lines).
  --filenames-only  Option to use together with "--list": print a space
                    separated list of filenames, no description.

An interactive mode will be started, when no action (archive/delete/list) is
chosen.

---------------

--filter and --wide work in both (interactive and non-interactive) modes.


r82807: readd interactive queue management tool with non-interactive mode
r82808: update advisory
Comment 6 Sönke Schwardt-Krummrich univentionstaff 2017-11-16 14:53:05 CET
(In reply to Daniel Tröder from comment #5)
> r82807: readd interactive queue management tool with non-interactive mode

This commit was not sufficient. An entry in debian/univention-ox.install was missing → fixed it

univention-ox (9.0.6-8):
c1b7e4782ab8 | Bug #45460: install manage_listener_queue to /usr/share/univention-ox/

Package: univention-ox
Version: 9.0.6-8A~4.2.0.201711161439
Branch: ucs_4.2-0
Scope: oxse4ucs

root@oxmaster97:/usr/share/univention-ox# ./manage_listener_queue 
Traceback (most recent call last):
  File "./manage_listener_queue", line 264, in <module>
    sys.exit(main())
  File "./manage_listener_queue", line 218, in main
    handler.collect_pickle_files()
  File "./manage_listener_queue", line 129, in collect_pickle_files
    for filename in [f for f in os.listdir(queue_path) if f != 'lock.tmp']:
OSError: [Errno 2] No such file or directory: '/var/spool/univention-directory-listener/ox-resource'

→ REOPEN, the tool should handle missing directories without tracebacks

Otherwise everything seems to be ok.
Comment 7 Sönke Schwardt-Krummrich univentionstaff 2017-11-16 21:32:19 CET
> → REOPEN, the tool should handle missing directories without tracebacks

Suggestion:
--- a/univention-ox/share/manage_listener_queue
+++ b/univention-ox/share/manage_listener_queue
@@ -126,6 +126,8 @@ class OXQueueFilesHandling(object):
 
 	def collect_pickle_files(self):
 		for ox_module, queue_path in self.queue_paths.items():
+			if not os.path.isdir(queue_path):
+				continue
 			for filename in [f for f in os.listdir(queue_path) if f != 'lock.tmp']:
 				path = os.path.join(queue_path, filename)
 				try:
Comment 8 Sönke Schwardt-Krummrich univentionstaff 2017-11-16 21:56:39 CET
Committed patch of last comment:

9d8ccd057734 | Bug #45460: add changelog entry
3c01818868c3 | Bug #45460: add small fix for missing queue directories

Package: univention-ox
Version: 9.0.6-11A~4.2.0.201711162154
Branch: ucs_4.2-0
Scope: oxse4ucs
univention-ox (9.0.6-11):
Comment 9 Sönke Schwardt-Krummrich univentionstaff 2017-11-16 22:21:13 CET
Does no longer trace if a queue directory is missing.

OK: code change
OK: functional test
OK: advisory
Comment 10 Sönke Schwardt-Krummrich univentionstaff 2017-11-17 13:06:02 CET
OX App Suite 7.8.4-ucs8 has been released.

If this error occurs again, please clone this bug.