Autoupdater fails on projects already updated
Summary
When autoupater updates projects it returns projects which were already up to date. In stage of preparing rocketchat messages it then tryis to make output from updated project, but none merge request was created so it trys to get attributes from None type object.
Steps to reproduce
Run autoupdater with --project pattern that which fit to project that need update, and one project that has all dependencies up to date.
Expected behavior
Autoupdater should end with succes and message should be send to rocketchat.
Actual behavior
Autoapdater fails with AttributeError exception raised.
Relevant logs and/or screenshots
...
2019-04-29 06:00:28,705 [INFO]: Package "ansible-cloud-playbook" is up-to-date: 19.04
2019-04-29 06:00:29,004 [INFO]: Package "ansible-lint" is up-to-date: 4.1.0
2019-04-29 06:00:29,004 [INFO]: End updating project "containers/pipeline-worker"
2019-04-29 06:00:30,032 [INFO]: Updating project "apl/secrets"
2019-04-29 06:00:30,635 [INFO]: Package "vault" is up-to-date: 1.1.2
2019-04-29 06:00:30,823 [INFO]: Package "ansible-roles/docker" is up-to-date: 3.2.0
2019-04-29 06:00:30,963 [INFO]: Package "ansible-roles/filesystem" is up-to-date: 2.3.0
2019-04-29 06:00:31,134 [INFO]: Package "ansible-roles/nginx" is up-to-date: 5.4.0
2019-04-29 06:00:31,326 [INFO]: Package "ansible-roles/openstack" is up-to-date: 5.3.0
2019-04-29 06:00:31,476 [INFO]: Package "ansible-roles/python" is up-to-date: 1.2.0
2019-04-29 06:00:31,662 [INFO]: Package "ansible-roles/service" is up-to-date: 1.5.1
2019-04-29 06:00:31,827 [INFO]: Package "ansible-roles/ssh" is up-to-date: 3.2.0
2019-04-29 06:00:32,008 [INFO]: Package "pipeline-worker" is up-to-date: 19.04
2019-04-29 06:00:32,009 [INFO]: End updating project "apl/secrets"
Traceback (most recent call last):
File "/usr/local/bin/autoupdater", line 10, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/site-packages/autoupdater/commander.py", line 32, in main
arguments.webhook
File "/usr/local/lib/python3.7/site-packages/autoupdater/projects/update.py", line 14, in update_projects
autoupdater.rocketchat.rocketchat.notify(updated_projects, webhook)
File "/usr/local/lib/python3.7/site-packages/autoupdater/rocketchat/rocketchat.py", line 11, in notify
message_with_new_changes, message_reminder = _make_readable_messages(updated_projects)
File "/usr/local/lib/python3.7/site-packages/autoupdater/rocketchat/rocketchat.py", line 37, in _make_readable_messages
merge_request_url = f'{project.merge_request.attributes["web_url"]}/diffs'
AttributeError: 'NoneType' object has no attribute 'attributes'
Running cleanup - removing workspace /var/lib/rundeck/work/teamwork/510874
Result: 1
Failed: NonZeroResultCode: Result code was 1
Execution failed: 510874 in project teamwork: [Workflow result: , step failures: {1=Dispatch failed on 1 nodes: [0.0.0.0: NonZeroResultCode: Result code was 1 + {dataContext=MultiDataContextImpl(map={ContextView(step:1, node:0.0.0.0)=BaseDataContext{{exec={exitCode=0}}}, ContextView(node:0.0.0.0)=BaseDataContext{{exec={exitCode=0}}}}, base=null)} ]}, Node failures: {0.0.0.0=[NonZeroResultCode: Result code was 1 + {dataContext=MultiDataContextImpl(map={ContextView(step:1, node:0.0.0.0)=BaseDataContext{{exec={exitCode=0}}}, ContextView(node:0.0.0.0)=BaseDataContext{{exec={exitCode=0}}}}, base=null)} ]}, status: failed]
Possible fixes
add if
statement to yield project in update_project method https://projects.task.gda.pl/apl/autoupdater/blob/master/autoupdater/gitlab/update.py#L112
and return UpdetedProject object or None if meregerequest is None in update method https://projects.task.gda.pl/apl/autoupdater/blob/master/autoupdater/gitlab/update.py#L186