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

Activity Stream times are not adjusted for GMT #147

Closed
Mbrownshoes opened this issue Aug 16, 2016 · 29 comments
Closed

Activity Stream times are not adjusted for GMT #147

Mbrownshoes opened this issue Aug 16, 2016 · 29 comments
Assignees
Labels
Milestone

Comments

@Mbrownshoes
Copy link
Contributor

Mbrownshoes commented Aug 16, 2016

In the activity streams edits that have just been made are showing they were edited '7 hours ago'. I believe was due to the time being set to GMT, and Leo had fixed this with a patch in Cad -- but it looks like his changes have been overwritten by the most recent deploy.

Modify a record and view https://catalogue.data.gov.bc.ca/dataset/activity/[datasetname] to see an example.

@gjlawran gjlawran added this to the 1.5.0 milestone Aug 16, 2016
@gjlawran gjlawran added the bug label Aug 17, 2016
@gjlawran gjlawran changed the title Timestamps showing '7 hours ago' in Prod, Cat and Delivery Activity Stream times are not adjusted for GMT Aug 17, 2016
@gjlawran gjlawran assigned kfishwick and unassigned gjlawran Aug 17, 2016
@gjlawran
Copy link
Member

Not fixed by Leo - wasn't fixed and reverted.

@kfishwick
Copy link
Contributor

Please do some analysis, the calls should all be in UTC, we need more information on time correction for local or profile based time zone that occurs in the templates.

@kfishwick kfishwick assigned jrods and unassigned kfishwick Aug 23, 2016
@jrods
Copy link
Contributor

jrods commented Aug 24, 2016

I was able to reproduce this in my local env. The problem stems from changing the /etc/sysconfig/clock to ZONE="America/Vancouver". In my env, it was set to ZONE="UTC"

@kfishwick
Copy link
Contributor

@ll911 any chance we can change that parameter in cad? It seems like it might be actually a better setting anyways.

@ll911
Copy link
Contributor

ll911 commented Aug 24, 2016

@kfishwick Which parm?

@kfishwick
Copy link
Contributor

Change the /etc/sysconfig/clock to ZONE="UTC"

@ll911
Copy link
Contributor

ll911 commented Aug 24, 2016

@kfishwick No, this is root manage system value, should not be changed and should match our current timezone /etc/sysconfig/clock
however, I found another parm in ckan
ckan.display_timezone default is UTC but it can be changed, after changed to America/Vancouver, it doubled the differences from 7hrs to 14hrs
http://docs.ckan.org/en/ckan-2.5.2/maintaining/configuration.html
https://cad.data.gov.bc.ca/dataset/activity/creating-geographic-dataset

@ll911
Copy link
Contributor

ll911 commented Aug 24, 2016

@kfishwick @jrods does this have correct time shift
https://github.com/bcgov/ckanext-bcgov/blob/master/ckanext/bcgov/controllers/package.py
convert timezone with pytz

python

from pytz import timezone
fmt = "%Y-%m-%d %H:%M:%S %Z%z"
now_utc = datetime.now(timezone('UTC'))
print now_utc.strftime(fmt)
2016-08-24 23:20:48 UTC+0000
now_pacific = now_utc.astimezone(timezone('US/Pacific'))
print now_pacific.strftime(fmt)
2016-08-24 16:20:48 PDT-0700

@kfishwick
Copy link
Contributor

Is this related to ckan/ckan#2882

@ll911
Copy link
Contributor

ll911 commented Aug 25, 2016

@kfishwick looks like a problem for a while

@jrods
Copy link
Contributor

jrods commented Aug 25, 2016

@ll911 are you also doing something like this on the server?

$ sudo mv /etc/localtime /etc/localtime.bak
$ sudo ln -s /usr/share/zoneinfo/Canada/Pacific /etc/localtime

@ll911
Copy link
Contributor

ll911 commented Aug 25, 2016 via email

@jrods
Copy link
Contributor

jrods commented Aug 25, 2016

@ll911 ok, so just an overview so i can match my env, on the server, /etc/localtime is UTC, and /etc/sysconfig/clock is ZONE="America/Vancouver", correct?

Are those the only settings I need for time on the server? Is there any other changes I need to make for my env to match the server?

@ll911
Copy link
Contributor

ll911 commented Aug 25, 2016

@jrods you need to set both system clock and localtime with PST

zdump /etc/localtime
/etc/localtime  Thu Aug 25 13:31:40 2016 PDT

@jrods
Copy link
Contributor

jrods commented Aug 25, 2016

@ll911 ok, but how did you specifically changed /etc/localtime?

@ll911
Copy link
Contributor

ll911 commented Aug 25, 2016

@jrods link to

/usr/share/zoneinfo/Canada/Pacific

@jrods
Copy link
Contributor

jrods commented Aug 26, 2016

@ll911 what is the db's set timezone?

@ll911
Copy link
Contributor

ll911 commented Aug 26, 2016

Postgresql calls system time, which should be PST, but it can all set by application during the RUNTIME

https://www.postgresql.org/docs/9.1/static/sql-set.html

@jrods
Copy link
Contributor

jrods commented Aug 26, 2016

From my analysis, this looks to be a ckan core issue with many datetime.datetime.now() calls being use, since the server isn't using UTC, this causes the time difference.

ckan/ckan#2970 is pretty much the exact same problem.

I'll ask around to see if anybody is working on it for core.

@kfishwick
Copy link
Contributor

Recommend deferring to the next release, this could be 2-3 days of work (if it affects more than just activity stream, and to coordinate the strategy for fixing it) and should be integrated into ckan core (and can likely be backported to 1.5 since it is a bug).

jrods added a commit to HighwayThree/ckan that referenced this issue Sep 8, 2016
bcgov/ckanext-bcgov#147 ckan#2882 ckan#2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified
@jrods
Copy link
Contributor

jrods commented Sep 9, 2016

I've made PR for activity times above. Note that this does not fix activity times that already have a stored timestamp. I'm not sure on the approach to fixing that. I'm inclined to just leave old timestamps, as they don't seem like they're very crucial (but this isn't my call)

@Mbrownshoes
Copy link
Contributor Author

Getting a server error on delivery when trying to access activity stream.
logs show this related to the time.
Error - <type 'exceptions.NameError'>: global name 'datatime_' is not defined
[pid: 55356|app: 0|req: 288/288] 142.34.140.32 () {48 vars in 2481 bytes} [Fri Sep 9 11:41:11 2016] GET /dataset/activity/bc-wildfire-active-weather-stations => generated 30065 bytes in 497 msecs (HTTP/1.1 500) 3 headers in 125 bytes (1 switches on core 0)
Fri Sep 9 11:41:11 2016 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 419] during GET /fanstatic/vendor/:version:2016-09-09T09:47:02.16/select2/select2.css (142.34.140.32)
IOError: write error

@Mbrownshoes
Copy link
Contributor Author

Maybe we should push this back to 1.6 since so far it looks like this is the only hold up. Though it's already been merged (after we deployed to cat). Can we roll this change, which isn't working, back?
bcgov/ckan#5

@jrods
Copy link
Contributor

jrods commented Sep 9, 2016

whoops, typo, fixed here: bcgov/ckan#7

@Mbrownshoes
Copy link
Contributor Author

Don't think this deployed to cad, I think only merges to ckanext-bcgov auto deploy.

jrods added a commit to HighwayThree/ckan that referenced this issue Sep 12, 2016
bcgov/ckanext-bcgov#147 ckan#2882 ckan#2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified

fixing typo
@kfishwick kfishwick reopened this Sep 13, 2016
@kfishwick
Copy link
Contributor

Getting internal server error when viewing Activity Stream in cad.

@jrods
Copy link
Contributor

jrods commented Sep 13, 2016

@ll911 will you please merge in the above PR and deploy ckan with those changes to delivery?

@ll911
Copy link
Contributor

ll911 commented Sep 13, 2016 via email

@kfishwick kfishwick assigned kfishwick and Mbrownshoes and unassigned jrods, ll911 and kfishwick Sep 13, 2016
@kfishwick
Copy link
Contributor

Seems to work in CAD, assigning over to Matt for verification.

@ll911 ll911 closed this as completed Sep 21, 2016
amercader pushed a commit to ckan/ckan that referenced this issue Feb 28, 2018
bcgov/ckanext-bcgov#147 #2882 #2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified

fixing typo
amercader pushed a commit to ckan/ckan that referenced this issue Feb 28, 2018
bcgov/ckanext-bcgov#147 #2882 #2970

The Activity model now stores its timestamp in utc

In Formatters, localized_nice_date, removed the datetime replace method
calls with actually ensuring the comparing timestamps have a timezone
specified

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

No branches or pull requests

5 participants