-
Notifications
You must be signed in to change notification settings - Fork 293
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
Enhance reliability of feature synchronization #7531
Comments
Hey @jimmymadon, I think it would be worth revising and fleshing out the AC here a bit.
|
@techanvil All good points. I think the period would have to be amendable per task? This might complicate the issue slightly since some of the potential IBs for the Remote Features sync could simply rely on certain actions/events in the plugin rather than a specific heartbeat period. I feel we will essentially be creating a dismissed-notification style system that relies on running certain tasks if a certain time has already passed. I'm not against this and this would be quite helpful as it will be generic. UPDATE: Would we need some UI elements to allow the user to disable the running of these tasks? If yes, then we'd need UX's input and this feature would now be something that the user will have to be made aware of which is not ideal for 'background running tasks'. c.c. @aaemnnosttv |
Thanks @jimmymadon.
I think the most straightforward approach to take would be to provide our own API modelled on the WP We may want to start off with Incidentally I noticed another place we're scheduling an event, refreshing the user's profile data in
When I mean it should be disabled by the user, I meant via a WP filter rather than any UI-side control, I don't think that would be necessary. |
@techanvil Your modelled solution seems like a good idea. I think the ACs as they are cover the "what" quite well and I'm a tad bit skeptical of adding the contents of your comment to the AC as it goes too much into the "how". So I've added a comment for an IB author to look at your comment as one good solution to model the IB on. I have updated the AC to accommodate for a new WP filter which would disable our version of the scheduler. c.c. @aaemnnosttv |
Thanks @jimmymadon, that SGTM. AC ✅ |
Hi @zutigrm, thanks for drafting this IB. First off, I would say I think it's a pretty ingenious idea, and I think could be a fitting solution in a different situation. That said, I don't think it's such a good fit for the plugin for the following reasons.
You make a good point about potentially needing to duplicate Of course, we could always consider dialling the requirements back to only cover syncing the enabled features, as per the Feature Description. Seeing as you've raised the point about the extent of the infrastructure work that would be required, let's check in with @aaemnnosttv to see what he thinks before carrying on with this one as currently specced. |
Thanks @aaemnnosttv
Since option is updated only if sync is successful, and will not be invoked if options don't update, I proposed alternative approach of running the checks and making non blocking request to invoke cron action.
I will take a look at it once it lands in IB. Thanks |
Thanks, @zutigrm. IB ✔️ |
Parked until dependency #8341 is merged cc: @binnieshah |
QA Update ✅
Verified that the fallback ensures features are synchronized if the last sync occurred more than 24 hours ago. Recording.1322.mp4Verified that the fallback ensures features are not synchronized if the last sync occurred less than 24 hours ago. Recording.1323.mp4 |
Feature Description
Features that are controlled by remote activation are currently only refreshed via a WP cron job twice daily after being received as part of the initial setup.
For most sites this works well, although some sites may have WP cron disabled without properly configuring WP cron to run by an alternative method which can leave a site without important features until the flag is removed entirely, which can be an unknown length of time after the feature is made generally available.
Site Kit should have an alternative method to synchronize its enabled features that does not rely on WP cron.
This issue is related to #6015 but independent from a requirements perspective.
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
Implementation Brief
Some context: Since remote features are updated only after cron sync happens, we can't listen to the
on_change
to check if update happend or not. So this approach handles the timestamp check onadmin_init
and fires a non-blocking request that in turn invokes the CRON callback action.includes/Core/Remote_Features/REST_Remote_Features_Controller.php
POST:sync-remote-features
and as a callback invoke cron actiondo_action( Remote_Features_Sync::CRON_ACTION )
Google\Site_Kit\Core\Remote_Features\Remote_Features
get_default
methodfeatures
- holds an empty array, andfeaturesLastSyncedAt
-0
by defaultget_sanitize_callback
method, to take new keys into the account, and add check forfeaturesLastSyncedAt
if it is not integer, set value back to0
Google\Site_Kit\Core\Remote_Features\Remote_Features_Activation
get_features
, andfilter_features
to expect features array in$features['features']
instead of$features
Google\Site_Kit\Core\Remote_Features\Remote_Features_Provider
register
methodREST_Remote_Features_Controller
class and invoke it'sregister
methodon_admin_init
methodfeaturesLastSyncedAt
timestamp is older than 24h to invokewp_remote_post
for a new REST route and passblocking => false
as an argument, so it is a non-blocking request.Google\Site_Kit\Core\Remote_Features\Remote_Features_Sync
pull_remote_features
method, to set thefeatures
option correctly to thefeatures
key instead of the main option as now. And updatefeaturesLastSyncedAt
option with the current timestampTest Coverage
Remote_Features_Provider
to include new additions around option structureQA Brief
QA:Eng
googlesitekitpersistent_remote_features
DB column fromwp_options
tableheartbeat
AJAX request is sent), verify thatgooglesitekitpersistent_remote_features
is populated again.last_synced_at
timestamp is less than 24h ago. This is example of how data would look like:At the last item you will notice this value
"last_updated_at";i:1723720515;
. You can modify timestamp (1723720515
in this case) manually to verify that fallback is called and timestamp updated when value is over 24h, using https://timestampgenerator.com/ or similar websites. Makes sure that only number value is replaced, without space at the end as it will make value invalid. To verify that callback was not invoked, you will see that your updated timestamp value is still present after re-visiting dashboard and waiting for nextheartbeat
sync (approximately 1-2min wait on the Site Kit dashboard)Changelog entry
The text was updated successfully, but these errors were encountered: