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

Evaluation Error: Unknown variable: '_sort_options_alphabetic'. #577

Open
kBite opened this issue Aug 30, 2023 · 0 comments
Open

Evaluation Error: Unknown variable: '_sort_options_alphabetic'. #577

kBite opened this issue Aug 30, 2023 · 0 comments

Comments

@kBite
Copy link

kBite commented Aug 30, 2023

EDIT: Well, only saw the PR after submitting. This issue is fixed by #576


While testing v7.2.0 I noticed Puppet runs failing due to Evaluation Error: Unknown variable: '_sort_options_alphabetic'.

Info: Using environment 'haproxy_v7_2_0'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Unknown variable: '_sort_options_alphabetic'. (file: /etc/puppetlabs/code/environments/haproxy_v7_2_0/modules/haproxy/manifests/backend.pp, line: 132, column: 35) on node some-server.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

With conversion of *.erb to *.epp templates $_sort_options_alphabetic is now given as template parameter:

$parameters = {
  'section_name'             => $section_name,
  'mode'                     => $mode,
  'description'              => $description,
  '_sort_options_alphabetic' => $_sort_options_alphabetic,
  'options'                  => $options,
}

This surfaces a bug in the variables assignment logic: in case $options is a Hash, but the key option does not contain httpchk $_sort_options_alphabetic stays undefined (e.g. when using tcp-check instead).

...
  if $options.is_a(Hash) and 'option' in $options {
    if ('httpchk' in $options['option']) {
      warning('Overriding the value of $sort_options_alphabetic to "false" due to "httpchk" option defined')
      $_sort_options_alphabetic = false
    }
  } else {
    ...
  }
...

This wasn't an issue before, because the variable was only evaluated in the *.erb template. It was effectively treated as false.

There are multiple options to resolve this: (1) adding or ('tcp-check' in $options['option']) to the condition, (2) adding an else or elsif, (3) adding pick($_sort_options_alphabetic, false) to the parameters hash, or ... some less minimal options like refactoring the assignment and others I didn't think of.


On a side note: pick() is either redundant on line 108 or the stdlib's description of pick() isn't (fully) correct

$picked_sort_options_alphabetic = pick($sort_options_alphabetic, $haproxy::globals::sort_options_alphabetic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants