Fix lazy initialization of GithubUser with apps

When in app mode the lazy initialization of the GithubUser object can
fail because the github client is eager initialized. This is the case
if the job takes longer than the lifetime of the auth token which
crashes reporting than with [1].

[1] Trace:
2018-01-31 09:21:55,354 ERROR zuul.Pipeline.xpad.gate: Exception while reporting:
Traceback (most recent call last):
  File "/usr/lib/python3.6/site-packages/zuul/manager/__init__.py", line 856, in _reportItem
    ret = self.sendReport(actions, item)
  File "/usr/lib/python3.6/site-packages/zuul/manager/__init__.py", line 175, in sendReport
    ret = reporter.report(item)
  File "/usr/lib/python3.6/site-packages/zuul/driver/github/githubreporter.py", line 73, in report
    self.mergePull(item)
  File "/usr/lib/python3.6/site-packages/zuul/driver/github/githubreporter.py", line 137, in mergePull
    message = self._formatMergeMessage(item.change)
  File "/usr/lib/python3.6/site-packages/zuul/driver/github/githubreporter.py", line 175, in _formatMergeMessage
    if not account:
  File "/usr/lib/python3.6/site-packages/zuul/driver/github/githubconnection.py", line 377, in __len__
    self._init_data()
  File "/usr/lib/python3.6/site-packages/zuul/driver/github/githubconnection.py", line 382, in _init_data
    user = self._github.user(self._username)
  File "/usr/lib/python3.6/site-packages/github3/github.py", line 1657, in user
    json = self._json(self._get(url), 200)
  File "/usr/lib/python3.6/site-packages/github3/models.py", line 211, in _json
    if self._boolean(response, status_code, 404) and response.content:
  File "/usr/lib/python3.6/site-packages/github3/models.py", line 233, in _boolean
    raise exceptions.error_for(response)
github3.exceptions.AuthenticationFailed: 401 Bad credentials

Change-Id: Id38520b790d7d7c6ce72bbcc8a736ed7485b5ae1
1 file changed