Re: Container Uptime Discussion

Jim Warner <[email protected]> Fri, 9 Feb 2024 12:36:42 -0600
Newsgroups gmane.linux.procps.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.
--------------Cva4Y65PDYRHcIMQMCpKcAGN
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

On 2/9/24 4:51 AM, Craig Small (csmall) wrote:
> . . . 
> So, do I do any fancy stuff or just make the container uptime is PID1 
> start - clock_gettime?

Hi Craig,

Don't do anything fancy because what you've got now works just fine 
under both docker and lxc (besides, the above is backwards).  Using the 
C standard clock_gettime equalized things and was the perfect solution.

Here's a summary of what I found with uptime outputs:

                   docker     lxc *      lxc *
based             ubuntu     ubuntu     opensuse
                   ---------  ---------  ---------
your uptime       host       container  container
your uptime -c    container  container  container
provided uptime   host       container  host
provided version  3.3.17     4.0.4      coreutils 9.4

  * a reminder that lxc alters /proc/uptime but
    coreutils uptime doesn't exploit

> Perhaps boot_time in the library should use clock_gettime()?

The attached patch does just that.  Thanks for paving the way.

> If you could run the test program attached, or something like it I'd be 
> keen to see if it provides the system uptime.
> I'll make the changes to use the clock.

I ran it under the three above containers.  It always shows the host 
"uptime".  Do you plan to abandon all use of /proc/uptime?

Anyway, thanks in advance for the push.

Regards,

Jim

p.s. over the weekend I'll decide whether or not to make top's 'l' 
toggle a three-way switch to also show container uptime.
--------------Cva4Y65PDYRHcIMQMCpKcAGN
Content-Type: application/gzip;
 name="0001-library-procps_uptime-clock_gettime-in-pids-api.patch.gz"
Content-Disposition: attachment;
 filename*0="0001-library-procps_uptime-clock_gettime-in-pids-api.patch.g";
 filename*1="z"
Content-Transfer-Encoding: base64

H4sICCBoxmUAAzAwMDEtbGlicmFyeS1wcm9jcHNfdXB0aW1lLWNsb2NrX2dldHRpbWUtaW4t
cGlkcy1hcGkucGF0Y2gA7Vf/bts2EP5fT3HogNa/ZEu2LMf5taRu3GZza6NxtwJFIUgUZbOV
RIGk6rrrC+019mQ7Skpsp3UbdBi6AR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