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

parse job events to extract failure messages #310

Conversation

d-honeybadger
Copy link
Collaborator

@d-honeybadger d-honeybadger commented Feb 15, 2024

Description of your changes

Follow-up for #228
In #294, we set the Ready condition, but the message on the condition was just the ansible-runner's exit code.
In this PR, the message is enhanced with the failure reason(s) from ansible logs.

Btw, parsing these job events can also help with #290 - there's a "summary" event at the end of playbook execution wich has the same info as ansible summary in the logs

I have:

  • Read and followed Crossplane's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Created an ansiblerun with a failure, an unreachable host, and successful execution.
Here are examples of the conditions of the failed ones:

  - lastTransitionTime: "2024-02-15T22:29:06Z"
    message: 'observe failed: running ansible: exit status 2: Failed on play "test",
      task "file", host "test": file (/test4) is absent, cannot continue'
    reason: ReconcileError
    status: "False"
    type: Synced

  - lastTransitionTime: "2024-02-15T19:55:58Z"
    message: 'observe failed: running ansible: exit status 4: Unreachable on play
      "test", task "Gathering Facts", host "test": Failed to connect to the host via
      ssh: [email protected]: Permission denied (publickey,password).'
    reason: ReconcileError
    status: "False"
    type: Synced

@d-honeybadger d-honeybadger force-pushed the extract-failure-msg-from-job-events branch from 29261a9 to d18513d Compare February 15, 2024 17:29
@d-honeybadger d-honeybadger marked this pull request as ready for review February 15, 2024 22:21
@fahedouch fahedouch added this to the v0.5.1 (tentative) milestone Feb 24, 2024
internal/ansible/ansible.go Outdated Show resolved Hide resolved
internal/ansible/ansible.go Outdated Show resolved Hide resolved
internal/ansible/ansible.go Outdated Show resolved Hide resolved
@fahedouch
Copy link
Collaborator

@d-honeybadger this PR need a a rebase :)

@d-honeybadger d-honeybadger force-pushed the extract-failure-msg-from-job-events branch 2 times, most recently from 65b2e0b to 42aed99 Compare March 9, 2024 00:21
@d-honeybadger d-honeybadger force-pushed the extract-failure-msg-from-job-events branch from 42aed99 to 56cc685 Compare March 9, 2024 00:36
@fahedouch
Copy link
Collaborator

LGTM. Thanks @d-honeybadger

@fahedouch fahedouch merged commit f5ad348 into crossplane-contrib:main Mar 9, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants