Applicable to:
- Plesk for Linux
Symptoms
- The migration of a Subscription example.com shows the following error in Plesk > Tools & Settings > Migration & Transfer Manager > source_server_IP > example.com > Details:
- PLESK_ERROR: Failed to adjust common migrated applications for new environmentMigration tools tried to perform operation in 3 attempts: Unterminated string starting at: line 1 column 73 (char 72)
-
In
/usr/local/psa/var/modules/panel-migrator/sessions/<_session_id_>/debug.logthe following is logged related to the same issue:CONFIG_TEXT: |D|ST1|plesk.actions.adjust_applications|example.com||Start adjust database connection settings in configuration files of subscription
|D|ST1|core.runners.unix.user_local|example.com||Execute command on the local server: /usr/local/psa/admin/sbin/vhostmng-find
|D|ST1|core.safe|example.com||Exception:
|D|ST1|core.safe|example.com||Traceback (most recent call last):
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/safe.py", line 191, in try_subscription_with_rerun
|D|ST1|core.safe|example.com|| func()
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/workflow/runner/by_subscription.py", line 526, in
|D|ST1|core.safe|example.com|| lambda: action.run(self._context, subscription),
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/plesk/actions/adjust_applications.py", line 100, in run
|D|ST1|core.safe|example.com|| issues = adjuster.adjust_database(
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/application/adjuster.py", line 131, in adjust_database
|D|ST1|core.safe|example.com|| tree = runner.get_dir_tree(self._base_path)
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/runners/unix/user_local.py", line 120, in get_dir_tree
|D|ST1|core.safe|example.com|| return build_dir_tree(
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/utils/file_utils.py", line 196, in build_dir_tree
|D|ST1|core.safe|example.com|| for path, is_directory in items:
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/runners/unix/user_local.py", line 121, in
|D|ST1|core.safe|example.com|| (
|D|ST1|core.safe|example.com|| File "/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/runners/unix/user_local.py", line 298, in _iter_command_items
|D|ST1|core.safe|example.com|| yield json.loads(str_decode(line))
|D|ST1|core.safe|example.com|| File "/opt/plesk/python/3/lib64/python3.10/json/init.py", line 346, in loads
|D|ST1|core.safe|example.com|| return _default_decoder.decode(s)
|D|ST1|core.safe|example.com|| File "/opt/plesk/python/3/lib64/python3.10/json/decoder.py", line 337, in decode
|D|ST1|core.safe|example.com|| obj, end = self.raw_decode(s, idx=_w(s, 0).end())
|D|ST1|core.safe|example.com|| File "/opt/plesk/python/3/lib64/python3.10/json/decoder.py", line 353, in raw_decode
|D|ST1|core.safe|example.com|| obj, end = self.scan_once(s, idx)
|D|ST1|core.safe|example.com||json.decoder.JSONDecodeError: Unterminated string starting at: line 1 column 73 (char 72)
|E|ST1|core.safe|example.com||Failed to adjust common migrated applications for new environment. Try to repeat operation once more. -
example.com has a file that which name includes non-UTF-8 characters, in this particular case the original file name was "View - ショートカット.lnk":
CONFIG_TEXT: /var/www/vhosts/example.com/httpdocs/dsadmin/View - \203V\203\207\201[\203g\203J\203b\203g.lnk
Cause
The issue is caused by a bug in the Plesk Migrator extension identified as #PPP-72968 due to non-UTF-8 characters being present on file names within the subscription.
One can monitor the Plesk Changelog or follow this article for when the bug fix is released.
Resolution
Until the bug is resolved, execute the following steps as a workaround
- Connect to the server via SSH
-
Create and edit a file, for example patch.sh:
# vim patch.sh
-
Paste the following code within it:
CONFIG_TEXT: F=/usr/local/psa/admin/plib/modules/panel-migrator/backend/lib/python/parallels/core/application/adjuster.py
cp -a "$F" "$F.orig-pmt5697"
python3 - "$F" <<'PY'
import sys
f = sys.argv[1]
old = """ with self._target_server.user_runner(self._system_user) as runner:
assert isinstance(runner, BaseRunner)
tree = runner.get_dir_tree(self._base_path)
"""
new = """ # PMT-5697 workaround: list the tree as administrator, because 'vhostmng-find'
# aborts its JSON output on file names which are not valid UTF-8
with self._target_server.runner() as runner:
tree = runner.get_dir_tree(self._base_path)
"""
s = open(f, encoding='utf-8').read()
assert s.count(old) == 1, "source block not found exactly once - do not patch, check the version"
open(f, 'w', encoding='utf-8').write(s.replace(old, new))
print("patched OK")
PY
python3 -m py_compile "$F" && echo "syntax OK" -
Execute the script:
# bash ./patch.sh
- Re-sync the failed Subscription via Tools & Settings > Migration and transfer settings > click on the Migration > Re-sync
-
Reverse the file changes by running the following command:
# mv "$F.orig-pmt5697" "$F"
Comments
Please sign in to leave a comment.