Applicable to:
- Plesk for Linux
Symptoms
-
During the migration of a subscription, the following error in shown in Plesk at Tools & Settings > Migration & Transfer Manager > 203.0.113.2 > example.com > Details:
PLESK_ERROR: Failed to adjust common migrated applications for new environment
Migration 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.log, the following entries are logged: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. -
The subscription contains a file whose name includes non-UTF-8 characters. In this particular example, 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
This issue is caused by a bug in the Plesk Migrator extension tracked under bug ID #PPP-72968. It occurs when file names within the subscription contain non-UTF-8 characters.
Resolution
A fix will be released in future Plesk versions. Follow this article to receive an update when the bug fix is released.
Workaround
As a workaround, execute the following steps:
- Connect to the target server via SSH.
-
Create and edit a file named
patch.sh:# vi patch.sh
-
Paste the following code within the file:
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 it:
# 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.