Add state coercion helper function for drive checks#28
Open
uh-dk wants to merge 1 commit intoiteratio-com:mainfrom
Open
Add state coercion helper function for drive checks#28uh-dk wants to merge 1 commit intoiteratio-com:mainfrom
uh-dk wants to merge 1 commit intoiteratio-com:mainfrom
Conversation
Add _to_state helper to safely coerce values (State / int / str) into a State with a fallback. Accept custom ava_map / opa_map entries that are strings, ints or State instances (no longer crash on unexpected types or None). Allow cleaning_needed rule to be supplied as State/int/str and normalize it (default remains WARN). Small robustness improvements to avoid exceptions when rule values are missing or invalid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The current version crashes if the tape library reports "Cleaning needed"
Operating System: Ubuntu 22.04.5 LTS
Checkmk Version: 2.3.0p41
Edition: cme
Crash Report
Exception
TypeError ('state' must be a checkmk State constant, got 1)Traceback
File "/omd/sites/intern/lib/python3/cmk/base/checkers.py", line 734, in get_aggregated_result check_result = check_function(**item_kw, **params_kw, **section_kws) File "/omd/sites/intern/lib/python3/cmk/base/checkers.py", line 514, in __check_function return _aggregate_results(consume_check_results(check_function(*args, **kw))) File "/omd/sites/intern/lib/python3/cmk/base/checkers.py", line 572, in consume_check_results for subr in subresults: File "/omd/sites/intern/lib/python3/cmk/base/api/agent_based/register/check_plugins.py", line 95, in filtered_generator for element in generator(*args, **kwargs): File "/omd/sites/intern/local/lib/python3/cmk_addons/plugins/dell_emc_ml3/agent_based/dell_emc_ml3_drive.py", line 91, in check_dell_emc_ml3_drive if params.get("ava_map"): File "/omd/sites/intern/lib/python3.12/site-packages/cmk/agent_based/v1/_checking_classes.py", line 404, in __new__ state, summary, details = _create_result_fields(**kwargs) # type: ignore[misc] File "/omd/sites/intern/lib/python3.12/site-packages/cmk/agent_based/v1/_checking_classes.py", line 430, in _create_result_fields raise TypeError(f"'state' must be a checkmk State constant, got {state}")Local Variables
{'details': None, 'notice': None, 'state': 1, 'summary': 'Cleaning Status: cleaning needed'}