Skip to content

Disable self-upgrade and version check for package-manager installs#887

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

Disable self-upgrade and version check for package-manager installs#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

Warning

Rate limit exceeded

@gvnnn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 2 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

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

Review profile: CHILL

Plan: Enterprise

Run ID: 3baf9617-6943-4ddd-b83b-a72da0ebfd1c

📥 Commits

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

📒 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

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.
Title check ✅ Passed The title accurately describes the main changes: disabling self-upgrade and version checks for package-manager-installed instances of osdctl via an InstallMethod mechanism.
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.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gvnnn

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

@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>
@openshift-ci
Copy link
Copy Markdown
Contributor

openshift-ci Bot commented May 11, 2026

@gvnnn: all tests passed!

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant