Skip to content

Disable self-upgrade and version check for packaged installation#887

Open
gvnnn wants to merge 2 commits into
openshift:masterfrom
gvnnn:SREP-4835
Open

Disable self-upgrade and version check for packaged installation#887
gvnnn wants to merge 2 commits into
openshift:masterfrom
gvnnn:SREP-4835

Conversation

@gvnnn
Copy link
Copy Markdown
Contributor

@gvnnn gvnnn commented May 11, 2026

When osdctl is installed via COPR or Homebrew, the self-upgrade command would overwrite a file owned by the package manager and the version-check nag is unhelpful. This adds a build-time InstallMethod variable (set via ldflags) that disables both behaviors and directs users to their package manager instead.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 11, 2026

Walkthrough

Managed install detection is added to osdctl. A new InstallMethod variable tracks the installation method (set via build-time ldflags), with helper functions to detect managed installs and provide upgrade commands. Version checks and self-upgrades are skipped or refused for managed installations, and version output includes the install method. Build scripts are updated to set the install method during RPM builds.

Changes

Managed Install Detection and Handling

Layer / File(s) Summary
Data Model & Utilities
pkg/utils/version.go
New exported InstallMethod variable captures installation method (set at build time). IsManagedInstall() returns true if method is non-empty. UpgradeInstruction() returns platform-specific upgrade commands for copr and homebrew, empty otherwise.
Utility Tests
pkg/utils/version_test.go
TestIsManagedInstall validates true for copr/homebrew, false for empty. TestUpgradeInstruction validates correct command strings per install method and empty string for unknown methods.
Build Configuration
hack/copr.sh, hack/osdctl.spec
Go linker flags now set both utils.Version and utils.InstallMethod=copr at build time for RPM packages.
Version Check Skip Logic
cmd/cmd.go
shouldRunVersionCheck additionally skips version check when utils.IsManagedInstall() is true, alongside existing flag and command allowlist logic.
Upgrade Refusal Logic
cmd/upgrade.go
upgrade() performs early check for managed installs via utils.IsManagedInstall(). If managed, prints disable message with upgrade instruction from utils.UpgradeInstruction() and returns without contacting GitHub or downloading binary.
Upgrade Tests
cmd/upgrade_test.go
TestUpgradeRefusesWhenManaged iterates table-driven cases for copr and homebrew, overrides utils.InstallMethod, captures stderr, asserts upgrade() returns nil, and verifies output contains both install method and expected upgrade command.
Version Output
cmd/version.go
versionResponse struct adds InstallMethod field with JSON tag install_method,omitempty. Field is populated from utils.InstallMethod when marshaling version output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 11 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (11 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Stable And Deterministic Test Names ✅ Passed PR adds only standard Go tests using testing.T, not Ginkgo tests. The custom check for Ginkgo test stability is not applicable. All test names are static and deterministic.
Test Structure And Quality ✅ Passed The custom check applies to Ginkgo test code. The PR adds tests using standard Go testing, not Ginkgo. Tests follow good patterns with proper setup/cleanup and meaningful assertions.
Microshift Test Compatibility ✅ Passed This PR does not add any Ginkgo e2e tests. The new tests are standard Go unit tests using the testing package, not Ginkgo framework tests. The check is not applicable.
Single Node Openshift (Sno) Test Compatibility ✅ Passed This PR adds only standard Go unit tests, not Ginkgo e2e tests. The custom check applies only to Ginkgo e2e tests, making it not applicable to this PR.
Topology-Aware Scheduling Compatibility ✅ Passed PR modifies osdctl CLI tool only. No Kubernetes manifests, operators, or controllers are changed. No scheduling constraints introduced. Check not applicable.
Ote Binary Stdout Contract ✅ Passed No OTE Binary Stdout Contract violations detected. All process-level code avoids stdout. Uses cmd.ErrOrStderr() for errors, JSON output intentional for version subcommand.
Ipv6 And Disconnected Network Test Compatibility ✅ Passed No Ginkgo e2e tests were added in this PR. The new tests are standard Go unit tests for the osdctl CLI tool, not Kubernetes/OpenShift e2e tests. The IPv6/disconnected network check is not applicable.
Title check ✅ Passed The title accurately summarizes the main objectives of the pull request: disabling self-upgrade and version check for packaged installations. It is concise, specific, and directly related to the primary changes across all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@openshift-ci openshift-ci Bot requested review from Makdaam and clcollins May 11, 2026 09:58
@openshift-ci openshift-ci Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 11, 2026
When osdctl is installed via COPR or Homebrew, the self-upgrade command
would overwrite a file owned by the package manager and the version-check
nag is unhelpful. This adds a build-time InstallMethod variable (set via
ldflags) that disables both behaviors and directs users to their package
manager instead.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@cmd/upgrade.go`:
- Around line 29-33: When utils.IsManagedInstall() is true, the current message
may print an empty command if utils.UpgradeInstruction() returns an
unmapped/non-empty InstallMethod but no instruction; update the branch around
utils.IsManagedInstall() so you compute a non-empty fallback before formatting:
call utils.UpgradeInstruction(), and if it returns an empty string, set a
fallback string that uses utils.InstallMethod (e.g., "use your system package
manager or contact your administrator for upgrade instructions for
<InstallMethod>") and then pass that fallback into fmt.Fprintf so the user never
sees an empty upgrade instruction; adjust the code that currently references
utils.InstallMethod and utils.UpgradeInstruction() accordingly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: bb223b60-1a67-4d0f-af45-de88075fe7ed

📥 Commits

Reviewing files that changed from the base of the PR and between 393bd82 and a2b5268.

📒 Files selected for processing (8)
  • cmd/cmd.go
  • cmd/upgrade.go
  • cmd/upgrade_test.go
  • cmd/version.go
  • hack/copr.sh
  • hack/osdctl.spec
  • pkg/utils/version.go
  • pkg/utils/version_test.go

Comment thread cmd/upgrade.go
UpgradeInstruction() now returns an error for unrecognized InstallMethod
values, surfacing build misconfigurations instead of printing an empty
upgrade instruction.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gvnnn gvnnn changed the title Disable self-upgrade and version check for package-manager installs Disable self-upgrade and version check for packaged installation May 21, 2026
Copy link
Copy Markdown
Member

@MateSaary MateSaary left a comment

Choose a reason for hiding this comment

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

/lgtm

@openshift-ci openshift-ci Bot added the lgtm Indicates that a PR is ready to be merged. label May 21, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 21, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gvnnn, MateSaary

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@gvnnn
Copy link
Copy Markdown
Contributor Author

gvnnn commented May 21, 2026

/retest

@openshift-merge-bot
Copy link
Copy Markdown
Contributor

/retest-required

Remaining retests: 0 against base HEAD 4b9103f and 2 for PR HEAD aaa7250 in total

@gvnnn
Copy link
Copy Markdown
Contributor Author

gvnnn commented May 22, 2026

/test build format
/label tide/merge-method-squash
/honk

@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 22, 2026

@gvnnn:
goose image

Details

In response to this:

/test build format
/label tide/merge-method-squash
/honk

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@openshift-ci openshift-ci Bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label May 22, 2026
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 22, 2026

@gvnnn: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
ci/prow/build aaa7250 link true /test build
ci/prow/format aaa7250 link true /test format

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants