#159 roles/testing-farm*: handle non json output
Merged 2 years ago by zuul. Opened 2 years ago by mvadkert.
mvadkert/fedora-zuul-jobs TFT-1553  into  master

@@ -81,8 +81,7 @@ 

      status_code: 200

      timeout: 30

    register: response

-   until: response.json.state == "complete" or

-     response.json.state == "error"

+   until: "'json' in response and (response.json.state == 'complete' or response.json.state == 'error')"

    retries: 720

    delay: 60

    ignore_errors: true

@@ -61,8 +61,7 @@ 

      status_code: 200

      timeout: 30

    register: response

-   until: response.json.state == "complete" or

-     response.json.state == "error"

+   until: "'json' in response and (response.json.state == 'complete' or response.json.state == 'error')"

    retries: 720

    delay: 60

    ignore_errors: true

Obviously it can happen the response is invalid and it
is not a valid json, so add a check to make sure we process
only json output.

Resolves TFT-1553

Related to https://centos.softwarefactory-project.io/zuul/t/centos/build/7da5eeee4b34470c92b4bd59b4ca54cf/console

Signed-off-by: Miroslav Vadkerti mvadkert@redhat.com

Tested manually via:

❯ ansible -c localhost -m debug -e '{ "response": { "tutu": { "state": "complete" }}}' -a "msg={{ 'json' in response and (response.json.state == 'complete' or response.json.state == 'error') }}" localhost
localhost | SUCCESS => {
    "msg": false
}

❯ ansible -c localhost -m debug -e '{ "response": { "json": { "state": "complete" }}}' -a "msg={{ 'json' in response and (response.json.state == 'complete' or response.json.state == 'error') }}" localhost
localhost | SUCCESS => {
    "msg": true
}

Build succeeded.

@fbo @tdecacqu hi guys, kindly asking for merge

Build succeeded.

Metadata Update from @tdecacqu:
- Pull-request tagged with: gateit

2 years ago

Build succeeded (gate pipeline).

Pull-Request has been merged by zuul

2 years ago

@mvadkert thanks for the ping, it should be good now

Oh, thanks, I completely forgot about that tag, next time :)