Skip to content

✨ WIP: add support for receiving kubeconfig in op-con/catd options#2562

Open
grokspawn wants to merge 1 commit intooperator-framework:mainfrom
grokspawn:hypershift-adaptation
Open

✨ WIP: add support for receiving kubeconfig in op-con/catd options#2562
grokspawn wants to merge 1 commit intooperator-framework:mainfrom
grokspawn:hypershift-adaptation

Conversation

@grokspawn
Copy link
Contributor

Description

Adds the ability for op-con / catd to interact with a non-default apiserver

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

Copilot AI review requested due to automatic review settings March 12, 2026 20:06
@netlify
Copy link

netlify bot commented Mar 12, 2026

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit d68417a
🔍 Latest deploy log https://app.netlify.com/projects/olmv1/deploys/69b3236b5b94140008565cc4
😎 Deploy Preview https://deploy-preview-2562--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@openshift-ci
Copy link

openshift-ci bot commented Mar 12, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign grokspawn for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a --kubeconfig CLI option to let operator-controller and catalogd connect to a non-default Kubernetes API server (e.g., HyperShift scenarios), instead of always using the default controller-runtime config loading behavior.

Changes:

  • Add --kubeconfig flag to operator-controller and catalogd.
  • When --kubeconfig is provided, build the REST config from the specified kubeconfig file before creating the controller-runtime manager.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
cmd/operator-controller/main.go Adds --kubeconfig flag and uses it to construct the REST config passed to ctrl.NewManager.
cmd/catalogd/main.go Adds --kubeconfig flag and uses it to construct the REST config passed to ctrl.NewManager.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

❌ Patch coverage is 42.85714% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.25%. Comparing base (6692d1b) to head (d68417a).

Files with missing lines Patch % Lines
cmd/catalogd/main.go 45.45% 5 Missing and 1 partial ⚠️
cmd/operator-controller/main.go 40.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2562      +/-   ##
==========================================
- Coverage   68.65%   64.25%   -4.41%     
==========================================
  Files         131      131              
  Lines        9333     9352      +19     
==========================================
- Hits         6408     6009     -399     
- Misses       2436     2864     +428     
+ Partials      489      479      -10     
Flag Coverage Δ
e2e 42.19% <42.85%> (-0.02%) ⬇️
experimental-e2e 11.84% <23.80%> (-39.83%) ⬇️
unit 53.73% <0.00%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@grokspawn grokspawn force-pushed the hypershift-adaptation branch from c3f5ed2 to 1d14a74 Compare March 12, 2026 20:34
Signed-off-by: grokspawn <jordan@nimblewidget.com>
Copilot AI review requested due to automatic review settings March 12, 2026 20:34
@grokspawn grokspawn force-pushed the hypershift-adaptation branch from 1d14a74 to d68417a Compare March 12, 2026 20:34
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

return err
}
} else {
restConfig = ctrl.GetConfigOrDie()
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

run() now has two different failure behaviors for loading cluster config: the kubeconfig path returns an error, but the default path uses ctrl.GetConfigOrDie() which panics instead of returning an error. Since run() already returns error, prefer using a non-panicking config loader and propagate the error so startup failures are handled consistently.

Suggested change
restConfig = ctrl.GetConfigOrDie()
restConfig, err = ctrl.GetConfig()
if err != nil {
setupLog.Error(err, "unable to load in-cluster configuration")
return err
}

Copilot uses AI. Check for mistakes.
return err
}
} else {
restConfig = ctrl.GetConfigOrDie()
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Similar to operator-controller: the kubeconfig branch returns an error, but the default branch calls ctrl.GetConfigOrDie() which panics on failure. Since run() returns error, prefer consistently returning an error for config-load failures rather than panicking.

Suggested change
restConfig = ctrl.GetConfigOrDie()
restConfig, err = ctrl.GetConfig()
if err != nil {
setupLog.Error(err, "unable to load in-cluster kubeconfig")
return err
}

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

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

There is a point that GetConfigOrDie() is no longer necessary since it's not in the NewManager() call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the other hand, it's established behavior if using the default path. While I can't foresee that someone would be expecting a panic outcome, it's been a precedent for a long time, and doesn't have to change here. Another alternative is even forcing a panic with an alternative kubeconfig, so that the branching behaviors align again.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants