Skip to content

[Bug] - SSM Auto Update conflicts with cloud-init package install (e.g. userData Docker installation fails on EC2. [Errno 2] No such file or directory) #397

Open

Description

@ambrosdavid

Describe the bug
When creating an EC2 instance using userData to init Docker, 9/10 times the command yum install docker -y fails giving the following error:
[Errno 2] No such file or directory: '/var/cache/dnf/amazonlinux-db3877fdc20f892f/packages/libnetfilter_conntrack-1.0.8-2.amzn2023.0.2.x86_64.rpm'
The dependency name in that path also changes and it's not always the same.

Out of 30 instances created, only about 4 had their docker installation successful, so sometimes for some reason it doesn't give any error.

If I use a Sleep of 10s inside the bash script before the yum install docker -y command, the installation works without any problem.
If I write twice the yum install docker -y command in the bash script, the installation works.
If I ssh into the created ec2 instance and execute manually the command sudo yum install docker -y, the installation works.

To Reproduce
ImageId: ami-0f61de2873e29e866
InstanceType: "t2.micro",

userData script:

#!/bin/bash
set -x
yum update -y
yum upgrade -y
yum install -y docker
systemctl start docker
systemctl enable docker
usermod -aG docker ec2-user
wget https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-$(uname -s)-$(uname -m) -O /usr/bin/docker-compose
chmod +x /usr/bin/docker-compose

Logs
cat /var/log/cloud-init-output.log >>>>>>>>

Cloud-init v. 22.2.2 running 'modules:config' at Mon, 10 Jul 2023 14:05:45 +0000. Up 11.41 seconds.
Cloud-init v. 22.2.2 running 'modules:final' at Mon, 10 Jul 2023 14:05:46 +0000. Up 12.60 seconds.
+ yum update -y
Amazon Linux 2023 repository                     21 MB/s |  15 MB     00:00    
Amazon Linux 2023 Kernel Livepatch repository   272 kB/s | 158 kB     00:00    
Last metadata expiration check: 0:00:01 ago on Mon Jul 10 14:05:58 2023.
Dependencies resolved.
Nothing to do.
Complete!
+ yum upgrade -y
Last metadata expiration check: 0:00:04 ago on Mon Jul 10 14:05:58 2023.
Dependencies resolved.
Nothing to do.
Complete!
+ yum install -y docker
Last metadata expiration check: 0:00:06 ago on Mon Jul 10 14:05:58 2023.
Dependencies resolved.
================================================================================
 Package                 Arch    Version                     Repository    Size
================================================================================
Installing:
 docker                  x86_64  20.10.23-1.amzn2023.0.1     amazonlinux   42 M
Installing dependencies:
 containerd              x86_64  1.6.19-1.amzn2023.0.1       amazonlinux   31 M
 iptables-libs           x86_64  1.8.8-3.amzn2023.0.2        amazonlinux  401 k
 iptables-nft            x86_64  1.8.8-3.amzn2023.0.2        amazonlinux  183 k
 libcgroup               x86_64  3.0-1.amzn2023.0.1          amazonlinux   75 k
 libnetfilter_conntrack  x86_64  1.0.8-2.amzn2023.0.2        amazonlinux   58 k
 libnfnetlink            x86_64  1.0.1-19.amzn2023.0.2       amazonlinux   30 k
 libnftnl                x86_64  1.2.2-2.amzn2023.0.2        amazonlinux   84 k
 pigz                    x86_64  2.5-1.amzn2023.0.3          amazonlinux   83 k
 runc                    x86_64  1.1.7-1.amzn2023.0.1        amazonlinux  3.0 M

Transaction Summary
================================================================================
Install  10 Packages

Total download size: 77 M
Installed size: 300 M
Downloading Packages:
(1/10): libnetfilter_conntrack-1.0.8-2.amzn2023 336 kB/s |  58 kB     00:00    
(2/10): libnftnl-1.2.2-2.amzn2023.0.2.x86_64.rp 440 kB/s |  84 kB     00:00    
(3/10): iptables-nft-1.8.8-3.amzn2023.0.2.x86_6 3.8 MB/s | 183 kB     00:00    
(4/10): libcgroup-3.0-1.amzn2023.0.1.x86_64.rpm 909 kB/s |  75 kB     00:00    
(5/10): iptables-libs-1.8.8-3.amzn2023.0.2.x86_ 4.6 MB/s | 401 kB     00:00    
(6/10): libnfnetlink-1.0.1-19.amzn2023.0.2.x86_ 616 kB/s |  30 kB     00:00    
(7/10): pigz-2.5-1.amzn2023.0.3.x86_64.rpm      1.2 MB/s |  83 kB     00:00    
(8/10): runc-1.1.7-1.amzn2023.0.1.x86_64.rpm     11 MB/s | 3.0 MB     00:00    
(9/10): docker-20.10.23-1.amzn2023.0.1.x86_64.r  29 MB/s |  42 MB     00:01    
(10/10): containerd-1.6.19-1.amzn2023.0.1.x86_6  18 MB/s |  31 MB     00:01    
--------------------------------------------------------------------------------
Total                                            32 MB/s |  77 MB     00:02     
[Errno 2] No such file or directory: '/var/cache/dnf/amazonlinux-db3877fdc20f892f/packages/libnetfilter_conntrack-1.0.8-2.amzn2023.0.2.x86_64.rpm'
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
+ systemctl start docker
Failed to start docker.service: Unit docker.service not found.
+ systemctl enable docker
Failed to enable unit: Unit file docker.service does not exist.
+ usermod -aG docker ec2-user
usermod: group 'docker' does not exist
++ uname -s
++ uname -m
+ wget https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-Linux-x86_64 -O /usr/bin/docker-compose
--2023-07-10 14:06:08--  https://github.com/docker/compose/releases/download/v2.15.1/docker-compose-Linux-x86_64
Resolving github.com (github.com)... 140.82.121.3
Connecting to github.com (github.com)|140.82.121.3|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://objects.githubusercontent.com/github-production-release-asset-2e65be/15045751/55771899-fdc1-4531-974a-0b71aea19e15?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230710%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230710T140609Z&X-Amz-Expires=300&X-Amz-Signature=d3b008815385781f37ea4890bd1fc8dc49f04ae4cd27fcc6f1f5d44ebe1fbfc4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=15045751&response-content-disposition=attachment%3B%20filename%3Ddocker-compose-linux-x86_64&response-content-type=application%2Foctet-stream [following]
--2023-07-10 14:06:09--  https://objects.githubusercontent.com/github-production-release-asset-2e65be/15045751/55771899-fdc1-4531-974a-0b71aea19e15?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20230710%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20230710T140609Z&X-Amz-Expires=300&X-Amz-Signature=d3b008815385781f37ea4890bd1fc8dc49f04ae4cd27fcc6f1f5d44ebe1fbfc4&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=15045751&response-content-disposition=attachment%3B%20filename%3Ddocker-compose-linux-x86_64&response-content-type=application%2Foctet-stream
Resolving objects.githubusercontent.com (objects.githubusercontent.com)... 185.199.110.133, 185.199.111.133, 185.199.108.133, ...
Connecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.110.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 44953600 (43M) [application/octet-stream]
Saving to: ‘/usr/bin/docker-compose’

     0K .......... .......... .......... .......... ..........  0% 15.4M 3s
    50K .......... .......... .......... .......... ..........  0% 13.9M 3s
   100K .......... .......... .......... .......... ..........  0% 13.6M 3s
  [...]
 43850K .......... .......... .......... .......... ..........100% 83.0M 0s
 43900K                                                       100% 0.00 =1.1s

2023-07-10 14:06:10 (39.2 MB/s) - ‘/usr/bin/docker-compose’ saved [44953600/44953600]

+ chmod +x /usr/bin/docker-compose
Cloud-init v. 22.2.2 finished at Mon, 10 Jul 2023 14:06:11 +0000. Datasource DataSourceEc2.  Up 37.29 seconds

Activity

  1. added
    bug
    on Jul 10, 2023
  2. stewartsmith commented on Jul 10, 2023

    @stewartsmith
    Contributor

    Well that's interesting!

    Thanks for the report, certainly something we're going to have to dive into and understand what's going on.

    Out of interesting, have you tried on any larger instance sizes than t2.micro? Any chance there's something in dmesg about running out of memory or anything? (no need to burn a bunch of your ec2 $ on this if you haven't tested, we can certainly test at scale for this with the steps you have provided)

  3. ambrosdavid commented on Jul 12, 2023

    @ambrosdavid
    Author

    Hello Stewart thanks for the reply, I have just tried to create 5 t3.medium instances and on all of them docker got installed successfully without any problem and without having to use the sleep command 👍

  4. mwebber commented on Jul 28, 2023

    @mwebber

    cc: @stewartsmith
    Just to contribute, we had occasional failures with a related but different error message, and we found that a sleep was required and sufficient to fix the problem. This is on a t3.large.

    The error message we got if we tried the dnf install too early was
    "can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)"

    Here's the relevant part of our userdata script, with our workaround:

    # Script written for Amazon Linux 2023
    
    printf "\n*** $(date +'%Y-%m-%d %H:%M:%S') INITIAL SETUP STARTING\n"
    uname -a
    
    printf "\n\n*** $(date +'%Y-%m-%d %H:%M:%S') Checking for and applying OS updates\n"
    system_release=$(rpm -q system-release --qf "%{VERSION}")
    printf "\n*** Current release ${system_release}\n"
    dnf check-release-update
    dnf check-update --releasever=${system_release}
    dnf update -y --releasever=${system_release}
    
    # sleep, in case of this error:
    # "can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)"
    sleep 60
    printf "\n\n*** $(date +'%Y-%m-%d %H:%M:%S') Installing additional packages\n"
    dnf -y install {{AMI_PACKAGES}}
  5. ambrosdavid commented on Jul 28, 2023

    @ambrosdavid
    Author

    It look like the userData script is being executed as soon as the instance is running and before finishing to initialise, instead of waiting for it to be in 'OK' status, also someone reported a similar problem in this StackOverflow post.

  6. bbenson29 commented on Aug 21, 2023

    @bbenson29

    I had a similar issue and this is what I did to fix it

    [Errno 2] No such file or directory: '/var/cache/dnf/amazonlinux-84ef13e8f4afd0b4/packages/libsepol-devel-3.4-3.amzn2023.0.3.x86_64.rpm'
    The downloaded packages were saved in cache until the next successful transaction.
    You can remove cached packages by executing 'dnf clean packages'.
    

    Fix

    sudo dnf upgrade --refresh rpm glibc
    sudo rm /var/lib/rpm/.rpm.lock
    dnf -y update
    dnf install  <MY PACKAGES>
    
  7. supergibbs commented on Sep 29, 2023

    @supergibbs

    @bbenson29 Had any issues with that? A bit hesitant to delete a lock. Would it be better to add a sleep 60 to ensure cloud-init is done?

  8. BlackDark commented on Oct 12, 2023

    @BlackDark

    Same problem here. Why is this still not fixed?
    This issue even happens with simple cloud init config where you directly use the packages directive without custom scripts.

  9. supergibbs commented on Oct 12, 2023

    @supergibbs

    AWS Support recommended the following. I agree it seems like there is an issue and we shouldn't need this, didn't in v1 or v2 but it's been working for me.

    while true; do
    dnf install --assumeyes docker && break
    done
    
    while true; do
    dnf update --assumeyes && break
    done
    
    
  10. rbpltr commented on Oct 18, 2023

    @rbpltr

    I've been trying to get to the bottom of this issue over the last 48 hours and I think it is caused by the SSM agent updater running at the same time as the user data scripts.

    See: https://docs.aws.amazon.com/systems-manager/latest/userguide/ssm-agent-automatic-updates.html#ssm-agent-automatic-updates-console

    I've disabled this in SSM Fleet Manager and the issue has gone away.

    If you do disable the automatic SSM agent updates, it's important that you know the consequences of this and implement the updates in another way!

    Edit: I'm specifically referring to the RPM lock issue btw...

  11. AB-DBMC commented on Oct 18, 2023

    @AB-DBMC

    The malfunction is apparently triggered by the Auto update SSM agent function. The SSM automation document AWS-UpdateSSMAgent is then executed on the EC2 instance, which eventually leads to this error when other YUM/DNF commands are processed at the same time:

    RPM: error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)
    Error: Could not run transaction.

    A quick and dirty workaround is to temporarily disable the Auto update SSM agent feature (Try it at your own risk, but it is not generally recommended).

    Systems Manager > Fleet Manager > Settings > Auto update SSM agent -> Disable

    After that, the error will no longer occur. As long as AWS does not have a bugfix here, the workaround of @supergibbs makes the most sense, but leads to multiple entries under yum history.

  12. changed the title [-][Bug] - userData Docker installation fails on EC2. [Errno 2] No such file or directory[/-] [+][Bug] - SSM Auto Update conflicts with cloud-init package install (e.g. userData Docker installation fails on EC2. [Errno 2] No such file or directory)[/+] on Oct 20, 2023
  13. stewartsmith commented on Oct 20, 2023

    @stewartsmith
    Contributor

    We've passed this along to the SSM team and they're tracking it in an internal ticket. I'll try and keep an eye on it.

  14. added
    aws-integration
    on Oct 20, 2023
  15. BenCoffeed commented on Dec 11, 2023

    @BenCoffeed

    Any update here? Having a real blast with 2023-powered EB engines.

  16. 23 remaining items

  17. thimslugga commented on Oct 13, 2024

    @thimslugga
    Contributor

    @thimslugga please correct me if I'm wrong, with this systemd override configuration the ssm-agent would start only after the cloud-init is done, this makes it impossible to connect to an instance when, for example a long-running bootstrap script is executing

    Not necessarily, you still should be able to connect via SSH + ec2-instance-connect + vpce, bastion or using the serial console.

    As for not be able to connect right away via session-manager and ssm-agent, that is downside of bundling multiple functionality into one agent. See: unix philosophy.

    With that said, I would argue that if you have long bootstrap times, whatever it is should probably be moved to be included as part of a golden image. Doing a bunch of stuff on initial boot is usually not ideal as there will be a lack of entropy accumulated, I/O latency due to restoring of volume, etc.

    https://aws.amazon.com/blogs/storage/addressing-i-o-latency-when-restoring-amazon-ebs-volumes-from-ebs-snapshots/

    https://www.exoscale.com/syslog/random-numbers-generation-in-virtual-machines/

    https://www.netdata.cloud/blog/understanding-entropy-the-key-to-secure-cryptography-and-randomness/

  18. modified the milestone: AL2023.6 on Oct 21, 2024
  19. stewartsmith commented on Oct 21, 2024

    @stewartsmith
    Contributor

    AL2023.6 has amazon-ssm-agent version 3.3.859.0-1.amzn2023 (see https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.6.20241010.html ) - are things any better with this version?

  20. rrehbein commented on Oct 25, 2024

    @rrehbein

    With 3.3.859.0 we still ran into issues when cloud-init would finish and CodeDeploy would start in our development environment during scale-up scenarios. In development we have a few additional yum-install calls related to development tooling installed via CodeDeploy rather than within cloud-init.

    The failures did not happen in cloud-init / cfn-init, so it that regard this version is better.

  21. nosnilmot commented on Nov 8, 2024

    @nosnilmot

    AL2023.6 has amazon-ssm-agent version 3.3.859.0-1.amzn2023 (see https://docs.aws.amazon.com/linux/al2023/release-notes/relnotes-2023.6.20241010.html ) - are things any better with this version?

    not obviously better. e.g.

    $ cat /etc/os-release
    NAME="Amazon Linux"
    VERSION="2023"
    ID="amzn"
    ID_LIKE="fedora"
    VERSION_ID="2023"
    PLATFORM_ID="platform:al2023"
    PRETTY_NAME="Amazon Linux 2023.6.20241031"
    ANSI_COLOR="0;33"
    CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
    HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
    DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
    SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
    BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
    VENDOR_NAME="AWS"
    VENDOR_URL="https://aws.amazon.com/"
    SUPPORT_END="2028-03-15"
    
    $ cat  /var/log/cloud-init-output.log
    ...
    + dnf -y install dnf-automatic dnf-utils docker htop jq kpatch-dnf nc redis6 mariadb105 dmidecode ec2-instance-connect
    Last metadata expiration check: 0:00:06 ago on Thu Nov  7 10:12:30 2024.
    Package dnf-utils-4.3.0-13.amzn2023.0.4.noarch is already installed.
    Package jq-1.7.1-48.amzn2023.0.1.x86_64 is already installed.
    Package ec2-instance-connect-1.1-19.amzn2023.noarch is already installed.
    Dependencies resolved.
    ================================================================================
     Package                    Arch   Version                    Repository   Size
    ================================================================================
    Installing:
     dmidecode                  x86_64 1:3.6-1.amzn2023.0.1       amazonlinux 100 k
     dnf-automatic              noarch 4.14.0-1.amzn2023.0.5      amazonlinux  29 k
     docker                     x86_64 25.0.6-1.amzn2023.0.2      amazonlinux  44 M
     htop                       x86_64 3.2.1-87.amzn2023.0.3      amazonlinux 183 k
     kpatch-dnf                 x86_64 0.4-13.amzn2023.0.1        amazonlinux  18 k
     mariadb105                 x86_64 3:10.5.25-1.amzn2023.0.1   amazonlinux 1.6 M
     nmap-ncat                  x86_64 3:7.93-4.amzn2023          amazonlinux 225 k
     redis6                     x86_64 6.2.14-2.amzn2023.0.1      amazonlinux 1.3 M
    Installing dependencies:
     containerd                 x86_64 1.7.22-1.amzn2023.0.2      amazonlinux  36 M
     iptables-libs              x86_64 1.8.8-3.amzn2023.0.2       amazonlinux 401 k
     iptables-nft               x86_64 1.8.8-3.amzn2023.0.2       amazonlinux 183 k
     libcgroup                  x86_64 3.0-1.amzn2023.0.1         amazonlinux  75 k
     libnetfilter_conntrack     x86_64 1.0.8-2.amzn2023.0.2       amazonlinux  58 k
     libnfnetlink               x86_64 1.0.1-19.amzn2023.0.2      amazonlinux  30 k
     libnftnl                   x86_64 1.2.2-2.amzn2023.0.2       amazonlinux  84 k
     mariadb-connector-c        x86_64 3.1.13-1.amzn2023.0.3      amazonlinux 196 k
     mariadb-connector-c-config noarch 3.1.13-1.amzn2023.0.3      amazonlinux 9.2 k
     mariadb105-common          x86_64 3:10.5.25-1.amzn2023.0.1   amazonlinux  29 k
     perl-Sys-Hostname          x86_64 1.23-477.amzn2023.0.6      amazonlinux  18 k
     pigz                       x86_64 2.5-1.amzn2023.0.3         amazonlinux  83 k
     runc                       x86_64 1.1.14-1.amzn2023.0.1      amazonlinux 3.2 M
    
    Transaction Summary
    ================================================================================
    Install  21 Packages
    
    Total download size: 88 M
    Installed size: 342 M
    Downloading Packages:
    (1/21): dnf-automatic-4.14.0-1.amzn2023.0.5.noa 224 kB/s |  29 kB     00:00
    (2/21): dmidecode-3.6-1.amzn2023.0.1.x86_64.rpm 490 kB/s | 100 kB     00:00
    (3/21): htop-3.2.1-87.amzn2023.0.3.x86_64.rpm   2.2 MB/s | 183 kB     00:00
    (4/21): iptables-libs-1.8.8-3.amzn2023.0.2.x86_ 5.7 MB/s | 401 kB     00:00
    (5/21): iptables-nft-1.8.8-3.amzn2023.0.2.x86_6 4.8 MB/s | 183 kB     00:00
    (6/21): kpatch-dnf-0.4-13.amzn2023.0.1.x86_64.r 330 kB/s |  18 kB     00:00
    (7/21): libcgroup-3.0-1.amzn2023.0.1.x86_64.rpm 1.4 MB/s |  75 kB     00:00
    (8/21): libnetfilter_conntrack-1.0.8-2.amzn2023 2.1 MB/s |  58 kB     00:00
    (9/21): libnfnetlink-1.0.1-19.amzn2023.0.2.x86_ 432 kB/s |  30 kB     00:00
    (10/21): libnftnl-1.2.2-2.amzn2023.0.2.x86_64.r 1.6 MB/s |  84 kB     00:00
    (11/21): mariadb-connector-c-3.1.13-1.amzn2023. 2.4 MB/s | 196 kB     00:00
    (12/21): mariadb-connector-c-config-3.1.13-1.am 442 kB/s | 9.2 kB     00:00
    (13/21): mariadb105-10.5.25-1.amzn2023.0.1.x86_ 7.1 MB/s | 1.6 MB     00:00
    (14/21): mariadb105-common-10.5.25-1.amzn2023.0 806 kB/s |  29 kB     00:00
    (15/21): nmap-ncat-7.93-4.amzn2023.x86_64.rpm   3.1 MB/s | 225 kB     00:00
    (16/21): containerd-1.7.22-1.amzn2023.0.2.x86_6  20 MB/s |  36 MB     00:01
    (17/21): perl-Sys-Hostname-1.23-477.amzn2023.0.  35 kB/s |  18 kB     00:00
    (18/21): pigz-2.5-1.amzn2023.0.3.x86_64.rpm     2.2 MB/s |  83 kB     00:00
    (19/21): runc-1.1.14-1.amzn2023.0.1.x86_64.rpm   15 MB/s | 3.2 MB     00:00
    (20/21): redis6-6.2.14-2.amzn2023.0.1.x86_64.rp 4.6 MB/s | 1.3 MB     00:00
    (21/21): docker-25.0.6-1.amzn2023.0.2.x86_64.rp  15 MB/s |  44 MB     00:02
    --------------------------------------------------------------------------------
    Total                                            28 MB/s |  88 MB     00:03
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
    RPM: error: can't create transaction lock on /var/lib/rpm/.rpm.lock (Resource temporarily unavailable)
    The downloaded packages were saved in cache until the next successful transaction.
    You can remove cached packages by executing 'dnf clean packages'.
    Error: Could not run transaction.
    ...
    
  22. ferricoxide commented on Jan 2, 2025

    @ferricoxide

    It looks like, when the SSM update is being done, it's using rpm -U … rather than leveraging dnf/yum? As such, it's an uncoordinated RPM update-action. Which is to say, a direct-invocation of rpm will write the problematic lockfile but dnf/yum won't be aware of what wrote the file. Since dnf/yum can't see any other dnf/yum running, they bomb-out on the lock-file's presence rather than going into a wait-state like normal.

    I only seem to run into this problem on Amazon Linux AMIs, presumably because the ones from Red Hat, Rocky, Alma, etc. don't bake SSM in. When using such AMIs, it's generally my userData payload/cloud-init that's installing the amazon-ssm-agent RPM. I either do this as part a larger dnf/yum install-action or as a standalone dnf/yum installation action. As such, even if my userData payload somehow attempt to do two dnf/yum actions simultaneously, the collision logic built into the dnf/yum utilities know how to sort things out. Maybe SSM's automated update can be fixed to use dnf/yum, instead of a direct-invocation of rpm -U …?

    Using dnf/yum is the generally better path, at any rate, since direct use of rpm can lead to differences of opinion between rpm's view of the package database and the dnf/yum utilities' view. This "difference of opinion" can lead to the dreaded:

    Warning: RPMDB altered outside of yum

    Error message.

    Ultimately, to work around this, I ended up needing to add a wait-loop to my userData payload. Basically, something like:

    while [[ $( pgrep -f "rpm -U" ) != "" ]]
     do
       echo "Another process is locking the RPM database"
       sleep 1
    done

    Before the dnf action that fails due to the unaccounted-for lock file.

  23. bjoernd commented on Nov 14, 2025

    @bjoernd

    The SSM team informed us that they addressed this issue in their 3.3.987.0 release.

  24. supergibbs commented on Feb 12, 2026

    @supergibbs

    @bjoernd I just tried removing the workaround and still getting the same error. Should this be reopened or is it definitely an issue for the SSM team and should be reported there?

  25. arstulke-btc commented on Jul 27, 2026

    @arstulke-btc

    I ran into this error multiple times today. My current AMI uses amazon-ssm-agent version 3.3.4624.0.

    With an initial sleep of 60 seconds and 5 retries (each spaced 60 seconds apart), I was able to boot the instance successfully. I just tested it and was able to start 20 instances without issues.

  26. bjoernd commented on Aug 10, 2026

    @bjoernd

    Reopening. This is certainly a problem on the SSM side, but we should keep this for visibiltiy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    aws-integrationbug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions