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

Wrong number of arguments given #194

Closed
altvnk opened this issue Oct 15, 2015 · 14 comments
Closed

Wrong number of arguments given #194

altvnk opened this issue Oct 15, 2015 · 14 comments

Comments

@altvnk
Copy link

altvnk commented Oct 15, 2015

Error 400 on SERVER: sorted_json(): Wrong number of arguments given (3 for 1) at /etc/puppet/environments/production/modules/consul/manifests/config.pp:97 on node m-master-01

Can you please explain what this thing want from me? Used default config like:

  $consulnodes = query_nodes("Class[Profiles::Consul::Server] and location=${::location}", ipaddress)

  $datacenter = downcase($::location)

  class { '::consul':
    config_hash => {
      'bootstrap_expect' => 3,
      'client_addr'      => '0.0.0.0',
      'data_dir'         => '/opt/consul',
      'datacenter'       => $datacenter,
      'log_level'        => 'INFO',
      'node_name'        => $::fqdn,
      'server'           => true,
      'ui_dir'           => '/opt/consul/ui',
      'rejoin_after_leave' => true,
      'retry_join'         => $consulnodes,
    }
  }
@altvnk
Copy link
Author

altvnk commented Oct 15, 2015

Sure. Here is simplest ever config i've just tried, result the same.
Cannot understand where it finds three arguments here. And yes, when query nodes is used it returns three ip addresses of consul server nodes.

  class { '::consul':
    config_hash => {
      'bootstrap_expect' => 1,
      'client_addr'      => '0.0.0.0',
      'data_dir'         => '/opt/consul',
      'datacenter'       => $datacenter,
      'log_level'        => 'INFO',
      'node_name'        => $::fqdn,
      'server'           => true,
      'ui_dir'           => '/opt/consul/ui'
    }
  }

@aj-jester
Copy link

I see the problem. For some reason the function being used in your puppet run is sorted_json(), but the function we use is consul_sorted_json().

https://github.com/solarkennedy/puppet-consul/blob/master/manifests/config.pp#L97
https://github.com/solarkennedy/puppet-consul/blob/master/lib/puppet/parser/functions/consul_sorted_json.rb

Can you tell me in your locally installed module whats files are in /etc/puppet/environments/production/modules/consul/lib/puppet/parser/functions/* and the contents of line 97 in /etc/puppet/environments/production/modules/consul/manifests/config.pp?

@altvnk
Copy link
Author

altvnk commented Oct 15, 2015

In functions/*

consul_sorted_json.rb:90:  newfunction(:consul_sorted_json, :type => :rvalue, :doc => <<-EOS
consul_sorted_json.rb:118:    consul_sorted_json(unsorted_hash)
consul_sorted_json.rb:129:    consul_sorted_json(unsorted_hash, true, 4)

In config.pp

config.pp:97:    content => consul_sorted_json($config_hash, $consul::pretty_config, $consul::pretty_config_indent),

@altvnk
Copy link
Author

altvnk commented Oct 15, 2015

Well, that's even more strange then...

@aj-jester
Copy link

HAHA but the error makes no sense: Error 400 on SERVER: sorted_json(): Wrong number of arguments given (3 for 1)

Can you delete the entire module, restart your puppetmaster, ensure the module isin't being picked up, install module again, restart puppetmaster. I've come across similar issues in the past with functions. Since these functions run on puppet MASTER (not the individual agents/nodes) it caches them and causes weird issues until puppetmaster has been restarted.

@altvnk
Copy link
Author

altvnk commented Oct 15, 2015

Oh, my excuses... Somehow puppet server cached old manifests (i always thinked it's impossible). After restarting apache all worked like a charm! Modules managed by r10k after hook from git repo, so i'm looking into modules on master rarely.
Anyway, thank you for your time!

PS: new module updated web_ui but didn't touched consul itself.

@altvnk altvnk closed this as completed Oct 15, 2015
@aj-jester
Copy link

Glad to see you got it resolved 👍

@mrh666
Copy link

mrh666 commented Mar 8, 2016

Hi there,

I have the same issue and I can't get rid of cache!
I uninstalled old KyleAnderson-consul, restarted httpd (foreman+Passenger install), installed KyleAnderson-consul 1.0.5, restarted httpd, removed cache on local node (rm -f /var/lib/puppet/client_data/catalog/*) and still no luck:

# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: sorted_json(): Wrong number of arguments given (3 for 1) at /etc/puppet/modules/consul/manifests/config.pp:100 on node influxdbnode-o4io894xlnj7mfg
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Any ideas please?

@solarkennedy
Copy link
Contributor

Pretty strange. @mrh666 can you look at /etc/puppet/modules/consul/ and manually inspect it to ensure it has a modern version of puppet-consul?

@mrh666
Copy link

mrh666 commented Mar 8, 2016

solarkennedy, sure!
Even like that:

$ puppet module uninstall KyleAnderson-consul
...output skipped...
$ rm -rf /etc/puppet/modules/consul
...output skipped...
$ service httpd restart
...output skipped...
$ puppet module install KyleAnderson-consul
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└─┬ KyleAnderson-consul (v1.0.5)
  ├── nanliu-staging (v1.0.3)
  └── puppetlabs-stdlib (v4.9.0)

$ service httpd restart

Check the config.pp:

$ tail -n 10 /etc/puppet/modules/consul/manifests/config.pp
  file { 'consul config.json':
    ensure  => present,
    path    => "${consul::config_dir}/config.json",
    owner   => $consul::user,
    group   => $consul::group,
    mode    => $consul::config_mode,
    content => consul_sorted_json($config_hash, $consul::pretty_config, $consul::pretty_config_indent),
  }
}

On the instance:

$ rm -f /var/lib/puppet/client_data/catalog/*
$ puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: sorted_json(): Wrong number of arguments given (3 for 1) at /etc/puppet/modules/consul/manifests/config.pp:100 on node influxdbnode-o4io894xlnj7mfg
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I can't believe but it's cached somehow or ...

@mrh666
Copy link

mrh666 commented Mar 8, 2016

solarkennedy, Just in case I deployed a new instance. Same story, it's cached on master:

Mar  8 18:23:02 influxdbnode-172 puppet-agent[1391]: Could not retrieve catalog from remote server: Error 400 on SERVER: sorted_json(): Wrong number of arguments given (3 for 1) at /etc/puppet/modules/consul/manifests/config.pp:100 on node influxdbnode-s72ogotxbnces67

@hopperd
Copy link
Contributor

hopperd commented Mar 9, 2016

@mrh666 did you restart the puppet master and try again? Puppet caches function eternally until a restart of the puppet master.

@mrh666
Copy link

mrh666 commented Mar 10, 2016

@Split3, sure I did. And just in case I did it again:

touch /etc/puppet/rack/tmp/restart.txt
service foreman-proxy restart
service httpd restart

I can see all the processes are running from the moment I restarted them 14:12 - 14:13:

[root@ip-172 ~]# ps xau | egrep "rack|httpd|pupp"
root      4428  0.0  0.1 155652  6052 ?        Ss   14:12   0:00 /usr/sbin/httpd
apache    4449  0.1  0.1 155960  6220 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4450  0.2  0.1 155964  6228 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4451  0.1  0.1 155964  6228 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4452  0.1  0.1 155912  6216 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4453  0.0  0.1 155912  6232 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4454  0.0  0.1 155988  6240 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4455  0.1  0.1 155920  6236 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4456  0.0  0.1 155928  6212 ?        S    14:12   0:00 /usr/sbin/httpd
puppet    4461  0.4  1.7 157372 65192 ?        Sl   14:12   0:01 Passenger AppPreloader: /etc/puppet/rack
apache    4491  0.1  0.1 155964  6236 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4520  0.1  0.1 155960  6172 ?        S    14:12   0:00 /usr/sbin/httpd
apache    4521  0.1  0.1 155944  6216 ?        S    14:12   0:00 /usr/sbin/httpd
puppet    4531  4.1  3.0 218968 114688 ?       Sl   14:12   0:13 Passenger RackApp: /etc/puppet/rack
puppet    4535  4.0  2.9 214660 109820 ?       Sl   14:12   0:12 Passenger RackApp: /etc/puppet/rack
puppet    4542  6.5  3.1 223256 119036 ?       Sl   14:12   0:20 Passenger RackApp: /etc/puppet/rack
puppet    4548  3.9  3.0 226104 112096 ?       Sl   14:12   0:12 Passenger RackApp: /etc/puppet/rack
apache    4632  0.0  0.1 155948  6220 ?        S    14:13   0:00 /usr/sbin/httpd
apache    4634  0.0  0.1 155888  6184 ?        S    14:13   0:00 /usr/sbin/httpd
apache    4635  0.1  0.1 155920  6196 ?        S    14:13   0:00 /usr/sbin/httpd
puppet    4637  8.0  3.4 234408 130044 ?       Sl   14:13   0:23 Passenger RackApp: /etc/puppet/rack
apache    4645  0.0  0.1 155892  6216 ?        S    14:13   0:00 /usr/sbin/httpd
apache    4646  0.0  0.1 155988  6248 ?        S    14:13   0:00 /usr/sbin/httpd
apache    4647  0.0  0.1 155952  6228 ?        S    14:13   0:00 /usr/sbin/httpd
apache    4648  0.1  0.1 155940  6136 ?        S    14:13   0:00 /usr/sbin/httpd
apache    4678  0.1  0.1 155944  6212 ?        S    14:13   0:00 /usr/sbin/httpd
apache    4700  0.1  0.1 155928  6212 ?        S    14:13   0:00 /usr/sbin/httpd
root      5119  0.0  1.1 135656 44272 ?        Ss   14:15   0:00 /usr/bin/ruby /usr/bin/puppet agent

And I still getting obsolete manifest on node:

[root@influxdbnode-172 ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: sorted_json(): Wrong number of arguments given (3 for 1) at /etc/puppet/modules/consul/manifests/config.pp:100 on node influxdbnode-o4io894xlnj7mfg
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

Any idea how can I coerce Puppet Master to reset the cache?

@gabaynati
Copy link

Hi,
You probably use different consul_sorted_json.rb from another custom Puppet module.
search for consul_sorted_json in /environments path on the master

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

No branches or pull requests

6 participants