ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
818 stars 1.5k forks source link

jenklins-build module does not wait #7013

Open herranzf opened 1 year ago

herranzf commented 1 year ago

Summary

I have a random error when I run the "jenkins_build" module.

- name: "Create a jenkins build CIS Benchmark pipeline"
  community.general.jenkins_build:
    name: "{{ jk_path_cis_benchmark_pipeline }}"
    args:
      target_host: "{{ target_host }}" 
      cis_benchmark_name: "{{ cis_benchmark_name }}" 
      cis_credential: "{{ cis_credential }}" 
      cis_parameters: "{{ cis_parameters }}" 
      cis_separator: "{{ cis_separator }}"
      jk_path_cis_benchmark: "{{ jk_path_cis_benchmark }}"
    state: present
    user: "{{ jenkins_user }}"
    token: "{{ jenkins_token }}"
    url: "{{ jenkins_server }}"
  register: build_cis_status
  become: false

Sometimes it doesn't wait for the execution to finish and receives an incorrect completion status.

It is a random failure.

When it fails it returns an execution time of 0 ("executingTimeMillis": 0), and a successful status ("result": "SUCCESS"), even if the task completion is unsuccessful.

"build_info": { ... "buildableDurationMillis": 0, "buildableTimeMillis": 0, "buildingDurationMillis": 0, "executingTimeMillis": 0, "executorUtilization": 1.0, "subTaskCount": 0, "waitingDurationMillis": 5050, "waitingTimeMillis": 5050. ... "queueId": 23964990, "result": "SUCCESS", "timestamp": 1690366381728,. ...

}

Has anyone had a similar bug? Thanks.

Issue Type

Bug Report

Component Name

jenkins_build

Ansible Version

$ ansible --version
+ ansible --version
ansible [core 2.15.2]
  config file = /var/lib/jenkins/.ansible.cfg
  configured module search path = ['/var/lib/jenkins/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /jenkins/workspace/ployment_feature-initial-version/database-venv/lib/python3.9/site-packages/ansible
  ansible collection location = /var/lib/jenkins/workspace/ployment_feature-initial-version/collections
  executable location = /jenkins/workspace/ployment_feature-initial-version/database-venv/bin/ansible
  python version = 3.9.2 (default, Mar 14 2022, 15:14:56) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] (/jenkins/workspace/ployment_feature-initial-version/database-venv/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Community.general Version

$ ansible-galaxy collection list community.general
+ ansible-galaxy collection list community.general

# /jenkins/workspace/ployment_feature-initial-version/database-venv/lib/python3.9/site-packages/ansible_collections
Collection        Version
----------------- -------
community.general 7.2.0  

Configuration

$ ansible-config dump --only-changed
+ ansible-config dump --only-changed
ANSIBLE_FORCE_COLOR(env: ANSIBLE_FORCE_COLOR) = True
COLLECTIONS_PATHS(/var/lib/jenkins/.ansible.cfg) = ['/var/lib/jenkins/workspace/ployment_feature-initial-version/collections']
CONFIG_FILE() = /var/lib/jenkins/.ansible.cfg
DEFAULT_NO_LOG(/var/lib/jenkins/.ansible.cfg) = False
DEFAULT_NO_TARGET_SYSLOG(/var/lib/jenkins/.ansible.cfg) = True

OS / Environment

RHEL 7.9

Steps to Reproduce

    - name: "Create a jenkins build CIS Benchmark pipeline"
      community.general.jenkins_build:
        name: "{{ jk_path_cis_benchmark_pipeline }}"
        args:
          target_host: "{{ target_host }}" 
          cis_benchmark_name: "{{ cis_benchmark_name }}" 
          cis_credential: "{{ cis_credential }}" 
          cis_parameters: "{{ cis_parameters }}" 
          cis_separator: "{{ cis_separator }}"
          jk_path_cis_benchmark: "{{ jk_path_cis_benchmark }}"
        state: present
        user: "{{ jenkins_user }}"
        token: "{{ jenkins_token }}"
        url: "{{ jenkins_server }}"
      register: build_cis_status
      become: false

Expected Results

I expectect it wait to finishes the execution and recovers the correct state

Actual Results

Code of Conduct

ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 1 year ago

cc @brettmilford @unnecessary-username click here for bot help

brettmilford commented 1 year ago

Thanks @herranzf for reporting.

The module is a thin wrapper to the Jenkins REST API via the python module python-jenkins. Looking over its commit log it appears to have been fairly stable for some time so I don't think much has changed there that might be causing this.

My working theory is that there is some race condition in which the Jenkins REST API initially returns success prematurely.

herranzf commented 1 year ago

The problem continues. It keeps crashing randomly Has anyone had this happen to them?