Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ISO location logic in 99_migration #304

Merged
merged 13 commits into from
Nov 8, 2024
Merged

Conversation

doccaz
Copy link
Contributor

@doccaz doccaz commented Nov 1, 2024

I noticed that you have a Kiwi appliance to test DMS on your OBS home directory. I branched it and made an LVM version with 4 volumes to test DMS. I then noticed that 99_migration is not finding the ISO file on an LVM root volume and not writing the corresponding entry to GRUB.

I added a test to check if the ISO is found, and only search on the user paths if not found, This commit solves the issue.

The KIWI appliance is located here: https://build.opensuse.org/package/show/home:emendonca:branches:home:marcus.schaefer:dms/suse-migration-test-vm-lvm

The line where I substituted an "echo" by an "ls -1 | tail -1" is just for a situation I found when testing multiple versions of the packages and it ended up returning an invalid value when there's more than one ISO in the directory.

@rjschwei rjschwei requested a review from schaefi November 1, 2024 19:47
@schaefi
Copy link
Collaborator

schaefi commented Nov 2, 2024

@doccaz Thanks for looking into this.

With regards to #277 we moved the install location of the live ISO from /usr/share/migration-image to /migration-image. This move impacts the 99_migration code as you already found out. Because of this reason the two packages SLES15-Migration (which packages the live ISO into a package) and the package suse-migration-sle15-activation must be in sync. I updated the activation package in my :dms build later because I also stumbled over the issue you had. Therefore I assume when you branched my project you still got the not-in-sync package state. If you check it again it should be in sync and my tests worked.

I don't think we should add the complexity of two different search methods in the 99_migration code. Instead I suggest that
we bump the version of the SLES15-Migration package and add a proper Requires: SLES15-Migration >= "..." to the spec file of the suse-migration-sle15-activation package

@schaefi
Copy link
Collaborator

schaefi commented Nov 2, 2024

The line where I substituted an "echo" by an "ls -1 | tail -1" is just for a situation I found when testing multiple versions of the packages and it ended up returning an invalid value when there's more than one ISO in the directory.

I agree with you that the echo code is weak. However, always using the first entry found might lead to unexpected behavior too. I was thinking under which condition you got the situation that there is more than one image available and differently named ?
In any case, covering this issue should be an extra PR.

Copy link
Collaborator

@schaefi schaefi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into this. Good catch and we need to fix this but I propose a different direction. Thoughts ?

@doccaz
Copy link
Contributor Author

doccaz commented Nov 5, 2024

The line where I substituted an "echo" by an "ls -1 | tail -1" is just for a situation I found when testing multiple versions of the packages and it ended up returning an invalid value when there's more than one ISO in the directory.

I agree with you that the echo code is weak. However, always using the first entry found might lead to unexpected behavior too. I was thinking under which condition you got the situation that there is more than one image available and differently named ? In any case, covering this issue should be an extra PR.

I agree with you on this one. This was actually a problem caused by me during testing, there's no need to address it in this PR.

@doccaz
Copy link
Contributor Author

doccaz commented Nov 5, 2024

@doccaz Thanks for looking into this.

With regards to #277 we moved the install location of the live ISO from /usr/share/migration-image to /migration-image. This move impacts the 99_migration code as you already found out. Because of this reason the two packages SLES15-Migration (which packages the live ISO into a package) and the package suse-migration-sle15-activation must be in sync. I updated the activation package in my :dms build later because I also stumbled over the issue you had. Therefore I assume when you branched my project you still got the not-in-sync package state. If you check it again it should be in sync and my tests worked.

I only branched "suse-migration-test-vm" to add an LVM partition layout (see here). The rest of the packages are being pulled from your repository automatically through KIWI. I also added SUSEConnect and a couple missing python dependencies to appliance.kiwi.

Here are the included versions in the qcow2 image:

  • SLES15-Migration-2.0.40-1
  • suse-migration-pre-checks-2.1.1-1
  • suse-migration-2.1.1-1.1

I booted the qcow2 image and manually added the .repo file pointing to your repository. Finally, I installed suse-sle15-activation-2.1.1-1.1. I can see that the generated grub.cfg after the grub2-mkconfig is called has a blank 99_migration section.

My image has a VG called "vg_system" with 4 LVM volumes:

linux:~ # lvs
  LV     VG        Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  LVRoot vg_system -wi-ao---- 2,00g                                                    
  lv_opt vg_system -wi-ao---- 1,00g                                                    
  lv_usr vg_system -wi-ao---- 5,00g                                                    
  lv_var vg_system -wi-ao---- 5,00g  

If I run the script manually with sh -x, I see this:

+ '[' -z '' ']'
+ OS=Migration
++ echo /migration-image/SLES15-Migration.x86_64-2.0.40-Build1.8.iso
+ migration_iso=/migration-image/SLES15-Migration.x86_64-2.0.40-Build1.8.iso
++ grep -E '/$'
++ lsblk -p -n -r -o NAME,MOUNTPOINT
++ uniq
++ cut -f1 '-d '
+ root_device=/dev/mapper/vg_system-LVRoot
+ image_fs_device=/dev/mapper/vg_system-LVRoot
+ index=4
+ for path in '"/usr/share"' '"/usr"'
+ mountpoint -q /usr/share
+ index=3
+ for path in '"/usr/share"' '"/usr"'
+ mountpoint -q /usr
++ lsblk -p -n -r -o NAME,MOUNTPOINT
++ grep -E '/usr$'
++ cut -f1 '-d '
++ uniq
+ image_fs_device=/dev/mapper/vg_system-lv_usr
++ echo /migration-image/SLES15-Migration.x86_64-2.0.40-Build1.8.iso
++ cut -f3- -d/
+ migration_iso=/SLES15-Migration.x86_64-2.0.40-Build1.8.iso
+ break
++ blkid -s UUID -o value /dev/mapper/vg_system-lv_usr
+ image_fs_uuid=a992a0f9-2d23-4ef4-b3c1-2b25c8604ac9
++ blkid -s TYPE -o value /dev/mapper/vg_system-lv_usr
+ image_fs_type=ext3

The migration_iso variable starts with the correct value (/migration-image/SLES15-Migraiton*.iso), then it gets overwritten inside the for loop, because there IS an active volume for /usr but it DOES NOT contain the iso. In the end the wrong value gets assigned (/SLES15-Migration*.iso). That's why I suggested the extra file check.

I don't think we should add the complexity of two different search methods in the 99_migration code. Instead I suggest that we bump the version of the SLES15-Migration package and add a proper Requires: SLES15-Migration >= "..." to the spec file of the suse-migration-sle15-activation package

That's a valid way of using the correct version, I agree.

@schaefi
Copy link
Collaborator

schaefi commented Nov 5, 2024

@doccaz Oh now I see it. Thanks much for the trace output. Actually as we have now moved the location of the ISO to "/" instead of "/usr/share" the following code in 99_migration can be imho dropped because /migration-image will always be on the root device. Thus I suggest to drop

# check if location of migration_iso is not on the root_device
image_fs_device=${root_device}
index=4
for path in "/usr/share" "/usr";do
    if mountpoint -q ${path};then
        image_fs_device=$(
            lsblk -p -n -r -o NAME,MOUNTPOINT |\
            grep -E "${path}$" | uniq | cut -f1 -d" "
        )
        migration_iso=/$(echo "${migration_iso}" | cut -f"${index}"- -d/)
        break
    fi
    index=$((index -1))
done

completely

Thoughts ?

@schaefi
Copy link
Collaborator

schaefi commented Nov 6, 2024

@doccaz That's a valid way of using the correct version, I agree.

I provided #305 to address this part

grub.d/99_migration Outdated Show resolved Hide resolved
Copy link
Contributor Author

@doccaz doccaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go.

grub.d/99_migration Outdated Show resolved Hide resolved
@@ -14,7 +14,7 @@ else
) ${CLASS}"
fi

migration_iso=$(echo /*-Migration.*.iso)
migration_iso=$(echo /migration-image/*-Migration.*.iso)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you go.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doccaz Great thanks 👍 it looks good to me now, can you squash your commits into one ? then we are ready for merge. Thanks much

@schaefi
Copy link
Collaborator

schaefi commented Nov 7, 2024

@doccaz maybe if you have a minute, can you do me a favor and check #305 if it makes sense to you. Thanks again

schaefi and others added 9 commits November 7, 2024 16:47
Add information how to test the DMS
The current DMS workflow is based on a reboot either through
kexec or grub(loopsetup). The reboot is required to meet the
documented requirement for an offline upgrade process which
is the only supported process to upgrade from SLE12 to SLE15.
However this limitation is not a technology limitation, it
was based on product management decisions back in time.
From todays perspective it is possible to run a seamless
online upgrade from SLE12 to SLE15 using container technology.
This commit implements support for it in the DMS and provides the
required technology stack at:

https://build.opensuse.org/project/show/home:marcus.schaefer:dms

I'm aware that this container based workflow can only serve
as an additional/experimental workflow without guarantees to the
user as it would violate a PM decision. However, I also believe
that we have to provide good solutions when they solve a
number of severe issues that exists with the current DMS
reboot workflow. Along with this implementation I also prepared
a presentation to show and demo the workflow. Maybe this gains
some interest in the future and can help to start a PM
conversation about the SLE12 upgrade process.

In any way I'd like to add this additional workflow to the DMS
such that our users have a chance to upgrade when the reboot
way fails. If customers would consider it, it must be clear
to them that they are on unsupported territory. This information
must be placed to the documentation prior merge
The suse-migration-rpm package contains an OBS hook
script which turns the migration live ISO image into
a package named according to the name of the image
name attribute. In our case: SLES15-Migration. The
sources of this package was not maintained in any
git repository but are tightly coupled to the live
image build which resides here. Thus and to complete
the source gap we have for the DMS this commit adds
the sources for the meta package here
This change helps to run migrations on systems which stores
/usr/share in a special way, e.g. as LVM volume or other
type that cannot be read via the loopback grub or kexec
method. This Fixes SUSE#277
If the DMS live ISO loopback boot runs on a machine
that has root (/) on LVM we need to load lvm in grub
to be able to read from the root of the toplevel
volume
@doccaz doccaz requested a review from schaefi November 7, 2024 20:04
@doccaz
Copy link
Contributor Author

doccaz commented Nov 7, 2024

@doccaz maybe if you have a minute, can you do me a favor and check #305 if it makes sense to you. Thanks again

Yes, that makes sense and would avoid using the wrong image.

@schaefi schaefi merged commit ab58541 into SUSE:master Nov 8, 2024
@schaefi
Copy link
Collaborator

schaefi commented Nov 8, 2024

@doccaz I have merged your and my PR and submitted the changes to:

I'm running some tests once everything as built. So far there are no release plans for the DMS to the SUSE namespace. I plan a refresh during the next three months or on demand if there is a prio bug coming up.

@doccaz doccaz deleted the fix-iso-path branch November 8, 2024 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants