Skip to content

Exception while declaring a service #22

@teintuc

Description

@teintuc

When applying a second time a simple kube service declaration:

$namespace="hello-world"

kubernetes_service { "$namespace-svc":
  ensure => present,
  require => [Kubernetes_namespace["$namespace"]],
  metadata => {
    name => $namespace,
    namespace => $namespace,
    labels => {
      'app' => $namespace
    },
  },
  spec => {
    ports => [{'port'=>80, 'targetPort'=>8080}],
    selector => {'app' => $namespace},
    type => 'LoadBalancer',
  },
}

It produces the following error:

Error: undefined method `keys' for "hello-world":String
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet_x/puppetlabs/swagger/fuzzy_compare.rb:30:in `test_complex_structure'
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet_x/puppetlabs/swagger/fuzzy_compare.rb:51:in `block (2 levels) in test_complex_structure'
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet_x/puppetlabs/swagger/fuzzy_compare.rb:50:in `collect'
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet_x/puppetlabs/swagger/fuzzy_compare.rb:50:in `block in test_complex_structure'
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet_x/puppetlabs/swagger/fuzzy_compare.rb:30:in `collect'
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet_x/puppetlabs/swagger/fuzzy_compare.rb:30:in `test_complex_structure'
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet_x/puppetlabs/swagger/fuzzy_compare.rb:22:in `fuzzy_compare'
/etc/puppetlabs/code/environments/production/modules/kubernetes/lib/puppet/type/kubernetes_service.rb:33:in `insync?'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/property.rb:277:in `safe_insync?'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:123:in `sync_if_needed'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/transaction/resource_harness.rb:88:in `block in perform_changes'

The reason is that in our case we have mcollective installed in the same ruby environment (which is the case of puppet AIO). Mcollective uses the stomp gem which also defines a symbolise_keys which is not recursive.
The keys from sub hashes are not transfomed to symbols which makes the fuzzy comparator unhappy.

The quick fix would be to rename the symbolise_key function to something more specific to this project.

Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions