Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail early processing project factory #5919

Merged

Conversation

AlanCoding
Copy link
Member

@AlanCoding AlanCoding commented Feb 12, 2020

SUMMARY

In data generators, don't let JT processing continue with failed projects

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME
  • API
AWX VERSION
9.2.0
ADDITIONAL INFORMATION

error before:

tests/api/test_alan.py::TestAlan::test_project FAILED                                                                                                                [100%]

================================================================================= FAILURES =================================================================================
__________________________________________________________________________ TestAlan.test_project ___________________________________________________________________________
Traceback (most recent call last):
  File "/Users/alancoding/Documents/repos/tower-qa/tests/api/test_alan.py", line 184, in test_project
    factories.job_template()
  File "/Users/alancoding/Documents/repos/tower-qa/tests/lib/fixtures/factory_fixtures.py", line 199, in __call__
    return self._has_create_factory(request=self.request, **kwargs)
  File "/Users/alancoding/Documents/repos/tower-qa/tests/lib/fixtures/factory_fixtures.py", line 59, in __call__
    has_create = cls.model(connection).create(**kwargs)
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/pages/job_templates.py", line 179, in create
    self.connection).post(payload))
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/pages/page.py", line 307, in post
    return self.page_identity(r, request_json=json)
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/pages/page.py", line 260, in page_identity
    raise exc.BadRequest(exc_str, data)
awxkit.exceptions.BadRequest: {'playbook': ['Playbook not found for project.']}

error after:

tests/api/test_alan.py::TestAlan::test_project FAILED                                                                                                                [100%]

================================================================================= FAILURES =================================================================================
__________________________________________________________________________ TestAlan.test_project ___________________________________________________________________________
Traceback (most recent call last):
  File "/Users/alancoding/Documents/repos/tower-qa/tests/api/test_alan.py", line 184, in test_project
    factories.job_template()
  File "/Users/alancoding/Documents/repos/tower-qa/tests/lib/fixtures/factory_fixtures.py", line 199, in __call__
    return self._has_create_factory(request=self.request, **kwargs)
  File "/Users/alancoding/Documents/repos/tower-qa/tests/lib/fixtures/factory_fixtures.py", line 59, in __call__
    has_create = cls.model(connection).create(**kwargs)
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/pages/job_templates.py", line 176, in create
    project=project, **kwargs)
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/pages/job_templates.py", line 147, in create_payload
    Project)))
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/mixins/has_create.py", line 360, in create_and_update_dependencies
    created = to_create(self.connection).create(**scoped_args)
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/pages/projects.py", line 116, in create
    update.wait_until_completed().assert_successful()
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/mixins/has_status.py", line 92, in assert_successful
    return self.assert_status('successful', msg=msg)
  File "/Users/alancoding/Documents/tower/awxkit/awxkit/api/mixins/has_status.py", line 89, in assert_status
    raise AssertionError(msg)
AssertionError: Project_Update-384 has status of error, which is not in ['successful'].
result_traceback:
Traceback (most recent call last):
  File "/awx_devel/awx/main/tasks.py", line 1275, in run
    self.pre_run_hook(self.instance, private_data_dir)
  File "/awx_devel/awx/main/tasks.py", line 2231, in pre_run_hook
    os.mkdir(settings.PROJECTS_ROOT)
FileExistsError: [Errno 17] File exists: '/var/lib/awx/projects/'

TIME WHEN STATUS WAS FOUND: 2020-02-12 14:30:24.729099 (UTC)

Under nominal conditions, this isn't expected to ever fail, unless github isn't working or the configured default project URL is bad. But that's actually a pretty good point about github, there are some things we can't control.

...but in this particular example I'm showing there, I just messed up my environment (remember those file permission errors we've had other times?). I suspect there are several cases where this will be a frustrating-reducing change.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@ryanpetrello
Copy link
Contributor

Seems reasonable to me.

@AlanCoding
Copy link
Member Author

hit some turbulence getting this fully tested, will check back in later

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@softwarefactory-project-zuul
Copy link
Contributor

Build failed.

@AlanCoding
Copy link
Member Author

recheck

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants