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

Avoid processing fact yaml files with empty 'values' hash #717

Merged

Conversation

antaflos
Copy link
Contributor

Under certain conditions it can happen that Puppet Server creates a fact
yaml file for a node that contains an empty values hash, for example
when multiple Puppet Servers are accessed through a load balancer like
HAProxy where Puppet agent requests are distributed equally and randomly.

When trying to process such a facts file with an empty values hash
Foreman will reject the HTTP request with an error message like this:

During the fact upload the server responded with: 422 Unprocessable Entity. Error is ignored and the execution continues.
{"message":"ERF42-3829 [Foreman::Exception]: invalid facts, missing operating system value"}

This change adds a simple method that loads the fact yaml file and
returns true if the values hash is empty. Such fact yaml files are
then skipped when processing host facts and a warning is written to
STDOUT. The Puppet administrator can then examine and delete any invalid
fact yaml files.

Under certain conditions it can happen that Puppet Server creates a fact
yaml file for a node that contains an empty `values` hash, for example
when multiple Puppet Servers are accessed through a load balancer like
HAProxy where Puppet agent requests are distributed equally and randomly.

When trying to process such a facts file with an empty `values` hash
Foreman will reject the HTTP request with an error message like this:

    During the fact upload the server responded with: 422 Unprocessable Entity. Error is ignored and the execution continues.
    {"message":"ERF42-3829 [Foreman::Exception]: invalid facts, missing operating system value"}

This change adds a simple method that loads the fact yaml file and
returns true if the `values` hash is empty. Such fact yaml files are
then skipped when processing host facts and a warning is written to
STDOUT. The Puppet administrator can then examine and delete any invalid
fact yaml files.
@antaflos antaflos force-pushed the external_node_v2_empty_facts_hash branch from 72aea85 to 7dfedb3 Compare March 12, 2019 16:57
@antaflos
Copy link
Contributor Author

The test failures seem unrelated to the changes in this PR.

@mmoll mmoll merged commit f9d2c0b into theforeman:master Apr 5, 2019
@mmoll
Copy link
Contributor

mmoll commented Apr 5, 2019

merged, thanks @antaflos!

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

Successfully merging this pull request may close these issues.

4 participants