gpt4 book ai didi

linux - Azure 云初始化 : Failed to install packages

转载 作者:行者123 更新时间:2023-12-02 02:11:10 27 4
gpt4 key购买 nike

我有一个简单的 cloud-init 文件:

#cloud-config
package_upgrade: true

packages:
- symlinks
- wget
- rsync
- git

但我的 Azure 失败(最后提供日志)。
这是我第一次在 Azure 上使用 cloud-init。
可能出了什么问题以及如何修复它?

PS。我的虚拟机:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

$ uname -rm
5.10.0-6-cloud-amd64 x86_64

失败日志:

2021-05-28 14:44:26,704 - util.py[DEBUG]: Cloud-init v. 20.4.1 running 'modules:final' at Fri, 28 May 2021 14:44:26 +0000. Up 25.34 seconds.
2021-05-28 14:44:26,748 - stages.py[DEBUG]: Using distro class <class 'cloudinit.distros.debian.Distro'>
2021-05-28 14:44:26,749 - stages.py[DEBUG]: Running module package-update-upgrade-install (<module 'cloudinit.config.cc_package_update_upgrade_install' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py'>) with frequency once-per-instance
2021-05-28 14:44:26,749 - handlers.py[DEBUG]: start: modules-final/config-package-update-upgrade-install: running config-package-update-upgrade-install with frequency once-per-instance
2021-05-28 14:44:26,756 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/1dd6dd52-1a5f-4a41-9810-da5e50583762/sem/config_package_update_upgrade_install - wb: [644] 24 bytes
2021-05-28 14:44:26,756 - helpers.py[DEBUG]: Running config-package-update-upgrade-install using lock (<FileLock using file '/var/lib/cloud/instances/1dd6dd52-1a5f-4a41-9810-da5e50583762/sem/config_package_update_upgrade_install'>)
2021-05-28 14:44:26,757 - util.py[DEBUG]: Writing to /var/lib/cloud/instances/1dd6dd52-1a5f-4a41-9810-da5e50583762/sem/update_sources - wb: [644] 22 bytes
2021-05-28 14:44:26,757 - helpers.py[DEBUG]: Running update-sources using lock (<FileLock using file '/var/lib/cloud/instances/1dd6dd52-1a5f-4a41-9810-da5e50583762/sem/update_sources'>)
2021-05-28 14:44:26,757 - subp.py[DEBUG]: Running command ['apt-get', '--option=Dpkg::Options::=--force-confold', '--option=Dpkg::options::=--force-unsafe-io', '--assume-yes', '--quiet', 'update'] with allowed return codes [0] (shell=False, capture=False)
2021-05-28 14:44:27,179 - util.py[DEBUG]: apt-update [apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::options::=--force-unsafe-io --assume-yes --quiet update] took 0.422 seconds
2021-05-28 14:44:27,180 - util.py[WARNING]: Package update failed
2021-05-28 14:44:27,180 - util.py[DEBUG]: Package update failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py", line 86, in handle
cloud.distro.update_package_sources()
File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 205, in update_package_sources
self._runner.run("update-sources", self.package_command,
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 185, in run
results = functor(*args)
File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 199, in package_command
util.log_time(logfunc=LOG.debug,
File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2348, in log_time
ret = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 293, in subp
raise ProcessExecutionError(stdout=out, stderr=err,
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['apt-get', '--option=Dpkg::Options::=--force-confold', '--option=Dpkg::options::=--force-unsafe-io', '--assume-yes', '--quiet', 'update']
Exit code: 100
Reason: -
Stdout: -
Stderr: -
2021-05-28 14:44:27,386 - subp.py[DEBUG]: Running command ['apt-get', '--option=Dpkg::Options::=--force-confold', '--option=Dpkg::options::=--force-unsafe-io', '--assume-yes', '--quiet', 'dist-upgrade'] with allowed return codes [0] (shell=False, capture=False)
2021-05-28 14:44:27,464 - util.py[DEBUG]: apt-upgrade [apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::options::=--force-unsafe-io --assume-yes --quiet dist-upgrade] took 0.078 seconds
2021-05-28 14:44:27,465 - helpers.py[DEBUG]: update-sources already ran (freq=once-per-instance)
2021-05-28 14:44:27,465 - subp.py[DEBUG]: Running command ['apt-get', '--option=Dpkg::Options::=--force-confold', '--option=Dpkg::options::=--force-unsafe-io', '--assume-yes', '--quiet', 'install', 'symlinks', 'wget', 'rsync', 'git'] with allowed return codes [0] (shell=False, capture=False)
2021-05-28 14:44:27,526 - util.py[DEBUG]: apt-install [apt-get --option=Dpkg::Options::=--force-confold --option=Dpkg::options::=--force-unsafe-io --assume-yes --quiet install symlinks wget rsync git] took 0.061 seconds
2021-05-28 14:44:27,526 - util.py[WARNING]: Failed to install packages: ['symlinks', 'wget', 'rsync', 'git']
2021-05-28 14:44:27,527 - util.py[DEBUG]: Failed to install packages: ['symlinks', 'wget', 'rsync', 'git']
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py", line 100, in handle
cloud.distro.install_packages(pkglist)
File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 112, in install_packages
self.package_command('install', pkgs=pkglist)
File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 199, in package_command
util.log_time(logfunc=LOG.debug,
File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2348, in log_time
ret = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 293, in subp
raise ProcessExecutionError(stdout=out, stderr=err,
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['apt-get', '--option=Dpkg::Options::=--force-confold', '--option=Dpkg::options::=--force-unsafe-io', '--assume-yes', '--quiet', 'install', 'symlinks', 'wget', 'rsync', 'git']
Exit code: 100
Reason: -
Stdout: -
Stderr: -
2021-05-28 14:44:27,527 - cc_package_update_upgrade_install.py[WARNING]: 2 failed with exceptions, re-raising the last one
2021-05-28 14:44:27,527 - handlers.py[DEBUG]: finish: modules-final/config-package-update-upgrade-install: FAIL: running config-package-update-upgrade-install with frequency once-per-instance
2021-05-28 14:44:27,527 - util.py[WARNING]: Running module package-update-upgrade-install (<module 'cloudinit.config.cc_package_update_upgrade_install' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py'>) failed
2021-05-28 14:44:27,528 - util.py[DEBUG]: Running module package-update-upgrade-install (<module 'cloudinit.config.cc_package_update_upgrade_install' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py'>) failed
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/cloudinit/stages.py", line 848, in _run_modules
ran, _r = cc.run(run_name, mod.handle, func_args,
File "/usr/lib/python3/dist-packages/cloudinit/cloud.py", line 54, in run
return self._runners.run(name, functor, args, freq, clear_on_fail)
File "/usr/lib/python3/dist-packages/cloudinit/helpers.py", line 185, in run
results = functor(*args)
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py", line 124, in handle
raise errors[-1]
File "/usr/lib/python3/dist-packages/cloudinit/config/cc_package_update_upgrade_install.py", line 100, in handle
cloud.distro.install_packages(pkglist)
File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 112, in install_packages
self.package_command('install', pkgs=pkglist)
File "/usr/lib/python3/dist-packages/cloudinit/distros/debian.py", line 199, in package_command
util.log_time(logfunc=LOG.debug,
File "/usr/lib/python3/dist-packages/cloudinit/util.py", line 2348, in log_time
ret = func(*args, **kwargs)
File "/usr/lib/python3/dist-packages/cloudinit/subp.py", line 293, in subp
raise ProcessExecutionError(stdout=out, stderr=err,
cloudinit.subp.ProcessExecutionError: Unexpected error while running command.
Command: ['apt-get', '--option=Dpkg::Options::=--force-confold', '--option=Dpkg::options::=--force-unsafe-io', '--assume-yes', '--quiet', 'install', 'symlinks', 'wget', 'rsync', 'git']
Exit code: 100
Reason: -
Stdout: -
Stderr: -

最佳答案

较新版本的 apt 使用选项字符串,因此您可以延长超时并向命令添加重试。例如:

sudo apt update -o Dpkg::Lock::Timeout=60 -o Acquire::Retries=60

您可以将其包含在云配置文件中。 (示例 cloud-init 文件。)

apt:
conf: |
Acquire::Retries "60";
DPkg::Lock::Timeout "60";

这将创建一个文件/etc/apt/apt.conf.d/94cloud-init-config。这些选项有助于避免 waagent 竞争时立即出现锁定错误。

其他信息:

关于linux - Azure 云初始化 : Failed to install packages,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67741343/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com