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

{"error":["Field 'policy_name' invalid"]} running @ v0.10.0 gem chef-api #82

Open
Doltair opened this issue Oct 22, 2019 · 7 comments
Open

Comments

@Doltair
Copy link

Doltair commented Oct 22, 2019

Hi, @tas50 Good day!

We tried using the latest gem v0.10.0, but we're having issues into it. Below are the error encountered.

Description

 {"error":["Field 'policy_name' invalid"]}
    from /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/chef-api-0.10.0/lib/chef-api/connection.rb:304:in `block in request'
    from /opt/chefdk/embedded/lib/ruby/2.6.0/net/http.rb:920:in `start'
    from /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/chef-api-0.10.0/lib/chef-api/connection.rb:290:in `request'
    from /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/chef-api-0.10.0/lib/chef-api/connection.rb:142:in `put'
    from /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/chef-api-0.10.0/lib/chef-api/resources/base.rb:162:in `put'
    from /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/chef-api-0.10.0/lib/chef-api/resources/base.rb:685:in `save!'
    from /home/jenkins/.chefdk/gem/ruby/2.6.0/gems/chef-api-0.10.0/lib/chef-api/aclable.rb:23:in `save!'
    from patch_build_core.rb:76:in `block (3 levels) in <main>'
    from patch_build_core.rb:70:in `each'
    from patch_build_core.rb:70:in `block (2 levels) in <main>'
    from patch_build_core.rb:66:in `each'
    from patch_build_core.rb:66:in `block in <main>'
    from patch_build_core.rb:61:in `each'
@jtatum
Copy link

jtatum commented Dec 12, 2019

We looked into this. The node object adds attributes for policy_name and policy_group: https://github.com/chef/chef-api/blob/cfafa5a32f3d98d102c0a873a8d67c57abcfa2f4/lib/chef-api/resources/node.rb#L13-L14

Assuming you want to create a node without these attributes, you must remove them.

A better fix might be changing the serialization so that these attributes are omitted if nil.

@Doltair
Copy link
Author

Doltair commented Jan 17, 2020

Thank you @jtatum for looking at this.

Yeah, we we're just updating attributes for the node, like run_lists and normal attributes through chef-api but yeah it seems its appending or looking for the policy attribute? What will be our temporary solution to this? anyhow we're still using none v0.10's version.

@Doltair
Copy link
Author

Doltair commented Mar 9, 2020

Hi @tas50 , @jtatum just a query, about changes in v0.10.5 in nodes resources,

  attribute :run_list,     type: Array,  default: []

What was changed and it does not perform any updates to chef server?

Doing like:

nodes.update(run_list_add, 'run_list' => @run_lists_add)

Nothing happens compared before v0.10.x? and the node attributes are not updated. Thank you so much!

@Doltair
Copy link
Author

Doltair commented Apr 3, 2020

Hi @jtatum , if we will be modifying/updating an existing node like run_list and normal attributes using gem 0.10.x, what should be the values for this?

attribute :policy_name, type: String

Your recommendation and comment are very much appreciated. Thank you!

FYI @tas50

@jtatum
Copy link

jtatum commented May 3, 2020

@Doltair policy_name is the name of the Chef policy. If you don't know what policies are in Chef, you probably don't want to set a policy_name or a policy_group. The problem is, this gem sends both, whether you set one or not. We chose to fork this gem and and delete the policy_name and policy_group attributes. That's a workaround, not a "fix" though because the gem needs to support policy_name and/or policy_group when one is supplied.

@chakri-pd
Copy link

To add further context, chef policies are optional. If you choose not to have, it is set to null.
I ran into the same problem when nodes.updates was called, it augments the payload with policy_name, policy_group, and barf.
Removing policy_name, policy_group, or marking them as optional is reasonable.
(cc @tas50 )

@Doltair
Copy link
Author

Doltair commented Nov 27, 2020

Hi @tas50 , this repo has been marked as Deprecated. Is there a plan to write a new project to replace this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants