- πΊπΈUnited States tedbow Ithaca, NY, USA
I think the thought was that it might be core-mvp to at least research the alternatives.
But I am not sure that it needs to be. If we don't get the PHP-TUF support required for Cron updates in the contrib module we really won't have any real world testers of the curl use because this only happens during cron updates. In the UI we make sure have a new request for PostApplyEvent by making sure the batch step runs in a new requests.
So basically will we really be able to tell if the current method causes problems?
Also our current non-test uses of PostApplyEvent are
- UpdateDataSubscriber, which clears the update module data so the available updates page is correct
- StatusChecker which clears the status check results after an update
both of these will happen for sure through the UI because we don't rely on curl
StatusChecker is cleared because some of the messages might be related to the old core version. But if the user sees this on admin page and click through to the status report the status checkers would be rerun and recached
UpdateDataSubscriber would me the available updates might not be correct after cron update but that page lists the last time it was checked and has a link to refresh.
I think one problem we could have if PostApplyEvent does not run correctly is that stage would not be destroyed so if you went back to Core Update UI it would tell you that there is existing operation. You could cancel it but you won't know that stage has already been applied.
We have no mechanism for determining if a non-destroyed stage has already been applied and is therefore safe to destroy. One reason for that is because we did think it might be possible valid use case for stage to be applied more than once.
For instance Project Browser could conceivably keep a stage around after a apply so they could install a new module without copying the whole codebase over again. The would have their own version of LockFileValidator and maybe decorate our version of LockFileValidator and return early if the stage was an instance of their installer stage.
- Issue was unassigned.
- π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
I found #8 very hard to parse β it's kind of meandering in thoughts across 8 paragraphs, not presenting a clear answer to the question articulated in #7?
- cURL may not always be available--especially on low end hosting or tightly secured self-hosted environments.
I think that this is the only
core-mvp
aspect: currently this module usescurl_init()
etc but does not requireext-curl
in itscomposer.json
, and core doesn't yet either (although core requires plenty of other PHP extensions).#3291147: Successfully applying an update puts the remainder of the request into an unreliable state β introduced the reliance on
curl_*()
functions and hence dependency onext-curl
. Devil's advocate: why isfile_get_contents()
/steam_get_contents()
inadequate? π€ - πΊπΈUnited States tedbow Ithaca, NY, USA
I updated #10 to be clearer(hopefully π€·)
- πΊπΈUnited States tedbow Ithaca, NY, USA
re #8 I created π Document when PostApplyEvent should be used instead of hook_update_n() or post update RTBC
I think if we document that
PostApplyEvent
should be used for non-critical clean-up then the current issue becomes a little less important because in the worst case where a cron update is applied butPostApplyEvent
does not get dispatched it will not be too bad - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
#11: thanks, much appreciated! Much clearer indeed.
First use of
PostApplyEvent
: clearing status check results after an updateWhat if the results are not just stored like they currently are:
$this->keyValueExpirable->setWithExpire( 'status_check_last_run', $results, $this->resultsTimeToLive * 60 * 60 );
β¦ but also keyed by the
composer.lock
'scontent-hash
? That way, we'd prevent ever showing wrong information, and we should not even need to clear the stored status check results?Second use of
PostApplyEvent
: refreshingupdate.module
dataCan't we apply the same principle here? Decorate the
update.manager
service, where we'd override the constructor to:- retrieve the actual
composer.lock
'scontent-hash
- compare this to the stored hash, and if it does not match, delete all cached data (I think by calling
refreshUpdateData()
?)
β¦ everything else should be able to stay the same β it just means that we're adding an extra invalidation mechanism: the default mechanism only does time-based invalidation, we're just adding instantaneous invalidation when we know for a fact it should be updated. (Much like cache tags vs cache max-age!)
- retrieve the actual
- Status changed to Postponed
almost 2 years ago 2:45pm 15 February 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
@tedbow and @tim.plunkett discussed the plan for getting Automatic Updates, Project Browser and Package Manager into core. We're likely going to aim to land Package Manager first. So postponing this issue for now, until the dust settles on that.
- Status changed to Active
over 1 year ago 2:22pm 9 May 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Package Manager alpha blockers are all done, unpostponing.
- Status changed to Needs review
over 1 year ago 12:28pm 11 May 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
At #3341406-6: Document when PostApplyEvent should be used instead of hook_update_n() or post update β , it was explained in detail by @tedbow why we want to keep
PostApplyEvent
.That means that during unattended (currently cron) updates, we still need to trigger it. And in
HEAD
as of today,CronUpdateStage
:- runs the entire stage life cycle in a single request
- and hence has to perform
\Drupal\automatic_updates\CronUpdateStage::triggerPostApply()
usingcurl
to force\Drupal\package_manager\StageBase::postApply()
to happen in a separate PHP process -
But π For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits Fixed is going to change that, so the risks are lower. However, we still want
\Drupal\package_manager\StageBase::postApply()
to be called as soon as possible after theapply
operation is complete, because without its// Rebuild the container and clear all caches, to ensure that new services // are picked up. drupal_flush_all_caches();
β¦ the site will not be ready for use after the update, and we won't be able to turn off maintenance mode π± That's why the current solution was introduced in #3291147: Successfully applying an update puts the remainder of the request into an unreliable state β , to avoid π
Fortunately, Drupal core has already solved this once before:
update.php
and theUpdateKernel
. Which AFAICT has never been discussed:- https://www.drupal.org/project/issues/automatic_updates?text=update.php&... β β 0 hits
- https://www.drupal.org/project/issues/automatic_updates?text=updatekerne... β β 0 hits
(well, now that this is posted they'll each get 1 hit of courseβ¦)
That was already forced to deal with complex edge cases: #2863986: Allow updating modules with new service dependencies β . Surely we should be able to adopt the same pattern for Automatic Updates?
Note that it's
\Drupal\system\Controller\DbUpdateController::batchFinished()
which does both:-
drupal_flush_all_caches();
-
// Now that the update is done, we can put the site back online if it was // previously not in maintenance mode. if (!$session->remove('maintenance_mode')) { \Drupal::state()->set('system.maintenance_mode', FALSE); }
β¦ which is exactly what we're after.
tl;dr: I propose first letting π For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits Fixed handle updating the existing
CronUpdateStage
to work across multiple requests and then use this issue to convert it to use core's existingUpdateKernel
and related infrastructure. If that fails, we should be able to subclass it to add the tweaks we need.
- Assigned to tedbow
- Status changed to Postponed
over 1 year ago 9:19am 14 June 2023 - π§πͺBelgium wim leers Ghent π§πͺπͺπΊ
Per @tedbow at #3360656-7: For web cron updates run each stage life cycle phase in a different request β , π For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits Fixed is now THE way forward.
So β¦ AFAICT that means this can be tentatively postponed. Once #3357969 lands, I think this can be marked ?
- πΊπΈUnited States tedbow Ithaca, NY, USA
#19 yep. assuming we can solve π For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits Fixed the way we hope then we won't need this. I feel about 90% certain we can
- Issue was unassigned.
- Status changed to Closed: outdated
over 1 year ago 1:39am 21 July 2023 - πΊπΈUnited States tedbow Ithaca, NY, USA
We shouldn't need this because π For web server dependent unattended updates run the entire life cycle in a separate process that will not be affected by hosting time limits Fixed seems to be working