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
[dev.icinga.com #11207] unable to refer to array variable inside for loop #3959
Comments
Updated by gbeutner on 2016-02-23 10:51:49 +00:00 Do you have any hosts where the 'checks' attribute is set to a string? |
Updated by gbeutner on 2016-02-23 10:52:28 +00:00 (Also, if so, we should probably improve error handling to mention the host's name where we encountered the error.) |
Updated by kowalskimn on 2016-02-24 13:34:59 +00:00 Okay i think figured it out : assign where "bloat" in config.pgchecks (i renamed the variable, just in case there was a duplicate somewhere). i have to refer by "config" variable, for some reason. This way i get correct data types (Array) and i can do the match. And it seems to work fine, too - i added two databases, one with less checks than the other, and rules apply correctly. This is on 2.4.2-1 , contrary to original bug report. |
Updated by mfriedrich on 2016-02-24 19:36:35 +00:00
apply for iterates over the databases dictionary using the key => value notation. In your example, the following applies for the first iteration:
Since the for "condition" is evaluated first, and then the assign/ignore where expressions it is possible to reference local variables inside the apply for definition. For example "config". Using the indexer "." to access the "checks" key inside your "config" directory, and you'll get the value - your array where you'll use intersection to check availability. So your attempt is totally fine, just wrap your head around what's happening :) You could also use the script debugger and print the objects and attributes in this specific context then. This will also unveil the objects name where this problem comes up. As Gunnar suggested we should fix the log message adding more visible context to it. |
Updated by mfriedrich on 2016-02-25 00:11:37 +00:00
|
Updated by mfriedrich on 2016-02-25 00:12:11 +00:00
Just found #9182 ... I'm closing this one here, and we'll fix the other one. |
This issue has been migrated from Redmine: https://dev.icinga.com/issues/11207
Created by kowalskimn on 2016-02-23 10:27:24 +00:00
Assignee: (none)
Status: Closed (closed on 2016-02-25 00:12:11 +00:00)
Target Version: (none)
Last Update: 2016-02-25 00:12:11 +00:00 (in Redmine)
I have a host defined like so :
I am trying to do the following:
The assign conditions fail with error
critical/config: Error: Invalid field access (for value of type 'String'): 'checks'
It seems like some kind of type interpretation mistake to me, unless this construction is totally wrong.
Relations:
The text was updated successfully, but these errors were encountered: