Listing users do not return all users
Summary
When deploying Rocket.chat after service start role list all chat users and performs creation/update of bot user based on condition if bot is present or not in list g all users.
Steps to reproduce
Expected behavior
Bot user should be always returned on list withh all users.
Actual behavior
Sometimes bot user is not present in that list, then role try to create it and fails because this user already exist.
Relevant logs and/or screenshots
2020-10-30 20:05:21,239 p=28 u=porzech n=ansible | Friday 30 October 2020 20:05:21 +0000 (0:00:04.944) 0:07:49.752 ********
2020-10-30 20:05:23,139 p=28 u=porzech n=ansible | skipping: [rocketchat]
2020-10-30 20:05:23,170 p=28 u=porzech n=ansible | TASK [rocketchat : create bot user] **********************************************************************************************************************************************************************************************************************
2020-10-30 20:05:23,172 p=28 u=porzech n=ansible | Friday 30 October 2020 20:05:23 +0000 (0:00:01.932) 0:07:51.685 ********
2020-10-30 20:05:28,704 p=28 u=porzech n=ansible | fatal: [rocketchat]: FAILED! => {"cache_control": "no-store", "changed": true, "connection": "close", "content": "{\"success\":false,\"error\":\"rocket.cat is already in use :( [error-field-unavailable]\",\"errorType\":\"error-field-unavailable\",\"details\":{\"method\":\"insertOrUpdateUser\",\"field\":\"rocket.cat\"}}", "content_type": "application/json", "date": "Fri, 30 Oct 2020 20:05:28 GMT", "elapsed": 0, "failed_when_result": true, "json": {"details": {"field": "rocket.cat", "method": "insertOrUpdateUser"}, "error": "rocket.cat is already in use :( [error-field-unavailable]", "errorType": "error-field-unavailable", "success": false}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "pragma": "no-cache", "redirected": false, "status": 400, "transfer_encoding": "chunked", "url": "http://127.0.0.1:80/api/v1/users.create", "vary": "Accept-Encoding", "x_content_type_options": "nosniff", "x_instance_id": "SK4ajSMxm6d4p4Htu", "x_xss_protection": "1"}
Possible fixes
- Try to get only bot user not all users using users.info endpoint
- Increase count parametr which is by default 50 → https://docs.rocket.chat/api/rest-api/offset-and-count-and-sort-info