clearlinux / micro-config-drive

An alternative and small cloud-init implementation in C
Other
46 stars 17 forks source link

UCD does not resize Clear Linux root partition when installed on baremetal using OpenStack Ironic with a ConfigDrive #34

Closed mdreyesm closed 5 years ago

mdreyesm commented 5 years ago

When deploying Clear Linux on baremetal using OpenStack Ironic, the root partition does not resize dynamically according to the HD size like in VM deployments. When using ConfigDrive, it is written at the end of the Hard Drive as a 64M partition, apparently this causes conflict with the resizing operation. When no ConfigDrive is used, the resize operation is executed successfully.

Steps to reproduce:

- Build the Clear Linux cloud image with kernel-native instead of kernel-kvm https://github.com/bryteise/ister/blob/master/cloud-config.json 
- Deploy the image with OpenStack Ironic using ConfigDrive https://docs.openstack.org/ironic/latest/install/configdrive.html

Once Clear Linux is deployed, the root partition has the same size as declared in ister, in this case 800M.


root@localhost /home/clear # fdisk -l
Disk /dev/sda: 3.7 TiB, 4000225165312 bytes, 7812939776 sectors
Disk model: PERC H730P Mini 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 1048576 bytes
Disklabel type: gpt

Device          Start        End Sectors  Size Type
/dev/sda1        2048    1048575 1046528  511M EFI System
/dev/sda2     1048576    2686975 1638400  800M Linux root (x86-64)
/dev/sda3  7812806656 7812939742  133087   65M Linux filesystem
devimc commented 5 years ago

I'd like to see the logs, please run following command

$ journalctl -b -u ucd
ahkok commented 5 years ago

Ah, thanks for filing this issue here as well.

Root cause is that parted doesn't support this, it can auto resize partitions, but not partition tables.

mdreyesm commented 5 years ago

The output of journalctl is the following:

root@localhost /home/clear # journalctl -b -u ucd
-- Logs begin at Tue 2019-03-26 23:34:32 UTC, end at Tue 2019-03-26 23:35:10 UTC. --
Mar 26 23:34:32 clr-f1deea13f28749e9b89f9c375dad9123 systemd[1]: Starting micro-config-drive job...
Mar 26 23:34:32 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [5.619517] micro-config-drive version: 35
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [6.665950] openstack: Saving instance id '83679162-1378-4288-a2d4-70e13ec132aa'
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [6.666148] lib: First boot: True
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [6.666322] lib: Executing: /bin/sh -c "/usr/bin/usermod -p '!' root"
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [6.666393] Checking disk /dev/sda
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [6.907369] disk: Nothing to do with '/dev/sda' disk
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 usermod[1187]: change user 'root' password
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.064325] lib: STD output:
Mar 26 23:34:33 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.064926] lib: Executing: /bin/sh -c "/usr/bin/useradd -U -d '/home/clear' -G 'wheel' -f '-1' -e '' -s '/bin/bash' -c 'Clear Linux' -p '!' 'clear'"
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 useradd[1357]: new group: name=clear, GID=1000
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 useradd[1357]: new user: name=clear, UID=1000, GID=1000, home=/home/clear, shell=/bin/bash
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 useradd[1357]: add 'clear' to group 'wheel'
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.517740] lib: STD output:
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518070] openstack: Metadata using 'availability_zone' handler
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518097] openstack: Metadata using 'files' handler
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518110] openstack: Metadata using 'hostname' handler
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518130] openstack: Metadata using 'launch_index' handler
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518142] openstack: Metadata using 'name' handler
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518194] openstack: Metadata 'availability_zone' not implemented yet
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518215] [7.518224] openstack: files nothing to do with (null)
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: openstack: Metadata using 'meta' handler
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518253] [7.518270] openstack: Metadata 'launch_index' not implemented yet
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: lib: First boot: True
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518282] [7.518330] openstack: Metadata 'name' not implemented yet
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: lib: Executing: /bin/sh -c "/usr/bin/hostnamectl set-hostname 'auto-instance'"
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518291] openstack: Metadata using 'public_keys' handler
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518307] openstack: Metadata 'meta' not implemented yet
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518393] openstack: public keys processing (null)
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.518400] openstack: Adding key "pub_key"
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.520266] openstack: files nothing to do with (null)
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.520366] lib: Unable to open destination file '/etc/resolv.conf'
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.520386] openstack: Copy file '/var/lib/cloud/config-2-RdlBYe/openstack//content/0001' failed
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.520392] openstack: files nothing to do with (null)
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.520394] userdata: Looking for shebang file /var/lib/cloud/userdata-e8LCuX
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.520569] userdata: Shebang found #!/bin/bash
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.520622] lib: Executing: /bin/sh -c "/var/lib/cloud/userdata-e8LCuX"
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.522563] openstack: Adding key "pub_key2"
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 sudo[1381]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/chmod 755 -R /etc/systemd/
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 sudo[1381]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 sudo[1381]: pam_unix(sudo:session): session closed for user root
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 sudo[1390]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/echo -e export http_proxy=http://proxy.domain.com\ne
xport https_proxy=http://proxy.domain.com\n
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 sudo[1390]: pam_unix(sudo:session): session opened for user root by (uid=0)
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 sudo[1390]: pam_unix(sudo:session): session closed for user root
Mar 26 23:34:34 clr-f1deea13f28749e9b89f9c375dad9123 ucd[994]: [7.803150] lib: STD output:
Mar 26 23:34:34 auto-instance ucd[994]: [7.927931] lib: STD output:
Mar 26 23:34:34 auto-instance systemd[1]: Started micro-config-drive job.
root@localhost /home/clear # 
gorozco1 commented 5 years ago

@ahkok

root@icore5:~# parted /dev/sdb
GNU Parted 3.2
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) p                                                                
Model: ADATA USB Flash Drive (scsi)
Disk /dev/sdb: 8076MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  578MB   577MB   primary               esp
 2      578MB   839MB   261MB   primary
 3      8000MB  8076MB  76.5MB  primary

---
root@icore5:~# fdisk /dev/sdb -l
Disk /dev/sdb: 7.5 GiB, 8076132352 bytes, 15773696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9a7475cc

Device     Boot    Start      End Sectors  Size Id Type
/dev/sdb1           2048  1128447 1126400  550M ef EFI (FAT-12/16/32)
/dev/sdb2        1128448  1638399  509952  249M 83 Linux
/dev/sdb3       15624192 15773695  149504   73M 83 Linux

root@icore5:~# parted /dev/sdb
(parted) resizepart 2 7999MB
(parted) p                                                                
Model: ADATA USB Flash Drive (scsi)
Disk /dev/sdb: 8076MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags: 

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  578MB   577MB   primary               esp
 2      578MB   7999MB  7421MB  primary
 3      8000MB  8076MB  76.5MB  primary

root@icore5:~# fdisk -l /dev/sdb
Disk /dev/sdb: 7.5 GiB, 8076132352 bytes, 15773696 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x9a7475cc

Device     Boot    Start      End  Sectors  Size Id Type
/dev/sdb1           2048  1128447  1126400  550M ef EFI (FAT-12/16/32)
/dev/sdb2        1128448 15623046 14494599  6.9G 83 Linux
/dev/sdb3       15624192 15773695   149504   73M 83 Linux

This is of course an approximation the ideally state is that partition Number 2 Ends at 15624191 and not 15623046

devimc commented 5 years ago

@mdreyesm @gorozco1 I can confirm that it is a bug in ucd, cloud-init resizes the rootfs automatically. @mdreyesm as a temporal workaround can you resize it manually using cloud-config ?

devimc commented 5 years ago

@ahkok I have a fix in mind, I'd like to take this issue

mdreyesm commented 5 years ago

I will be testing the patch, thanks!.