Skip to content

Instantly share code, notes, and snippets.

@nzwulfin
Forked from dustymabe/TestProjectAtomic.rst
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nzwulfin/14539a6c5b6b246c879e to your computer and use it in GitHub Desktop.
Save nzwulfin/14539a6c5b6b246c879e to your computer and use it in GitHub Desktop.

Test steps for atomic

Below are some steps to roughly test an atomic host from Project Atomic.

Booting with cloud-init

First step is to start an atomic host using any method/cloud provider you like. I use KVM on Fedora with a thin qcow2 disk attached for use with docker-storage-setup

#cloud-config password: atomic chpasswd: { expire: False } ssh_pwauth: True write_files: - path: /etc/sysconfig/docker-storage-setup content: | DEVS="/dev/vdb" ROOT_SIZE=4G - path: /etc/resolv.conf content: | search localdomain nameserver 192.168.122.1

Verifying docker-storage-setup

docker-storage-setup is a service that can be used to configure the storage configuration for docker in different ways on instance bringup. Notice in the user-data above that I decided to set config variables for docker-storage-setup. They basically mean that I want to resize my atomicos/root LV to 4G and I want to create an atomicos/docker-data LV use the complete additional drive.

To verify the storage was set up successfully, log in (as the fedora user) and become root (usind sudo su -). Now you can check if docker-storage-setup worked by checking the logs as well as looking at the output from lsblk:

# journalctl -o cat --unit docker-storage-setup.service
CHANGED: partition=2 start=411648 old: size=12171264 end=12582912 new: size=41531232,end=41942880
Physical volume "/dev/vda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
Size of logical volume atomicos/root changed from 1.95 GiB (500 extents) to 4.00 GiB (1024 extents).
Logical volume root successfully resized
Rounding up size to full physical extent 24.00 MiB
Logical volume "docker-meta" created
Logical volume "docker-data" created
#

-bash-4.3# lsblk

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sr0 11:0 1 366K 0 rom vda 252:0 0 6G 0 disk ├─vda1 252:1 0 300M 0 part /boot └─vda2 252:2 0 5.7G 0 part ├─atomicos-root 253:0 0 4G 0 lvm /sysroot ├─atomicos-docker--meta 253:1 0 24M 0 lvm │ └─docker-253:0-12592312-pool 253:3 0 17.3G 0 dm └─atomicos-docker--data 253:2 0 17.3G 0 lvm └─docker-253:0-12592312-pool 253:3 0 17.3G 0 dm vdb 252:16 0 16G 0 disk └─vdb1 252:17 0 16G 0 part

Verifying Docker Lifecycle

To verify Docker runs fine on the atomic host we will perform a simple run of the busybox docker image. This will contact the docker hub, pull down the image, and run /bin/true:

# docker run -it --rm busybox sleep 15 && echo "PASS" || echo "FAIL"
Unable to find image 'busybox' locally
Pulling repository busybox
e72ac664f4f0: Download complete 
511136ea3c5a: Download complete 
df7546f9f060: Download complete 
e433a6c5b276: Download complete 
PASS

After the Docker daemon has started the LVs that were created by docker-storage-setup will be used by device mapper as shown in the lsblk output below:

# lsblk
NAME                              MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
vda                               252:0    0   20G  0 disk 
├─vda1                            252:1    0  200M  0 part /boot
└─vda2                            252:2    0 19.8G  0 part 
  ├─atomicos-root                 253:0    0    4G  0 lvm  /sysroot
  ├─atomicos-docker--meta         253:1    0   24M  0 lvm  
  │ └─docker-253:0-6298462-pool   253:3    0   10G  0 dm   
  │   └─docker-253:0-6298462-base 253:4    0   10G  0 dm   
  └─atomicos-docker--data         253:2    0   10G  0 lvm  
    └─docker-253:0-6298462-pool   253:3    0   10G  0 dm   
      └─docker-253:0-6298462-base 253:4    0   10G  0 dm

Atomic Host: Upgrade

Now on to an atomic upgrade. First let's check what commit we are currently at and store a file in /etc/file1 to save it for us:

# atomic host status
  TIMESTAMP (UTC)         VERSION   ID             OSNAME            REFSPEC                                                
* 2015-04-15 12:50:37     22.39     a8d8656489     fedora-atomic     fedora-atomic:fedora-atomic/f22/x86_64/docker-host   

# ostree admin status
* fedora-atomic-host 1877f1fa64be8bec8adcd43de6bd4b5c39849ec7842c07a6d4c2c2033651cd84.0
    origin refspec: fedora-atomic:fedora-atomic/f21/x86_64/docker-host

# cat /ostree/repo/refs/heads/ostree/0/1/0
1877f1fa64be8bec8adcd43de6bd4b5c39849ec7842c07a6d4c2c2033651cd84

# cat /ostree/repo/refs/heads/ostree/0/1/0 > /etc/file1

Now run an upgrade to the latest atomic compose:

-bash-4.3# atomic host upgrade

Updating from: fedora-atomic:fedora-atomic/f22/x86_64/docker-host

825 metadata, 4940 content objects fetched; 224682 KiB transferred in 80 seconds Copying /etc changes: 25 modified, 0 removed, 44 added Transaction complete; bootconfig swap: yes deployment count change: 1 Changed: NetworkManager-1:1.0.0-9.fc22.x86_64 <SNIP> util-linux-2.26.2-1.fc22.x86_64 Added: cryptsetup-1.6.7-1.fc22.x86_64 <SNIP> udisks2-2.1.5-1.fc22.x86_64 Upgrade prepared for next boot; run "systemctl reboot" to start a reboot

And do a bit of poking around right before we reboot:

-bash-4.3# atomic host status

TIMESTAMP (UTC) VERSION ID OSNAME REFSPEC 2015-05-06 13:37:51 22.60 01c545be08 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host

  • 2015-04-15 12:50:37 22.39 a8d8656489 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host

    -bash-4.3# ostree admin status

    fedora-atomic 01c545be085d46cf423f1db23a21807662b47b4faf77e083dba89cb0577ff79a.0

    Version: 22.60 origin refspec: fedora-atomic:fedora-atomic/f22/x86_64/docker-host

  • fedora-atomic a8d86564895cc7d223a8a10e1d58a266c68c98337ad76fc68755c4a7040cdc79.0

    Version: 22.39 origin refspec: fedora-atomic:fedora-atomic/f22/x86_64/docker-host

    -bash-4.3# systemctl reboot

Note

The * in the above output indicates which tree is currently booted.

After reboot now the new tree should be booted. Let's check things out and make /etc/file2 with our new commit hash in it:

-bash-4.3# atomic host status

TIMESTAMP (UTC) VERSION ID OSNAME REFSPEC

  • 2015-05-06 13:37:51 22.60 01c545be08 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host 2015-04-15 12:50:37 22.39 a8d8656489 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host

-bash-4.3# ostree admin status * fedora-atomic 01c545be085d46cf423f1db23a21807662b47b4faf77e083dba89cb0577ff79a.0 Version: 22.60 origin refspec: fedora-atomic:fedora-atomic/f22/x86_64/docker-host fedora-atomic a8d86564895cc7d223a8a10e1d58a266c68c98337ad76fc68755c4a7040cdc79.0 Version: 22.39 origin refspec: fedora-atomic:fedora-atomic/f22/x86_64/docker-host

-bash-4.3# cat /ostree/repo/refs/heads/ostree/1/1/0 01c545be085d46cf423f1db23a21807662b47b4faf77e083dba89cb0577ff79a -bash-4.3# cat /ostree/repo/refs/heads/ostree/1/1/0 > /etc/file2

As one final item let's boot up a docker container to make sure things still work there:

-bash-4.3# docker run -it --rm busybox sleep 15 && echo "PASS" || echo "FAIL"

PASS

Atomic Host: Rollback --------------------

Atomic host provides the ability to revert to the previous working tree if things go awry with the new tree. Lets revert our upgrade now and make sure things still work:

-bash-4.3# atomic host rollback

Moving 'a8d86564895cc7d223a8a10e1d58a266c68c98337ad76fc68755c4a7040cdc79.0' to be first deployment Transaction complete; bootconfig swap: yes deployment count change: 0 Changed: NetworkManager-1:1.0.0-8.fc22.x86_64 <SNIP> util-linux-2.26.1-1.fc22.x86_64 Removed: cryptsetup-1.6.7-1.fc22.x86_64 <SNIP> udisks2-2.1.5-1.fc22.x86_64 Sucessfully reset deployment order; run "systemctl reboot" to start a reboot

-bash-4.3# atomic host status

TIMESTAMP (UTC) VERSION ID OSNAME REFSPEC 2015-04-15 12:50:37 22.39 a8d8656489 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host

  • 2015-05-06 13:37:51 22.60 01c545be08 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host

-bash-4.3# systemctl reboot

After reboot:

-bash-4.3# atomic host status

TIMESTAMP (UTC) VERSION ID OSNAME REFSPEC

  • 2015-04-15 12:50:37 22.39 a8d8656489 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host 2015-05-06 13:37:51 22.60 01c545be08 fedora-atomic fedora-atomic:fedora-atomic/f22/x86_64/docker-host

-bash-4.3# cat /etc/file1 a8d86564895cc7d223a8a10e1d58a266c68c98337ad76fc68755c4a7040cdc79 -bash-4.3# cat /etc/file2 cat: /etc/file2: No such file or directory

Notice that /etc/file2 did not exist until after the upgrade so it did not persist during the rollback.

And the final item on the list is to make sure Docker still works:

# docker run -it --rm busybox sleep 15 && echo "PASS" || echo "FAIL"
PASS

Anddd Boom.. You have just put atomic through some paces.

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