Skip to content

Make porch-server manager-runnable - #1111

Open
mozesl-nokia wants to merge 13 commits into
kptdev:mainfrom
nokia:manager-runnable
Open

Make porch-server manager-runnable#1111
mozesl-nokia wants to merge 13 commits into
kptdev:mainfrom
nokia:manager-runnable

Conversation

@mozesl-nokia

Copy link
Copy Markdown
Contributor

Make porch-server manager-runnable


Description

  • What changed: Wrapped the main porch-server process in the manager.Runnable interface, refactored how the object is set up, added leader-election related cli args.
  • Why it’s needed: First step towards high availability implementation
  • How it works: The PorchServer object is now running in a manager alongside the functionconfig controller

Related Issue(s)


Type of Change

  • Enhancement
  • Refactor

Checklist

  • Code follows project style guidelines
  • Self-reviewed changes
  • Tests added/updated
  • Documentation added/updated
  • All tests and gating checks pass

Additional Notes (Optional)

  • Known issues: If leader election is enabled and multiple replicas are started, only the leader pod can be "ready" otherwise incoming requests are distributed by kubernetes. The standby pod not being ready breaks default rollout (like kpt live apply)
  • Further improvements: Actually enabling leader-election with multiple replicas and figuring out how to handle request distribution. Add documentation.

AI Disclosure

  • I have used AI in the creation of this PR.

If so, please describe how:

  • Cursor's composer 2.5 was used to transplant the changes from another branch and some unit tests were written by it.

Assisted-by: Cursor:composer-2.5
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@mozesl-nokia
mozesl-nokia requested review from a team July 10, 2026 11:19
@netlify

netlify Bot commented Jul 10, 2026

Copy link
Copy Markdown

Deploy Preview for kpt-porch ready!

Name Link
🔨 Latest commit d269dbe
🔍 Latest deploy log https://app.netlify.com/projects/kpt-porch/deploys/6a60a53d43197a0008b95fa9
😎 Deploy Preview https://deploy-preview-1111--kpt-porch.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

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

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 10, 2026
@github-actions
github-actions Bot requested a review from Copilot July 10, 2026 11:20
@mozesl-nokia mozesl-nokia added enhancement New feature or request go Pull requests that update go code refactoring #b33d8f labels Jul 10, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Refactors porch-server startup so the apiserver runs as a manager.Runnable under a controller-runtime manager, enabling future HA via leader election while keeping existing server behavior largely intact.

Changes:

  • Wrap porch apiserver startup in a manager.Runnable (PorchServer) and start it via a controller-runtime manager.
  • Add HA/leader-election CLI flags and a probe-port option for manager health/ready endpoints.
  • Update unit/e2e tests to cover new flag parsing and (some) manager health delegation behavior.

Reviewed changes

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

Show a summary per file
File Description
test/e2e/api/advanced_test.go Makes readiness gate assertions order-insensitive (ElementsMatch).
pkg/cmd/server/start.go Switches startup to manager-based lifecycle; adds probe/HA flags and health delegation helpers.
pkg/cmd/server/start_test.go Adds coverage for new HA/probe flags and standby readiness behavior.
pkg/apiserver/porchserver.go Introduces PorchServer implementing manager.Runnable + LeaderElectionRunnable.
pkg/apiserver/config.go Builds controller-runtime manager, registers controllers, and returns (mgr, porchServer) instead of a standalone server.
pkg/apiserver/apiserver_test.go Adds tests for kubeconfig loading, client construction, New, and HA helpers.
go.mod Moves sigs.k8s.io/cli-utils to indirect dependency.

Comment thread pkg/cmd/server/start.go Outdated
Comment thread pkg/cmd/server/start.go Outdated
mozesl-nokia and others added 2 commits July 10, 2026 13:42
Signed-off-by: mozesl-nokia <laszlo.mozes@nokia.com>

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: mozesl-nokia <laszlo.mozes@nokia.com>
Assisted-by: Cursor:composer-2.5
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@mozesl-nokia

Copy link
Copy Markdown
Contributor Author

The rest of the coverage would probably require envtest, which I'm not familiar with (and would not trust AI with). This was not covered previously either.

The security rating is for internal network comms, so false positive.

Comment thread pkg/apiserver/apiserver_test.go Outdated
@dosubot dosubot Bot added the lgtm #ededed label Jul 20, 2026
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@efiacor

efiacor commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Quality Gate Failed Quality Gate failed

Failed conditions 54.3% Coverage on New Code (required ≥ 80%) D Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

I know most of the uncovered is config but could we refactor some of it out to helpers and test in isolation?

Assisted-by: Cursor:grok-4.5
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Assisted-by: Cursor:grok-4.5
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 21, 2026
Assisted-by: Cursor:grok-4.5
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
Assisted-by: Cursor:grok-4.5
Signed-off-by: Mózes László Máté <laszlo.mozes@nokia.com>
@sonarqubecloud

Copy link
Copy Markdown

@liamfallon
liamfallon requested a review from a team July 27, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request go Pull requests that update go code lgtm #ededed refactoring #b33d8f size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants