Skip to content

Conversation

@allanrogerr
Copy link
Contributor

@allanrogerr allanrogerr commented Oct 14, 2025

Description

This PR adds .old file normalization to handle cases where os.Executable() returns a path ending with .old after a previous update on some systems.

  • Implements normalizeExecutablePath() function to strip .old suffix and leading dots from base filenames
  • Modifies getPath() to normalize executable paths before use
  • Adds comprehensive unit tests covering various path scenarios

Motivation and Context

After a self-update operation, some systems may report the current executable path with a .old extension (e.g., /path/to/.minio.old). This can cause issues when the updater
tries to determine the target path for the next update.

The implementation addresses:

  1. Strip .old suffix - Removes .old extension from executable paths (lines 244-246)
  2. Remove leading dots - Handles hidden files like .minio.oldminio (lines 248-250)
  3. Preserve normal paths - Unchanged behavior for paths without .old extension (lines 254)
  4. Cross-platform support - Works with Unix and Windows-style paths (lines 244-254)

The normalization handles:

  1. Normal paths remain unchanged (lines 258-261 in test)
  2. Paths with .old suffix are normalized (lines 262-265)
  3. Hidden files with .old are normalized (lines 266-269, 270-273)
  4. Simple filenames with .old (lines 274-281)
  5. Complex paths preserved (lines 282-285)
  6. Windows-style paths supported (lines 286-289)

How to test this PR?

Run the test suite:

go test -v -run TestNormalizeExecutablePath

See other tests downstream in eos here: https://github.com/miniohq/eos/actions/runs/18663370987/job/53209192041
The failures are unrelated and are being discussed with @vadmeste in https://github.com/miniohq/eos/issues/1956

Types of changes

[x] Bug fix (non-breaking change which fixes an issue)
[ ] New feature (non-breaking change which adds functionality)
[ ] Optimization (provides speedup with no functional changes)
[ ] Cleanup/Maintenance (no functional changes)
[ ] Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

[ ] Fixes a regression (If yes, please add commit-id or PR # here)
[x] Unit tests added/updated
[ ] Internal documentation updated
[ ] Create a documentation update request

@allanrogerr allanrogerr self-assigned this Oct 14, 2025
@allanrogerr allanrogerr added the bug Something isn't working label Oct 14, 2025
@allanrogerr allanrogerr marked this pull request as ready for review October 20, 2025 22:34
@harshavardhana
Copy link
Member

@ramondeklein this fixes the odd issues that we have seen during Operator drive minio upgrades.

@harshavardhana harshavardhana merged commit 51020f5 into minio:master Oct 21, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants