rht-labs / labs-ci-cd

👻UNMAINTAINED - A collection of Red Hat Open Innovation Labs CI/CD components
Apache License 2.0
101 stars 70 forks source link

Nexus post step is not idempotent #228

Closed mcanoy closed 5 years ago

mcanoy commented 6 years ago

When adding roles/configure-nexus as a post step to my ci-cd project the playbook fails during the configure-nexus action on run attempts after the first run. (First time is successful).

  - name: nexus
    template: https://raw.githubusercontent.com/rht-labs/labs-ci-cd/v3.9.2/openshift-templates/nexus/template.yml
    params: "{{ playbook_dir }}/params/nexus/deploy"
    namespace: "{{ ci_cd_namespace }}"
    tags:
    - nexus
    post_steps:
    - role: "labs-ci-cd/roles/configure-nexus"

After a few runs of the applier I tried deleting the app and re-running (that didn't work either!).

Here is the delete output:

oc delete all -l app=nexus 
replicationcontroller "nexus-1" deleted
replicationcontroller "nexus-2" deleted
replicationcontroller "nexus-3" deleted
replicationcontroller "nexus-4" deleted
replicationcontroller "nexus-5" deleted
service "nexus" deleted
deploymentconfig.apps.openshift.io "nexus" deleted
imagestream.image.openshift.io "nexus" deleted
route.route.openshift.io "nexus" deleted

I don't think there should be that many rc. It seems like the pod is deleted on each run

Failure message

TASK [/var/folders/h4/8p0szgd158jb4cmwy3b6mfwh0000gp/T/ansible.uIlvnF/labs-ci-cd/roles/configure-nexus : Execute New Script] *************************************************************************
fatal: [ci-cd-tooling]: FAILED! => {"changed": false, "connection": "close", "content": "{\n  \"name\" : \"nist-proxy-repos\",\n  \"result\" : \"javax.script.ScriptException: org.sonatype.goodies.common.MultipleFailures$MultipleFailuresException: Failed to initialize facets; 1 failure\"\n}", "content_type": "application/json", "date": "Fri, 12 Oct 2018 16:43:33 GMT", "json": {"name": "nist-proxy-repos", "result": "javax.script.ScriptException: org.sonatype.goodies.common.MultipleFailures$MultipleFailuresException: Failed to initialize facets; 1 failure"}, "msg": "Status code was 400 and not [200]: HTTP Error 400: Bad Request", "redirected": false, "server": "Nexus/3.7.1-02 (OSS)", "set_cookie": "dtCookie=5$FE09C61E29F95EF6676C8DD58A5FCC7B; Path=/; Domain=.rht-labs.com, 622c39bce33d0e3a0ae73d50d318ac92=c447ae4961f6c8136af3c4368ec919cb; path=/; HttpOnly", "status": 400, "url": "http://nexus.labs.com/service/siesta/rest/v1/script/nist-proxy-repos/run", "x_content_type_options": "nosniff", "x_frame_options": "SAMEORIGIN", "x_oneagent_js_injection": "true"}
mcanoy commented 6 years ago

I think there is 2 things going on here. One is that the applier is kicking off a config change on the nexus docker image (even though there isn't). In this case a failure will happen sometimes.

The other thing is there appears to be bug introduced in this commit https://github.com/rht-labs/labs-ci-cd/commit/1610cbe57441d07019a40758673fd1c85ca1dd69 Where the name of the repo being checked for existence is not the same name as the repo being created. cc: @InfoSec812

oybed commented 5 years ago

The configure-nexus role has been moved to https://github.com/redhat-cop/infra-ansible/tree/master/roles/config-nexus, so this issue should be addressed in there.

@InfoSec812 FYI