Jira (FACT-2479) Uptime facts on LXC get the uptime from the host OS and not the container.

14 views
Skip to first unread message

Atanas Stoyanov (Jira)

unread,
Mar 20, 2020, 4:40:04 AM3/20/20
to puppe...@googlegroups.com
Atanas Stoyanov created an issue
 
Facter / Bug FACT-2479
Uptime facts on LXC get the uptime from the host OS and not the container.
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2020/03/20 1:39 AM
Environment:

OS: Ubuntu Bionic 18.04

Server: Puppetserver 6.7.1-1bionic

Agent: puppet-agent 6.10.1-1bionic

LXC: lxc 3.0.3-0ubuntu1~18.04.1

Priority: Normal Normal
Reporter: Atanas Stoyanov

Hello everyone,

On LXC the core facts in:

system_uptime -> hours
system_uptime -> seconds
system_uptime -> days
system_uptime -> uptime
uptime_hours
uptime_seconds
uptime_days
uptime

display the uptime of the host OS and not the LXC itself.

I am not sure where the uptime is taken and calculated from but a good source of truth would be the /proc/uptime, which displays the proper value inside the LXC.

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

Mihai Buzgau (Jira)

unread,
Mar 24, 2020, 7:47:03 AM3/24/20
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 24, 2020, 7:48:03 AM3/24/20
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Mar 24, 2020, 7:48:04 AM3/24/20
to puppe...@googlegroups.com

Oana Tanasoiu (Jira)

unread,
Apr 29, 2020, 10:11:03 AM4/29/20
to puppe...@googlegroups.com

Oana Tanasoiu (Jira)

unread,
Jul 15, 2020, 2:59:04 AM7/15/20
to puppe...@googlegroups.com

Mihai Buzgau (Jira)

unread,
Jul 15, 2020, 9:14:04 AM7/15/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Jul 22, 2020, 9:07:06 AM7/22/20
to puppe...@googlegroups.com

Florin Dragos (Jira)

unread,
Jul 29, 2020, 7:26:03 AM7/29/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Jul 29, 2020, 9:03:11 AM7/29/20
to puppe...@googlegroups.com

Florin Dragos (Jira)

unread,
Jul 30, 2020, 3:56:03 AM7/30/20
to puppe...@googlegroups.com
Florin Dragos commented on Bug FACT-2479
 
Re: Uptime facts on LXC get the uptime from the host OS and not the container.

Atanas Stoyanov, can you please provide some environment information like os/version ?

I've tried reproducing on ubuntu 18.04 and it looks like the uptime is ok:

root@antique-counter:~# facter uptime
0:42 hours
root@antique-counter:~# lxc exec ubuntu -- facter uptime
0:13 hours

Atanas Stoyanov (Jira)

unread,
Jul 31, 2020, 7:58:04 AM7/31/20
to puppe...@googlegroups.com

Hi,

Just a small clarification, we are not running LXD but pure LXC.

root@serv # facter uptime
1:00 hours
 
root@serv # # uptime
 13:47:36 up  1:00,  4 users,  load average: 0.12, 0.09, 0.16
 
root@serv # lxc-attach  -n ubuntu -- facter uptime
1:00 hours
 
root@serv # lxc-attach  -n ubuntu -- uptime
 13:47:43 up 28 min,  0 users,  load average: 0.10, 0.08, 0.16
 
root@serv # lxc-attach  -n ubuntu -- cat /proc/uptime
1694.00 1363.00

From the above you can see that the facter inside the container is as well returning exactly 1 hour (60 minutes) uptime, even though the container was started 28 minutes ago, which can be verified from the output of the uptime and cat /proc/uptime commands inside the container.

Both the host OS and the container are running Ubuntu Bionic 18.04, puppet client version is 6.14.0 on both.

For now we have resolved the issue by not using the system facts but building our custom fact:

#!/usr/bin/ruby
Facter.add("ia_uptime_seconds") do
    uptime_seconds = Facter::Util::Resolution.exec("/usr/bin/awk -F. '{print $1}' /proc/uptime")
    unless (uptime_seconds.nil?)
        setcode do
            uptime_seconds
        end
    end
end

 

Florin Dragos (Jira)

unread,
Aug 3, 2020, 10:00:03 AM8/3/20
to puppe...@googlegroups.com

Hey Atanas Stoyanov, can you please check the facter version? Puppet 6.14 comes by default with facter 3.

I've tried on pure lxc and still cannot reproduce:

root@beardown-glamor:~# uptime
 13:52:25 up  1:33,  1 user,  load average: 0.00, 0.00, 0.00
root@beardown-glamor:~# lxc-attach -n u1 -- facter uptime
0:05 hours
root@beardown-glamor:~# lxc-attach -n u1 -- uptime
 13:52:35 up 5 min,  0 users,  load average: 0.00, 0.00, 0.00
root@beardown-glamor:~# lxc-attach -n u1 -- facter --version
4.0.32

As far as I can tell, this is an issue on docker, but seems to work fine on lxc.

Bogdan Irimie (Jira)

unread,
Aug 5, 2020, 9:10:04 AM8/5/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-29.07, ghost-5.08 , ready for triage 2

Atanas Stoyanov (Jira)

unread,
Aug 6, 2020, 5:57:03 AM8/6/20
to puppe...@googlegroups.com
Atanas Stoyanov commented on Bug FACT-2479
 
Re: Uptime facts on LXC get the uptime from the host OS and not the container.

Hi Florin, I spawned a new test LXC and the facter --version command returns:

3.14.9 (commit 9115836a933a9191729305201b32ed46713ecf1b)

I upgraded the facter with "/opt/puppetlabs/puppet/bin/gem install facter" to facter-4.0.33 and the issue seem to have disapeared for the commandline, however when checking the facts through foreman or via the puppet facts command the values are still wrong:

root@LXC # puppet facts |grep uptime
    "ia_uptime_seconds": "79",
    "system_uptime": {
      "uptime": "22 days"
    "uptime": "22 days",
    "uptime_days": 22,
    "uptime_hours": 549,
    "uptime_seconds": 1978892,
 
root@LXC # facter uptime
0:01 hours

I thought I may have another facter binary but didn't find such:

root@LXC # find / -name facter
/opt/puppetlabs/puppet/lib/ruby/gems/2.5.0/gems/facter-4.0.33/lib/facter
/opt/puppetlabs/puppet/lib/ruby/gems/2.5.0/gems/facter-4.0.33/bin/facter
/opt/puppetlabs/puppet/lib/ruby/gems/2.5.0/doc/facter-4.0.33/ri/lib/facter
/opt/puppetlabs/puppet/cache/lib/facter
/opt/puppetlabs/puppet/bin/facter
/opt/puppetlabs/bin/facter
/opt/puppetlabs/facter
 
root@LXC # ll /opt/puppetlabs/puppet/bin/facter
-rwxr-xr-x 1 root root 613 Aug  6 11:09 /opt/puppetlabs/puppet/bin/facter*
 
root@LXC # ll /opt/puppetlabs/bin/facter
lrwxrwxrwx 1 root root 24 Mar  7 20:27 /opt/puppetlabs/bin/facter -> ../puppet/bin/wrapper.sh*

Both binaries with --version return 4.0.33

I noticed that there is also a facter-ng installed and removed it to verify that it is not causing the issue but the issue remains after that as well:

root@LXC # /opt/puppetlabs/puppet/bin/gem list |grep facter
facter (4.0.33, 3.14.9)
facter-ng (4.0.9.pre)
 
root@LXC # /opt/puppetlabs/puppet/bin/gem uninstall facter-ng
Remove executables:
        facter-ng
 
in addition to the gem? [Yn]  Y
Removing facter-ng
Successfully uninstalled facter-ng-4.0.9.pre

After each change I was doing a reboot of the container and a puppet run to verify that the facts are updated.

I assume that puppet doesn't pull the facts with facter uptime, can you share how is it retrieving them?

Florin Dragos (Jira)

unread,
Aug 6, 2020, 8:16:04 AM8/6/20
to puppe...@googlegroups.com

Hey Atanas Stoyanov, Puppet 6.14 comes with 2 versions of facter: 3 and 4 (also knows as facter-ng, which is experimental).

Facter 3 is enabled by default. When you call the facter cli, you will get facter 3. Also, when you try to get facts using puppet facts, it will use facter 3 by default (that's why you are getting different values).

You can change the behaviour of puppet facts by enabling the feature flag: puppet config set facterng true. With this flag set, puppet facts will use facter 4 (aka facter-ng) but the facter cli will still be facter 3 (unless you call the facter-ng cli).

Please note that the version of puppet you are using contains a pre-release version of facter 4 and there have been a lot of changes and fixes since then. 

You are free to try out our puppet-7 nightly builds, which drop facter 3 and uses the latest facter 4.

Florin Dragos (Jira)

unread,
Aug 6, 2020, 8:35:02 AM8/6/20
to puppe...@googlegroups.com

Also, facter 4 is our main priority right now. Since this bug is affecting only facter 3, we can't provide a timeline for when it will be fixed.

Bogdan Irimie (Jira)

unread,
Aug 12, 2020, 4:44:03 AM8/12/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-29.07, ghost-5.08, ghost-12.08 , ready for triage 2

Bogdan Irimie (Jira)

unread,
Aug 19, 2020, 9:12:04 AM8/19/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-29.07, ghost-5.08, ghost-12.08, ghost-19 , ready for triage 2

Bogdan Irimie (Jira)

unread,
Aug 26, 2020, 9:04:05 AM8/26/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-29.07, ghost-5.08, ghost-12.08, ghost-19, ghost-26.08 , ready for triage 2

Bogdan Irimie (Jira)

unread,
Sep 1, 2020, 2:42:02 AM9/1/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Sep 1, 2020, 2:42:04 AM9/1/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Sep 2, 2020, 9:07:06 AM9/2/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-29.07, ghost-5.08, ghost-12.08, ghost-19, ghost-26.08, ghost-2.09 , ready for triage 2

Bogdan Irimie (Jira)

unread,
Sep 9, 2020, 9:08:04 AM9/9/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ghost-29.07, ghost-5.08, ghost-12.08, ghost-19, ghost-26.08, ghost-2.09, ghost-9.09 , ready for triage 2

Bogdan Irimie (Jira)

unread,
Sep 9, 2020, 10:03:03 AM9/9/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Sep 9, 2020, 10:03:04 AM9/9/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Sep 9, 2020, 10:03:04 AM9/9/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: PR - Triage, ghost-29.07, ghost-5.08, ghost-12.08, ghost-19, ghost-26.08, ghost-2.09, ghost-9.09 , ghost-16.09

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:30:02 AM11/5/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:30:03 AM11/5/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:31:03 AM11/5/20
to puppe...@googlegroups.com

Bogdan Irimie (Jira)

unread,
Nov 5, 2020, 3:51:06 AM11/5/20
to puppe...@googlegroups.com
Bogdan Irimie updated an issue
Change By: Bogdan Irimie
Sprint: ready for triage, ghost-29.07, ghost-5.08, ghost-12.08, ghost-19, ghost-26.08, ghost-2.09, ghost-9.09

Ciprian Badescu (Jira)

unread,
Jun 7, 2021, 5:02:02 AM6/7/21
to puppe...@googlegroups.com
Ciprian Badescu commented on Bug FACT-2479
 
Re: Uptime facts on LXC get the uptime from the host OS and not the container.

Atanas Stoyanov,
Are you still having this issue?
Puppet 7 is using Facter 4 and this issue should be solved when using it.

This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

Ciprian Badescu (Jira)

unread,
Sep 23, 2021, 4:58:01 AM9/23/21
to puppe...@googlegroups.com

Hi Atanas Stoyanov, puppet has moved on considerably from the time this issue was raised and we feel it may no longer be a valid issue. If you feel otherwise please do not hesitate to re-open this ticket and provide more information as to why this may still be a valid issue.

Reply all
Reply to author
Forward
0 new messages