Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1232251

Summary: Created time is not same with CLI on deployment page
Product: OpenShift Container Platform Reporter: Wei Sun <wsun>
Component: ocAssignee: Maciej Szulik <maszulik>
Status: CLOSED CURRENTRELEASE QA Contact: Xingxing Xia <xxia>
Severity: low Docs Contact:
Priority: medium    
Version: unspecifiedCC: aos-bugs, jforrest, jokerman, libra-bugs, mmccomas, wsun
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-08-21 10:10:02 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
deploymentpage none

Description Wei Sun 2015-06-16 11:19:43 UTC
Description of problem:
Check deploymentconfig using oc ,and also check deployment page on web console,but the created time is not same.

Please refer to the attachment

Version-Release number of selected component (if applicable):
devenv-fedora_1811

How reproducible:
Always

Steps to Reproduce:
1.Create an application
2.Build and deploy the app
3.Wait for > 1 hour
4.Check deploymentconfig using oc
5.Check deployment page on web console

Actual results:
4.On CLI,I got the time:
[wsun@dhcp-8-229 v3test]$ oc describe dc nodejs-ex
Name:		nodejs-ex
Created:	2 hours ago
Labels:		app=nodejs,deploymentconfig=nodejs-ex,generatedby=OpenShiftWebConsole,name=nodejs-ex
Latest Version:	2
Triggers:	Image(nodejs-ex@latest, auto=true), Config
Strategy:	Recreate
Template:
	Selector:	deploymentconfig=nodejs-ex
	Replicas:	1
	Containers:
		NAME		IMAGE														ENV
		nodejs-ex	172.30.91.161:5000/wsuntest/nodejs-ex@sha256:ad00522251363bcf7cb95e8c7754abb55c8a6047102ac55b56fb1c8603a24afe	
Deployment #2 (latest):
	Name:		nodejs-ex-2
	Created:	4 minutes ago
	Status:		Complete
	Replicas:	1 current / 1 desired
	Selector:	deployment=nodejs-ex-2,deploymentconfig=nodejs-ex
	Labels:		app=nodejs,deploymentconfig=nodejs-ex,generatedby=OpenShiftWebConsole,name=nodejs-ex,openshift.io/deployment-config.name=nodejs-ex
	Pods Status:	1 Running / 0 Waiting / 0 Succeeded / 0 Failed
Deployment #1:
	Created:	2 hours ago
	Status:		Complete
	Replicas:	0 current / 0 desired
No events.

5.On deployment page:
nodejs-ex
Created:3 hours ago



Expected results:
The created time should be same 

Additional info:

Comment 1 Wei Sun 2015-06-16 11:20:06 UTC
Created attachment 1039392 [details]
deploymentpage

Comment 2 Samuel Padgett 2015-06-16 12:56:07 UTC
If it's +/- one hour, I suspect we're using a different rounding strategy in the CLI vs the Web Console.

Comment 3 Samuel Padgett 2015-06-16 12:59:34 UTC
Here is what we use in the web console:

http://momentjs.com/docs/#/displaying/fromnow/

If it's 1 hr 30 minutes, we round up to 2 hrs. I'm not sure what the CLI does, but perhaps it never rounds up.

Comment 4 weiwei jiang 2015-06-17 02:39:49 UTC
(In reply to Samuel Padgett from comment #3)
> Here is what we use in the web console:
> 
> http://momentjs.com/docs/#/displaying/fromnow/
> 
> If it's 1 hr 30 minutes, we round up to 2 hrs. I'm not sure what the CLI
> does, but perhaps it never rounds up.

The client relativetime algorithm is:

1. the formatRelativeTime function definition.
 https://github.com/openshift/origin/blob/27d63965c30af462e005056af7cfb1e34572b987/pkg/cmd/cli/describe/helpers.go#L113

2. the HumanDuration function definition.
 https://github.com/docker/docker/blob/master/pkg/units/duration.go#L10

And as the code show here, it switch the type to an integer, so will miss some data.
http://play.golang.org/p/WGVrd9ofqf

Comment 5 Samuel Padgett 2015-11-11 16:15:01 UTC
Jessica, should we close? It's working as intended despite the discrepancy.

Comment 6 Jessica Forrester 2015-11-23 18:37:57 UTC
Discussed among the team and we generally agree the truncation approach the CLI is using is wrong when compared to a rounding approach.

There was additional discussion that we may want to increase the levels of precision and show hours + mins instead of just hours which would require changes across both CLI and console.  We may want to open that as a separate issue to discuss.

Comment 7 Juan Vallejo 2016-11-29 14:40:51 UTC
Related upstream (Docker) PR: https://github.com/docker/go-units/pull/22

Comment 8 Fabiano Franz 2017-01-14 17:46:41 UTC
Fixed in https://github.com/openshift/origin/pull/12158

Comment 9 Xingxing Xia 2017-01-16 09:49:35 UTC
Checked in oc/openshift v1.5.0-alpha.1+b53352c-251. Found some problems. Below are test steps and results.
First, create various resources when time is:
$ date
Mon Jan 16 16:00:00 CST 2017

$ oc new-app -f https://raw.githubusercontent.com/openshift/origin/master/examples/sample-app/application-template-stibuild.json

Then set local time with various time differences from resource creation time, and
check resource age (or synonym display words STARTED/Created) via `oc get all` and via local browser respectively

1. Make local time minus creation time = 1h and 10min
$ sudo date -s "2017-01-16 17:10"
2. Check resource age via `oc get all` and via local browser respectively
CLI and browser can both show age: 1h. This is acceptable.

3. Make local time minus creation time = 1h and 40min
$ sudo date -s "2017-01-16 17:40"
4. Repeat above check 2
CLI and browser can show consistent age.
But for build/IS, they show 2h, for other resources pod/rc/svc, they show 1h. This is not acceptable.

5. Make local time minus creation time = 40min
$ sudo date -s "2017-01-16 16:40"
6. Repeat above check 2
CLI: all resources build/IS/pod/rc/svc age is shown 40 mins (ago)
Browser: all resources build/IS/pod/rc/svc age is shown an hour (ago). Inconsistency between CLI and browser may be acceptable, but not perfect.

7. Make local time minus creation time = 1day and 20h
$ sudo date -s "2017-01-18 12:10"
8. Repeat above check 2
CLI: build/IS age is shown 44 hours ago, pod/rc/svc age is shown 1d. This is not acceptable.
Browser: all resources build/IS/pod/rc/svc age is shown 2 days (ago). Inconsistency between CLI and browser is not fixed yet and not acceptable

9. Make local time minus creation time = negative 3h
$ sudo date -s "2017-01-16 13:40"
10. Repeat above check 2
CLI: build/IS age is shown "Less than a second ago". Other resources pod/rc/svc age is shown <invalid>. The latter is known NOTA bug: 1299328. But the former is inconsistent with the latter.
Browser: All resources build/IS/pod/rc/svc age is shown "in 3 hours". Inconsistency between CLI and browser is not acceptable

Comment 10 Xingxing Xia 2017-01-16 10:36:29 UTC
Forgot to notice comment 0 checks creation time in 'oc describe'. Now also checked it by `for i in build is dc rc svc pod; do echo "${i}:"; oc describe $i | grep '^Created'; done` for each time difference in comment 9:
For comment 9 step 1 (1h10min), the 'for' execution shows:
build:
Created:	About an hour ago
is:
Created:		About an hour ago
Created:		About an hour ago
dc:
Created:	About an hour ago
Created:	About an hour ago
rc:
svc:
pod:

For comment 9 step 3 (1h40min), it shows "2 hours ago" (for build/is/dc. Below ditto)
For comment 9 step 5 (40min), it shows "About an hour ago".
For comment 9 step 7 (1d20h), it shows "44 hours ago".
For comment 9 step 9 (-3h), it shows "Less than a second ago".
For difference < half an hour, e.g. 20min, it shows "20 minutes ago"

So in summary, the time shown in 'oc describe' looks good, though. Unfixed problems only exist in the comparison of `oc get ...` with browser in comment 9.
Thanks!

Comment 11 Maciej Szulik 2019-08-21 10:10:02 UTC
Should be fixed by now.