Jira (PUP-9290) `puppet facts upload` always uses environment "production" ignoring setting from puppet.conf

26 views
Skip to first unread message

Greg Dubicki (JIRA)

unread,
Oct 30, 2018, 8:38:02 AM10/30/18
to puppe...@googlegroups.com
Greg Dubicki created an issue
 
Puppet / Bug PUP-9290
`puppet facts upload` always uses environment "production" ignoring setting from puppet.conf
Issue Type: Bug Bug
Affects Versions: PUP 5.5.2
Assignee: Unassigned
Created: 2018/10/30 5:37 AM
Priority: Major Major
Reporter: Greg Dubicki

We have nodes with environment different than default "production", in here it's "qa":

[ro...@app03.XXX:~]# cat /etc/puppet/puppet.conf
(...)
[agent]
report      = true
runinterval = 1800
environment = qa
splay = true

But if we upload facts using `puppet facts upload` always environment "production" is being used:

[ro...@app03.XXX:~]# /opt/puppetlabs/puppet/bin/puppet facts upload --debug
Debug: Runtime environment: puppet_version=5.5.2, ruby_version=2.4.4, run_mode=user, default_encoding=UTF-8
Debug: Evicting cache entry for environment 'production'
(...)

We observe than then in puppetdb, because facts from such nodes have "facts_environment" set to "production", while "report_environment" and "catalog_environment" are set correctly to "qa".

If you simply run "puppet agent -t" facts with correct environment, "qa", are being uploaded.

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Greg Dubicki (JIRA)

unread,
Oct 30, 2018, 8:40:02 AM10/30/18
to puppe...@googlegroups.com
Greg Dubicki updated an issue
Change By: Greg Dubicki
We have nodes with environment different than default "production", in here it's "qa":
{code}

[ro...@app03.XXX:~]# cat /etc/puppet/puppet.conf
(...)
[agent]
report      = true
runinterval = 1800
environment = qa
splay = true
{code}


But if we upload facts using `puppet facts upload` always environment "production" is being used:
{code}

[ro...@app03.XXX:~]# /opt/puppetlabs/puppet/bin/puppet facts upload --debug
Debug: Runtime environment: puppet_version=5.5.2, ruby_version=2.4.4, run_mode=user, default_encoding=UTF-8
Debug: Evicting cache entry for environment 'production'
(...)
{code}

We observe than then in In puppetdb , because facts from such nodes have "facts_environment" set to "production", while "report_environment" and "catalog_environment" are set correctly to "qa".


If you simply run "puppet agent -t" facts with correct environment, "qa", are being uploaded.

Greg Dubicki (JIRA)

unread,
Oct 30, 2018, 8:48:02 AM10/30/18
to puppe...@googlegroups.com
Greg Dubicki commented on Bug PUP-9290
 
Re: `puppet facts upload` always uses environment "production" ignoring setting from puppet.conf

Running `/opt/puppetlabs/puppet/bin/puppet facts upload --environment qa` does not help.

Josh Cooper (JIRA)

unread,
Oct 30, 2018, 11:57:03 AM10/30/18
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-9290

In lib/puppet/face/facts.rb, we need to specify the environment when trying to save the facts, something like:

      Puppet::Node::Facts.indirection.save(facts, nil, :environment => Puppet::Node::Environment.remote(Puppet[:environment]))

Josh Cooper (JIRA)

unread,
Oct 30, 2018, 11:57:05 AM10/30/18
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Oct 30, 2018, 11:57:05 AM10/30/18
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Nov 1, 2018, 2:16:05 PM11/1/18
to puppe...@googlegroups.com

Greg Dubicki (JIRA)

unread,
Feb 21, 2019, 6:49:02 AM2/21/19
to puppe...@googlegroups.com

Ievgen Prokhorenko (JIRA)

unread,
Jul 14, 2019, 6:40:02 PM7/14/19
to puppe...@googlegroups.com

Josh Cooper (JIRA)

unread,
Jul 16, 2019, 6:27:03 PM7/16/19
to puppe...@googlegroups.com
Josh Cooper commented on Bug PUP-9290
 
Re: `puppet facts upload` always uses environment "production" ignoring setting from puppet.conf

Sorry for the back and forth on this. The root cause occurs because environment is set in the agent section, however, only the puppet agent application reads settings from there. The puppet facts application uses the user section, and since environment isn't specified there, it defaults to production.

You will need to:

1. Set environment in both agent and user sections
OR
2. Set environment in the main section, provided the host is an agent-only, and is not a puppetserver node.

Note specifying the environment on the command line should work as expected, provided there is an environment directory with that name on the puppetserver:

$ bx puppet facts upload --environment qa --http_debug 2>&1 | grep HTTP
<- "PUT /puppet/v3/facts/localhost?environment=qa& HTTP/1.1\r\nAccept: application/json, application/x-msgpack, text/pson\r\nX-Puppet-Version: 5.5.2\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nContent-Type: application/json\r\nUser-Agent: Puppet/5.5.2 Ruby/2.6.2-p47 (x86_64-darwin18)\r\nConnection: close\r\nHost: puppet.delivery.puppetlabs.net:8140\r\nContent-Length: 3948\r\n\r\n"
-> "HTTP/1.1 200 OK\r\n"

The reason my suggested fix earlier is not necessary, is because the indirector request defaults to the current environment.

I'm going to close this ticket as incomplete, but I'll move the current PR forward so that the environment is passed explicitly.

Greg Dubicki (Jira)

unread,
Nov 29, 2020, 4:03:02 PM11/29/20
to puppe...@googlegroups.com
Greg Dubicki commented on Bug PUP-9290

For posterity:

The resubmit_facts feature added in Puppet 5.5.18 / 6.4.5 / 6.11.0 (PUP-5934) ALSO uses the env from the "user" / "main" section, not the "agent".

This message was sent by Atlassian Jira (v8.5.2#805002-sha1:a66f935)
Atlassian logo

Josh Cooper (Jira)

unread,
Aug 3, 2021, 6:13:04 PM8/3/21
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sprint:
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Josh Cooper (Jira)

unread,
Aug 3, 2021, 6:13:05 PM8/3/21
to puppe...@googlegroups.com

Josh Cooper (Jira)

unread,
Aug 3, 2021, 6:14:04 PM8/3/21
to puppe...@googlegroups.com

Greg Dubicki (Jira)

unread,
Jul 15, 2022, 10:14:03 AM7/15/22
to puppe...@googlegroups.com
Greg Dubicki commented on Bug PUP-9290
 
Re: `puppet facts upload` always uses environment "production" ignoring setting from puppet.conf

josh: I have revisited this and it turns out that for me the bug totally still is present and I don't see it as fixed in any way, sorry.

It is strange though as even if I force the request to be made like you do:

# puppet facts upload --environment qa --http_debug 2>&1 | grep HTTP
<- "PUT /puppet/v3/facts/my-fqdn?environment=qa& HTTP/1.1\r\nAccept: application/json, text/pson\r\nX-Puppet-Version: 5.5.22\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nContent-Type: application/json\r\nUser-Agent: Puppet/5.5.22 Ruby/2.4.10-p364 (x86_64-linux)\r\nConnection: close\r\nHost: qa-puppet.my-company.com:8140\r\nContent-Length: 22182\r\n\r\n"
-> "HTTP/1.1 200 OK\r\n"

...but when I query for this node with PQL in the PuppetDB I see:

  {
        "cached_catalog_status": "not_used",
        "catalog_environment": "qa",
        "catalog_timestamp": "2022-07-15T14:00:08.444Z",
        "certname": "my-fqdn",
        "deactivated": null,
        "expired": null,
        "facts_environment": "production",
        "facts_timestamp": "2022-07-15T14:06:42.362Z",
        "latest_report_corrective_change": null,
        "latest_report_hash": "d2181d7597287ada8c79c49c95e82ff15c191ceb",
        "latest_report_job_id": null,
        "latest_report_noop": false,
        "latest_report_noop_pending": false,
        "latest_report_status": "changed",
        "report_environment": "qa",
        "report_timestamp": "2022-07-15T14:00:34.804Z"
    }

This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo

Greg Dubicki (Jira)

unread,
Jul 15, 2022, 10:15:02 AM7/15/22
to puppe...@googlegroups.com
Greg Dubicki updated an issue
 
Change By: Greg Dubicki
Affects Version/s: PUP 5.5.2
Affects Version/s: PUP 5.5.22

Greg Dubicki (Jira)

unread,
Jul 15, 2022, 10:18:02 AM7/15/22
to puppe...@googlegroups.com
Greg Dubicki commented on Bug PUP-9290
 
Re: `puppet facts upload` always uses environment "production" ignoring setting from puppet.conf

Ok, I found the commit that was supposed to fix it - https://github.com/puppetlabs/puppet/commit/4cf6b04735dc280af0e0bd99560a7dc7eab2014a - and it is present in 5.5.17+, so I don't understand why it is not working for me...

Greg Dubicki (Jira)

unread,
Jul 15, 2022, 11:00:04 AM7/15/22
to puppe...@googlegroups.com
Greg Dubicki commented on Bug PUP-9290

I am currently using a config with the environment set in the "main" section and the env is "qa" regardless of the way I check it:

root@my-fqdn:~ # puppet config print environment --section user
qa
root@my-fqdn:~ # puppet config print environment --section agent
qa
root@my-fqdn:~ # puppet config print environment --section master
qa
root@my-fqdn:~ # puppet config print environment
qa

Greg Dubicki (Jira)

unread,
Jul 15, 2022, 11:02:05 AM7/15/22
to puppe...@googlegroups.com
Greg Dubicki commented on Bug PUP-9290

Nvm my last comment - it seems to be clear that what is happening on the node is correct. The question is: why PuppetDB after getting a request with facts with explicitly provided env ignores it and stores the facts with "production" env?

Josh Cooper (Jira)

unread,
Jul 18, 2022, 12:17:03 PM7/18/22
to puppe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages