Problem/Motivation

#3276255: Disable unattended updates until TUF integration is complete hardcoded \Drupal\automatic_updates\CronUpdater::$disabled = TRUE until PHP-TUF integration is complete.

It re-enables it in tests only using PHP reflection … but using a KernelEvents::REQUEST subscriber, which can result in race conditions, which we discovered in #3306283-23: If cron updates are disabled display a message if status checks fail after installing Automatic Updates.

Steps to reproduce

Proposed resolution

Lets not strictly use the config setting automatic_updates.settings.cron to determine what cron is in. This will still disable cron by default and we will not create a UI for updating this until we do #3284443: Enable unattended updates

So here is what I think we need todo.

  1. Remove the test module automatic_updates_test_cron
  2. remove the \Drupal\automatic_updates\CronUpdater::$disabled and 1 place we check this in \Drupal\automatic_updates\CronUpdater::getMode
  3. change automatic_updates.settings.yml to default the cron setting to disable
  4. Remove automatic_updates_test_cron from \Drupal\Tests\automatic_updates\Kernel\AutomaticUpdatesKernelTestBase::$modules and other base tests
    Instead in setUp() of these tests do $this->config('automatic_updates.settings')->set('cron', CronUpdater::SECURITY); this will have the same effect as having the current test module
  5. search automatic_updates_test_cron to make sure it is not referenced else where

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Wim Leers created an issue. See original summary.

tedbow’s picture

Assigned: Unassigned » omkar.podey
Issue summary: View changes
Related issues: +#3284443: Enable unattended updates
tedbow’s picture

Issue tags: +core-mvp, +sprint

omkar.podey made their first commit to this issue’s fork.

wim leers’s picture

IMHO we should also add a hook_requirements() here, just like #3068275: Add status report message about JSON:API's read-only mode did. Except that when it's disabled, it should be a REQUIREMENT_WARNING. (Note that that doesn't have test coverage even in core.

omkar.podey’s picture

I am looking at \Drupal\Tests\automatic_updates\Functional\StatusCheckTest right now and while testing testStatusChecksOnAdminPages() i am running in to the error 'You do not have any administrative items.' while trying to access 'admin/structure' .

omkar.podey’s picture

Status: Active » Needs review
wim leers’s picture

You do not have any administrative items.
  1. Search that string in the codebase
  2. Figure out which permission you're missing
  3. Grant that permission in the test 👍
wim leers’s picture

Status: Needs review » Needs work

… if that's tricky to figure out, put a breakpoint on the place where that string exists and observe why it reached that point: which access check failed to grant access → this will tell you what kind of access needs to be granted.

tedbow’s picture

omkar.podey’s picture

Assigned: omkar.podey » wim leers
wim leers’s picture

While pairing with @omkar.podey, we hit a particularly nasty/complicated race condition, so I asked @omkar.podey to assign this to me 👍

wim leers’s picture

This is extremely tricky because \Drupal\automatic_updates\EventSubscriber\ConfigSubscriber::onConfigSave() always calls $this->statusChecker->clearStoredResults();, which means that any prior state is always wiped, both on module install and on $this->config('automatic_updates.settings')->set('cron', CronUpdater::SECURITY)->save();

… and that's only a problem because \Drupal\Tests\automatic_updates\Kernel\StatusCheck\StatusCheckerTest::testRunOnInstall() is trying to test a scenario that will some day be the default (once #3284443: Enable unattended updates is done), but for now is forcibly disabled, so we need to forcibly re-enable it in the test, temporarily. Will sleep on it.

wim leers’s picture

Assigned: wim leers » omkar.podey

Green!

Left 5 more remarks on the MR for @omkar.podey to address.

omkar.podey’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Needs work
Issue tags: +Needs change record

3 remarks on the merge request that require changes: missing update path (+test), the form alter, and a nit about minimizing diff size.

omkar.podey’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Needs work

6 remarks, including me realizing that #6 is not yet addressed!

Also note that this still needs a change record. You can find hundreds of examples at http://drupal.org/list-changes/drupal

omkar.podey’s picture

Not sure about the hook implementation, does the error needs to be suppressed or do we want to update assertions in \Drupal\Tests\automatic_updates\Functional\StatusCheckTest::testStatusChecksOnStatusReport

omkar.podey’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Needs work

4 remarks on the MR, I'm pretty sure that one of those contains the solution to the failing test! 🤓

omkar.podey’s picture

Status: Needs work » Needs review
wim leers’s picture

Status: Needs review » Reviewed & tested by the community

No more remarks! The one thing we still need here, is a change record. See the examples I linked to in #19.

omkar.podey’s picture

Created, The change record. saved as draft for now, can someone review that too ?

omkar.podey’s picture

Issue tags: -Needs change record
wim leers’s picture

Assigned: omkar.podey » Unassigned

🚀

tedbow’s picture

Assigned: Unassigned » omkar.podey
Status: Reviewed & tested by the community » Needs work

Needs work for MR comments

wim leers’s picture

There are only two comments that @omkar.podey can address (i) the language nit, ii) for adding @todo comments to more places).

The last comment I posted on the MR is something that @tedbow should clarify first as the project lead, it's not currently actionable by @omkar.podey yet.

omkar.podey’s picture

Assigned: omkar.podey » tedbow
Status: Needs work » Needs review
tedbow’s picture

Assigned: tedbow » wim leers

🏓

wim leers’s picture

Assigned: wim leers » tedbow

🏓

omkar.podey’s picture

Assigned: tedbow » omkar.podey
Status: Needs review » Needs work
omkar.podey’s picture

Assigned: omkar.podey » wim leers
Status: Needs work » Needs review
wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs review » Reviewed & tested by the community

Ready now, with all of @tedbow's concerns addressed! 👍

tedbow’s picture

Assigned: Unassigned » wim leers
Status: Reviewed & tested by the community » Needs work

Needs work for a strong warning if cron updates are enabled. Assign to @Wim Leers because he may have an idea for a stronger or clearer message.

wim leers’s picture

Assigned: wim leers » Unassigned

Posted a suggestion.

tedbow’s picture

Assigned: Unassigned » wim leers
wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs work » Reviewed & tested by the community
tedbow’s picture

Assigned: Unassigned » tedbow

Merged in 8.x-2.x again. assigning to myself to merge on green

  • f4a8680 committed on 8.x-2.x
    Issue #3321256 by omkar.podey, tedbow, Wim Leers: Fix race condition in...
tedbow’s picture

Status: Reviewed & tested by the community » Fixed

@Wim Leers & @omkar.podey thanks for sticking with this one!

tedbow’s picture

Assigned: tedbow » Unassigned

@Wim Leers & @omkar.podey thanks for sticking with this one!

wim leers’s picture

Change record published. 👍

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.