fix-partition-size #151

Merged
narenas merged 4 commits from fix-partition-size into main 2026-04-20 20:54:19 +02:00
Collaborator

Fix partition configuration, cache handling and hostname detection

Summary

  • Fixed ogFormatFs always reporting failure due to broken return value (integer 0 compared as False in Python)
  • Fixed ogMountFs crashing on stale symlinks left by former cache partitions
  • Fixed ogFormatCache always returning None on success, causing exit code 1
  • Fixed Configurar showing wrong exit code (1) when no formatting was requested
  • Fixed partition-to-cache conversion failing because existing partitions were not wiped before initCache
  • Fixed ogCheckNewCacheSize incorrectly blocking valid configurations when partitions are being redefined
  • Fixed race condition between partprobe and subsequent format commands by adding udevadm settle
  • Fixed ogGetHostname not resolving the hostname when neither HOSTNAME env var, DHCP leases nor hostname= kernel parameter are available — now extracts it from the ip= kernel parameter (field 5 in ip=client:server:gw:mask:hostname:iface:proto) and falls back to socket.gethostname()

Test plan

  • Create a disk with NTFS, Linux and cache partitions (ope=0): verify exit code 0
  • Create partitions with formatting (ope=1): verify exit code 0 and filesystems created correctly
  • Convert an existing NTFS partition to cache: verify old partition is wiped and cache is created
  • Convert an existing cache partition to Linux EXT4: verify cache is deleted and partition is formatted
  • Resize cache on a disk that also has other partitions: verify ogCheckNewCacheSize does not block the operation
  • Verify getConfiguration does not crash when a former cache partition is remounted as a regular partition
  • Boot a client via PXE and verify ogGetHostname returns the correct hostname from the ip= kernel parameter
Fix partition configuration, cache handling and hostname detection ## Summary - Fixed `ogFormatFs` always reporting failure due to broken return value (integer 0 compared as `False` in Python) - Fixed `ogMountFs` crashing on stale symlinks left by former cache partitions - Fixed `ogFormatCache` always returning `None` on success, causing exit code 1 - Fixed `Configurar` showing wrong exit code (1) when no formatting was requested - Fixed partition-to-cache conversion failing because existing partitions were not wiped before `initCache` - Fixed `ogCheckNewCacheSize` incorrectly blocking valid configurations when partitions are being redefined - Fixed race condition between `partprobe` and subsequent format commands by adding `udevadm settle` - Fixed `ogGetHostname` not resolving the hostname when neither `HOSTNAME` env var, DHCP leases nor `hostname=` kernel parameter are available — now extracts it from the `ip=` kernel parameter (field 5 in `ip=client:server:gw:mask:hostname:iface:proto`) and falls back to `socket.gethostname()` ## Test plan - [x] Create a disk with NTFS, Linux and cache partitions (`ope=0`): verify exit code 0 - [x] Create partitions with formatting (`ope=1`): verify exit code 0 and filesystems created correctly - [x] Convert an existing NTFS partition to cache: verify old partition is wiped and cache is created - [x] Convert an existing cache partition to Linux EXT4: verify cache is deleted and partition is formatted - [x] Resize cache on a disk that also has other partitions: verify `ogCheckNewCacheSize` does not block the operation - [x] Verify `getConfiguration` does not crash when a former cache partition is remounted as a regular partition - [x] Boot a client via PXE and verify `ogGetHostname` returns the correct hostname from the `ip=` kernel parameter
narenas added 4 commits 2026-04-20 20:29:52 +02:00
3720cb74d3 Fix multiple bugs in Configurar, ogFormatFs, ogMountFs and cache handling
Configurar:
- ogCheckNewCacheSize was called even when partitions were being
  redefined (tbp non-empty), incorrectly failing when existing
  partitions would have left enough space after repartitioning.
  Fixed by adding `and not tbp` to the condition.
- When only cache is configured (tbp empty), existing partitions
  were not wiped before initCache, causing ogCheckNewCacheSize to
  fail because the old partitions appeared to leave no room for
  the cache. Fixed by forcing recreate_partition_table=True when
  not tbp and is_there_cache.
- retval was initialised to integer 0 (falsy), causing the final
  log line to always show exit code 1 when no formatting was
  requested (ope=0). Fixed by initialising retval=True and
  normalising the display with `0 if retval else 1`.

DiskLib.ogCreatePartitions / ogUpdatePartitionTable:
- After partprobe, udev events were not yet processed before the
  next command ran, causing mkntfs (and similar) to fail
  immediately after partition creation in automated flows while
  working fine when run manually. Fixed by adding `udevadm settle`
  after each partprobe call.

FileSystemLib.ogFormatFs:
- Return value was changed to `0 if not errcode else errcode`
  (integer), breaking the script wrapper which uses `ret == True`
  / `ret == False` comparisons. In Python `0 == False` is True,
  so a successful format was reported as failure. Reverted to
  `return not errcode` (boolean).

FileSystemLib.ogMountFs:
- os.makedirs(mntdir, exist_ok=True) raised FileExistsError when
  mntdir existed as a broken symlink (e.g. a partition previously
  used as cache leaving a stale /mnt/sdcX -> /opt/opengnsys/cache
  symlink). Fixed by removing the stale symlink before makedirs.

CacheLib.ogFormatCache:
- Function returned None implicitly on success, causing the script
  wrapper to always exit with code 1 via `if ret is None: sys.exit(1)`.
  Fixed by adding `return True` at the end.
narenas merged commit 08c30fde56 into main 2026-04-20 20:54:19 +02:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: opengnsys/ogclone-engine#151
There is no content yet.