SUSE / suse-migration-services

GNU General Public License v3.0
7 stars 11 forks source link

Enable prechecks as a systemd process #247

Closed KeithMnemonic closed 2 years ago

KeithMnemonic commented 2 years ago

This PR completes the updated implementation of suse-migration-pre-checks. A new suse-migration-run-pre-checks-service has been added that will be started right after the instance is rebooted to the migration image and the filesystem is mounted at /system-root. This service will use the --fix option as the default behavior when the suse-migration-run-pre-checks-service is started. A new option config has been added to allow this to be turned off. In that mode, the pre-checks are still run but without the --fix fix option.

KeithMnemonic commented 2 years ago

Tested iso and see the following results:

Message when installing SLES15-Migration:

Running suse-migration-pre-checks with options: fix: False and live: False
Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/aeff9ddd-df2c-4fae-b717-b5fed9622aea']
Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/1aef0f3b-e5f7-407c-b48c-68971164614b']
Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/cloud/azure_resource-part1']
Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/0DFD-1C1E']
The config option 'multiversion' in /etc/zypp/zypp.conf includes the keyword 'kernel.' The current value is set as
'multiversion = provides:multiversion(kernel)'.
Checking the config option 'multiversion.kernels' to see if multiple kernels are also enabled
The config option multiversion.kernels is not set correctly in /etc/zypp/zypp.conf. It is currrently set as:
'multiversion.kernels = latest,latest-1,running'.
Please ensure it is set as:
'multiversion.kernels = latest,running'
Calling: ['rpm', '-qa', 'kernel-default']
Multiple kernels have been detected on the system:
kernel-default-4.12.14-122.121.2.x86_64
kernel-default-4.12.14-122.106.1.x86_64
Please remove all kernels other than the currrent running kernel: vmlinuz-4.12.14-122.121-default

Message during migration:

Running suse-migration-pre-checks with options: fix: True and live: True
Device path /dev/disk/cloud/azure_resource-part1 not found and skipped
Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/aeff9ddd-df2c-4fae-b717-b5fed9622aea']
Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/1aef0f3b-e5f7-407c-b48c-68971164614b']
Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/0DFD-1C1E']
The config option 'multiversion' in /etc/zypp/zypp.conf includes the keyword 'kernel.' The current value is set as
'multiversion = provides:multiversion(kernel)'.
Checking the config option 'multiversion.kernels' to see if multiple kernels are also enabled
The '--fix' option was provided, setting 'multiversion.kernels = latest,running'
Calling: ['sed', '-i', 's/multiversion.kernels = latest,latest-1,running/multiversion.kernels = latest,running/', '/etc/zypp/zypp.conf']
Calling: ['chroot', '/system-root', 'rpm', '-qa', 'kernel-default']
Multiple kernels have been detected on the system:
kernel-default-4.12.14-122.121.2.x86_64
kernel-default-4.12.14-122.106.1.x86_64
The '--fix' option was provided, removing old kernels
Removing: kernel-default-4.12.14-122.106.1.x86_64

and from systemd

migration@localhost:~> systemctl status suse-migration-pre-checks.service
● suse-migration-pre-checks.service - Run suse-migration-pre-checks before starting the migration
   Loaded: loaded (/usr/lib/systemd/system/suse-migration-pre-checks.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Fri 2022-05-27 01:09:19 UTC; 5min ago
  Process: 1175 ExecStart=/usr/bin/suse-migration-pre-checks --fix --live (code=exited, status=0/SUCCESS)
 Main PID: 1175 (code=exited, status=0/SUCCESS)

migration@localhost:~> sudo journalctl -u suse-migration-pre-checks.service
-- Logs begin at Fri 2022-05-27 01:09:02 UTC, end at Fri 2022-05-27 01:14:44 UTC. --
May 27 01:09:16 localhost systemd[1]: Starting Run suse-migration-pre-checks before starting the migration...
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Running suse-migration-pre-checks with options: fix: True and live: True
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Device path /dev/disk/cloud/azure_resource-part1 not found and skipped
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/aeff9ddd-df2c-4fae-b717-b5fed96>
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/1aef0f3b-e5f7-407c-b48c-6897116>
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Calling: ['blkid', '-s', 'TYPE', '-o', 'value', '/dev/disk/by-uuid/0DFD-1C1E']
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: The config option 'multiversion' in /etc/zypp/zypp.conf includes the keyword 'kernel.' The current>
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: 'multiversion = provides:multiversion(kernel)'.
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Checking the config option 'multiversion.kernels' to see if multiple kernels are also enabled
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: The '--fix' option was provided, setting 'multiversion.kernels = latest,running'
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Calling: ['sed', '-i', 's/multiversion.kernels = latest,latest-1,running/multiversion.kernels = la>
May 27 01:09:16 localhost suse-migration-pre-checks[1175]: Calling: ['chroot', '/system-root', 'rpm', '-qa', 'kernel-default']
May 27 01:09:17 localhost suse-migration-pre-checks[1175]: Multiple kernels have been detected on the system:
May 27 01:09:17 localhost suse-migration-pre-checks[1175]: kernel-default-4.12.14-122.121.2.x86_64
May 27 01:09:17 localhost suse-migration-pre-checks[1175]: kernel-default-4.12.14-122.106.1.x86_64
May 27 01:09:17 localhost suse-migration-pre-checks[1175]: The '--fix' option was provided, removing old kernels
May 27 01:09:17 localhost suse-migration-pre-checks[1175]: Removing: kernel-default-4.12.14-122.106.1.x86_64
May 27 01:09:17 localhost suse-migration-pre-checks[1175]: Calling: ['chroot', '/system-root', 'rpm', '-e', 'kernel-default-4.12.14-122.106.1.x86_64']
May 27 01:09:19 localhost systemd[1]: Started Run suse-migration-pre-checks before starting the migration.
KeithMnemonic commented 2 years ago

LGTM. I suggest s/live/migration_system/ g or something similarly more explicit.

@rjschwei for the message

        log.info("Using live mode")

or somewhere else?

rjschwei commented 2 years ago

LGTM. I suggest s/live/migration_system/ g or something similarly more explicit.

@rjschwei for the message

        log.info("Using live mode")

or somewhere else?

I would do the substitution everywhere. Meaning arguments that are currently named live would be migration_system (or similar descriptive name). The variable name live within the context of the code has very limited meaning and expects the code reader to know that this code is built into a "live-iso".

KeithMnemonic commented 2 years ago

LGTM. I suggest s/live/migration_system/ g or something similarly more explicit.

@rjschwei for the message

        log.info("Using live mode")

or somewhere else?

I would do the substitution everywhere. Meaning arguments that are currently named live would be migration_system (or similar descriptive name). The variable name live within the context of the code has very limited meaning and expects the code reader to know that this code is built into a "live-iso".

Done @rjschwei please re-review and merge if ready

rjschwei commented 2 years ago

LGTM