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

Adds not_built to jenkins build states map #730

Closed

Conversation

vafhornung
Copy link
Contributor

General information

Check_MK not handling Jenkins Jobs with build result not_build correct:

Exception:KeyError (not_built)

Traceback

  File "/omd/sites/SITE/lib/python3/cmk/base/agent_based/checking/__init__.py", line 470, in get_aggregated_result
    result = _aggregate_results(
  File "/omd/sites/SITE/lib/python3/cmk/base/agent_based/checking/__init__.py", line 578, in _aggregate_results
    perfdata, results = _consume_and_dispatch_result_types(subresults)
  File "/omd/sites/SITE/lib/python3/cmk/base/agent_based/checking/__init__.py", line 622, in _consume_and_dispatch_result_types
    for subr in subresults:
  File "/omd/sites/SITE/lib/python3/cmk/base/api/agent_based/register/check_plugins.py", line 94, in filtered_generator
    for element in generator(*args, **kwargs):
  File "/omd/sites/SITE/lib/python3/cmk/base/plugins/agent_based/jenkins_jobs.py", line 163, in check_jenkins_jobs
    MAP_BUILD_STATES[job.build_result.lower()],
{'build_duration_key': 'jenkins_build_duration',
 'build_timestamp_key': 'jenkins_last_build',
 'infotext': 'State: Not built',
 'item': 'job-segment-6',
 'item_data': [(None,
                'job-segment-6',
                'notbuilt',
                100,
                1720524699.276,
                7261,
                'NOT_BUILT',
                130.836,
                1720530318)],
 'job': (None,
         'job-segment-6',
         'notbuilt',
         100,
         1720524699.276,
         7261,
         'NOT_BUILT',
         130.836,
         1720530318),
 'job_cleanup': 'notbuilt',
 'job_state': 'notbuilt',
 'now': 1720530577.4863226,
 'params': Parameters({'build_result': {'null': 0},
 'jenkins_last_build': (7200, 10800),
 'jenkins_time_since': (10800, 14400),
 'job_state': {'yellow': 0}}),
 'score_key': 'jenkins_job_score',

Proposed changes

Added state not_build to MAP_BUILD_STATES as State OK.

Copy link

github-actions bot commented Jul 9, 2024

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@vafhornung
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.

@logan-connolly
Copy link
Member

@vafhornung thank you for your contribution! Judging by the traceback, this indeed looks like a missing build state.

After discussing this with a team member, we decided it would be best to set the default state to WARN. This would of course be configurable with the following change which I'll amend to your commit:

diff --git a/cmk/plugins/jenkins/rulesets/jenkins_jobs.py b/cmk/plugins/jenkins/rulesets/jenkins_jobs.py
index bf310a5a975..d24970ecb97 100644
--- a/cmk/plugins/jenkins/rulesets/jenkins_jobs.py
+++ b/cmk/plugins/jenkins/rulesets/jenkins_jobs.py
@@ -155,6 +155,12 @@ def _parameter_valuespec_jenkins_jobs() -> Dictionary:
                                 prefill=DefaultValue(1),
                             )
                         ),
+                        "not_built": DictElement(
+                            parameter_form=ServiceState(
+                                title=Title("State when last build result is: module not built"),
+                                prefill=DefaultValue(1),
+                            )
+                        ),
                         "none": DictElement(
                             parameter_form=ServiceState(
                                 title=Title("State when build result is: running"),

Thanks again!

@CheckmkCI CheckmkCI closed this in dcb56ef Nov 8, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Nov 8, 2024
CheckmkCI pushed a commit that referenced this pull request Nov 8, 2024
The 'not_built' build result was missing from our internal state
mapping, causing our plugin to crash upon receiving this value from the
Jenkins API.

Closes: #730
Co-authored-by: Logan Connolly <[email protected]>
Change-Id: I1f2f134455ed7ee9e5320766bdd5a7e46a6fc18d
CheckmkCI pushed a commit that referenced this pull request Nov 8, 2024
The 'not_built' build result was missing from our internal state
mapping, causing our plugin to crash upon receiving this value from the
Jenkins API.

Closes: #730
Co-authored-by: Logan Connolly <[email protected]>
Change-Id: I1f2f134455ed7ee9e5320766bdd5a7e46a6fc18d
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants