-
Notifications
You must be signed in to change notification settings - Fork 17
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
Bug 1358123: Add handler for FxA deleted queue #35
Conversation
@rfk This expects the message from the queue to be simply {
"event": "delete",
"uid": "<the fxa id>"
} But from the look of the code you pasted in the bug that structure might be embedded deeper under a |
c106f13
to
87c9bb9
Compare
Yeah, unfortunately due to the way that SQS works, I think you'll get a top-level "Message" key with the actual JSON payload in it as a string. |
Interesting. I don't get that from other SQS queues. Perhaps it's a consequence of the libraries we're using to access SQS? Not a big deal either way, just want to get it right :) Thanks! |
87c9bb9
to
70d29e4
Compare
56bf5d6
to
358a0b5
Compare
basket/news/tasks.py
Outdated
'email': email, | ||
'lang': lang, | ||
'newsletters': settings.FXA_REGISTER_NEWSLETTER, | ||
'source_url': settings.FXA_REGISTER_SOURCE_URL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rfk I think this should work well. Do you know if you're currently sending the source_url
based on the actual FxA domain that sent the event? I'm not sure it matters much for us, but I could do something fancy with this based on whether we're consuming the dev, stage, or prod queue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a config value that we could change for each environment, but I think right now it just defaults to "accounts.firefox.com" even in dev. Let me know if you have a use for us changing it and I'll file a bug about updating the config.
}) | ||
|
||
|
||
@et_task | ||
def add_fxa_activity(data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rfk after the other things, I believe the only other HTTP requests you send us are for this function which records account activity and includes the FxA ID, the user_agent
, and a first_device
boolean. Is this another event that will be on the queue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there will be a "login" event in the queue which we currently handle here:
https://github.com/mozilla/fxa-basket-proxy/blob/master/lib/events/index.js#L86
Our handling of this event does two things. It registers the activity by posting to /fxa-activity/
:
https://github.com/mozilla/fxa-basket-proxy/blob/master/lib/events/index.js#L114
And it also does a bit of magic where, if the user logged in with certain special values of the "utm_campaign" query parameter, it adds them to special subscriptions in basket:
https://github.com/mozilla/fxa-basket-proxy/blob/master/lib/events/index.js#L94
It's a lightly hacky way for us to tunnel metrics info through FxA for various first-run-page experiments.
If you're happy to take over handling of those events as well, that'll be great! We'll have to be careful though because IIUC the /fxa-activity/
part is not idempotent.
after the other things, I believe the only other HTTP requests you send us
are for this function which records account activity
FWIW we also provide a "communication preferences" screen in FxA settings, where the user can change their choice of the marketing opt-in checkbox that they made during signup. We currently action this by making calls to the existing basket web API, but we could consider whether there's a better way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW we also provide a "communication preferences" screen in FxA settings, where the user can change their choice of the marketing opt-in checkbox that they made during signup. We currently action this by making calls to the existing basket web API, but we could consider whether there's a better way.
That user interaction seems like a fine place for using the basket api, and if you're happy to keep doing it that's fine with me. I think we can move the activity handling to the queue, but that's a good point about it being different and not idempotent... Perhaps we should hold of on that bit and do it in a separate bug and sometime later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Filed #37 to cover this BTW.
358a0b5
to
4b56d7c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question about msg.delete()
. Looks good!
continue | ||
|
||
statsd.incr('fxa.events.message.success') | ||
msg.delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be useful to delete the msg just before et_task
completes to ensure that we don't miss any msgs in case salesforge is down for example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking we could rely on celery retries for those cases, but it is possible to lose some if it's down for a long time. I'm not currently passing the message object to the task (not sure how well it'd go on the celery queue), but I could probably figure out how to delete the message from the task instead of the consumer; I'm just not sure it's worth going to that trouble. What do you think?
The other option is to just not use celery tasks for this and to just record the messages as they come in from the queue consumer process. I didn't do that because celery gives us retries and much more scalability, but it could work better in the case of message deletion timing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hear you, I don't know if that's worth the trouble either.
Actually re-reading this made me think: Do you plan to run this command periodically? If yes how will it get triggered?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it just runs indefinitely via that infinite loop. Same as the process_donations_quqeue
command.
|
||
_update_fxa_info(email, lang, fxa_id) | ||
|
||
if subscribe: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rfk I guess we'll need to implement this bit as well, and add those new campaigns from the bug?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually nevermind. Won't need to do that until we takeover the "login" events in #37. I'll add a note there to be sure to do this bit.
@pmac do we need to do these all around the same period of time, or can I get the messages flowing to stage & prod queues before the basket & fxa deploys? |
It'd be nice if it were "around" the same time just to reduce the number of duplicate queue messages and POSTs coming from FxA, and to minimize the queue size at basket deploy. Is there something in FxA to deploy? The stopping of POSTing to basket for these things I guess? But to be clear they don't have to be at exactly the same time, but the closer the better. |
It looks like there's a "Purge Queue" action I can do, so I can deploy the queues to stage & prod now and purge before we deploy the FxA changes. |
Works for me. Thanks! 👍 |
Just to be clear, this code will go to dev and stage when I merge to master. I'll tag and push to the |
Also subscribe users that opt-in to newsletters
4b56d7c
to
bb93707
Compare
This should be pretty trivial, we can include this change in FxA train-96, going to stage this week and deploying next week. |
So we could aim to give live week of 25th September on both sides? |
Sounds good to me. Thanks! |
FYI this is in stage right now on our side |
Great. Deploying to stage here as well then. |
These changes have been deployed to basket dev and stage and the queue processor containers have been started. Let's get some more test data flowing :) |
I just signed up as "ryan-loves-newsletters@rfk.id.au" and checked the opt-in box, do you see any events from me? |
Actually I'm having trouble with the stage queue :( botocore.exceptions.ClientError: An error occurred (AWS.SimpleQueueService.NonExistentQueue) when calling the ReceiveMessage operation: The specified queue does not exist or you do not have access to it. I get that with the prod and stage settings. The dev queue works. Not sure why yet. |
/cc @jbuck ^ |
I've had a look around the IAM roles for access to these queues and it looks right to me. Perhaps @jbuck and I can troubleshoot tomorrow. |
I've fixed this in stage - it'll be going out with prod later today |
Confirmed the stage queue is now working! Or at least it's allowing me to connect (haven't verified any actual messages yet). Prod queue is still broken but it sounds like you're on it. Thanks @jbuck ! 🥇 |
No description provided.