Problem/Motivation
Travis Carden wrote:
Okay, so first of all, why don’t we create a backup copy of the original codebase and try to restore from it if committing the stage directory doesn’t work? I think that’s a good idea on one level, but it would be vulnerable to the same problem it would exist to correct--namely, the file syncer just failed to sync from the staging directory, so we use the same file syncer to sync from the backup directory. Assuming the ambient conditions haven’t changed (in the ~seconds) between the two operations, the restore operation seems just as likely to fail for the same reason as the commit. (You know what would be nice? A Git-based file syncer that could just test for a dirty working directory to see if the site is in a broken state and restore it via `git reset --hard`. Maybe someday, huh? :)
Second, does Composer Stager know how far along it is in the copying process? No, it doesn’t. In the case of the rsync file syncer, I don’t know if there’s a way it could know. In the case of the PHP file syncer, such an ability could conceivably be added.
Turns out that we don't particularly encourage the use of rsync, which does perform integrity checks. I think it's great that we have a fallback mechanism (the "PHP" file syncer), but if rsync is available, we really should recommend using it! Because rsync always performs integrity checks, and in a much more performant way than we ever could. Plus, they have decades of battle hardening!
Furthermore, since #3319507: Add symlink support to Composer Stager 2.0, require that version, and simplify UX & tests accordingly, it is already a requirement to use the rsync file syncer anyway if there are >0 symlinks to directories present in the codebase.
Steps to reproduce
N/A
Proposed resolution
- Status report entry that strongly recommends the use of
rsyncand warns the user if that's not being used. - Detect presence of
rsyncduring installation and then automatically switch torsyncinstead ofphpfile syncer (which is the sensible default: it always works).
Remaining tasks
User interface changes
API changes
None.
Data model changes
None.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Screenshot 2023-04-19 at 2.00.01 PM.png | 49.51 KB | wim leers |
| #3 | Screenshot 2023-04-19 at 1.59.31 PM.png | 55.21 KB | wim leers |
| #3 | Screenshot 2023-04-19 at 2.01.03 PM.png | 50.37 KB | wim leers |
Issue fork automatic_updates-3355105
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
Comment #3
wim leersJust implemented status report entry:
Comment #4
phenaproximaThe tests, they are a-failin'...
Comment #5
wim leersUnassigning since I haven't had time for this and won't soon.
Comment #6
wim leersNote that I believe that we could install
rsyncon DrupalCI. See https://www.drupal.org/drupalorg/docs/drupal-ci/customizing-drupalci-tes....But we should also just request them to install it — seems like that'd not be a big deal. Tagging for that — the follow-up is necessary not here but in the DrupalCI issue queue!
Comment #7
tedbow@Wim Leers I assuming that #6 means we could install rsync in drupalci.yml
How hard would that be? Should we just try it here? If so we might want to add data provider to our build tests to run both copiers.
One concern I have is we might recommend something we don't test. We mention briefly in discussions that maybe that is ok because composer stage is testing rsync but there is no mention in the issue summary.
So rsync does integrity checks after or during the copy?
If rsync fails in integrity checks are we thinking that logic is
\Drupal\package_manager\StageBase::applywould catch this and throw aApplyFailedExceptionerror where the php syncer would just not check?Comment #8
wim leersQuoting
man rsync:Note that
\PhpTuf\ComposerStager\Infrastructure\Service\FileSyncer\RsyncFileSyncerdoes not set--checksumor-c. But it's that second paragraph that explains why that's simply unnecessary:rsyncalways checksums when transferring data.Yes:
would throw and
would catch it and would contain the
stderroutput (starting with\Symfony\Component\Process\Exception\ProcessFailedException).Comment #9
wim leers#6:
Done: #3362143: Use the rsync file syncer by default.
Comment #10
tedbowWe don't need postpone this issue because I think there are still actionable steps here but we should not commit it until we make sure the test failures are rsync not that we actually testing it in #3362143: Use the rsync file syncer by default are resolved.
Comment #11
omkar.podey commentedComment #12
omkar.podey commentedcreating a validator
Comment #13
wim leersDiscussed with @omkar.podey:
rsyncon DrupalCI (commit #3362143-10: Use the rsync file syncer by default as a commit in this MR).Because the proposed resolution in the issue summary does already say this:
Comment #14
wim leers@tedbow tagged this in #7. But that was specifically for ensuring that our recommendation actually works: i.e. that tests can pass when using
rsync.That is exactly what #3362143: Use the rsync file syncer by default is for (which was opened after #7). So marking this postponed on that issue, but we can already get this issue 100% ready, so it can land immediately after we sort out the remaining problems in #3362143 👍
Comment #15
omkar.podey commentedThe failure occurs in
\Drupal\Tests\automatic_updates\Build\CoreUpdateTestbuild test with 2 failuresComment #16
omkar.podey commentedComment #17
tedbowTests failing. I haven't looked further yet
Comment #18
tedbowComment #19
phenaproximaBlocker is in.
Comment #20
tedbowNeeds work, see MR comment
Comment #21
phenaproximaComment #22
tedbowI think this looks good but could use other opinions on the wording.
Comment #23
wim leersI helped @omkar.podey:
TERMINATEevent (because it happens after the status report page has rendered!)Comment #24
omkar.podey commentedthe comment just above is for another issue, i have ported the comment to #3363725: Disallow unattended updates if performed by automated_cron
Comment #25
tedbowchanging the title because there are know problem with the PHP syncer.
Comment #26
phenaproximaComment #27
tedbowSee MR comments
Comment #28
phenaproximaComment #29
tedbowComment #30
tedbowI think this looks good but tests failed
Comment #31
phenaproximaComment #32
tedbowLooks good. I just removed one left over change
Comment #33
wim leersLooks superb now!
Just one question. One line in
hook_help()that I think is obsolete.Comment #35
phenaproximaComment #36
wim leersWhy was this committed without actually answering my question? I don't understand why a "I'm not sure" is followed by a commit?
So I still think that this is essentially noise in
hook_help():But … since this is "just"
hook_help()which will change anyway when going into core … not reopening this.