Closed skrzepto closed 3 years ago
Could you try with the changes from #193 ?
@pypingou still crashes for me same way. Does it work for you, it could be my local setup?
It works for me but I'm using a dump of FAS2's db upgraded, so not a FAS3 db generated by FAS3 :)
Thanks, updated my issue with that specific info. I am using the FAS3 db generated by FAS3.
okay figured it out, at least on my machine why its failing
the recent change
from
- person.login_timestamp = datetime.datetime.utcnow()
To
+ person.login_timestamp = datetime.datetime.now(pytz.timezone('UTC'))
@pypingou
from the commits message you mentioned you wanted the timezone to be set on the login_timestamp. does utcnow() not do that?
edit
I think we can update the model for the login to be timezone aware so this change can be compatible
No luck changing the people model and account activity model :/
does utcnow() not do that?
Unfortunately not :(
@pypingou how important is adding the tzinfo? https://github.com/fedora-infra/fas/blob/FAS_3.0/fas/subscribers/login.py#L102
Since all our dates are utcnow.
edit
good blog post on the topic
how important is adding the tzinfo?
Well, the issue is when you work on a FAS2 db converted to FAS3, for some reasons the date/times in there are stored with timezone info, this means we need to work with timezone everywhere as otherwise python complains (rightfully) that it cannot work with a date that is tz aware and a date that isn't at the same time.
So, for a FAS2 db upgraded, it is most important to be TZ aware.
@pypingou When you tested the login, were you using postgres db or sqlite?
Hey, so this is the data models which are not tz aware which lead you to this issue when generating the db from scratch. @pypingou Can I push a fix to your branch avoiding me to cherry-pick a commit and by the same time review your PR?
@laxathom could you check out my pr for the login fix, if its good pypingou could rebase his branch
@pypingou Can I push a fix to your branch avoiding me to cherry-pick a commit and by the same time review your PR?
Sure thing, feel free to ping me if you want another set of eyes on this commit
Done.
@laxathom I'm assuming you pushed changes to the Misc Fixes and the first time logging into fasadmin works. Then when I log out and log back in, the error persists.
Issue is still present in most recent version of fas3. DB: postgres local
Seems if you comment out https://github.com/fedora-infra/fas/blob/FAS_3.0/fas/security.py#L295 login works fine
@pypingou @laxathom
I mentioned this above but could someone explain why timezone info was important in
fas/subscribers/login.py
103: person.login_timestamp = datetime.datetime.now(pytz.utc)
it seems in table people column login_timestamp
doesn't have tz aware attribute which is why it throws the error.
Could we change it back to
- person.login_timestamp = datetime.datetime.utcnow()
This fixes the login time stamp issue but keeps it in utc date format without timezone awareness.
Thoughts?
The issue is that FAS2 has timezone aware date/times, so that's why we need to have them also in FAS3, otherwise migrating from one to the other is somewhere between most-painful to really-don't-want-to-try :)
@pypingou can you check out my PR #222 I believe it satisfies your request for keeping timezone aware
Closing this issue as the FAS project is now archived, not actively developed, and unmaintained.
FAS was replaced in March 2021 by Fedora Accounts (https://accounts.fedoraproject.org).
If this issue is a Feature Request that you forsee might be beneficial to Fedora Accounts, please refile it against Noggin
Summary
When logging into
fasadmin
or any other account you create it errors sayingSteps to reproduce
Expected results
Misc. Notes
I came across this when trying to run my unit tests but they were all failing. One thing I noticed is that if you comment out line 295 in fas/security https://github.com/skrzepto/fas/blob/115507f3748a70313d4c7dbac48f8ae0f1930268/fas/security.py#L295
it works as expected. I went through the recent git logs and I can't seem to pinpoint what change caused this.
Error Log