Skip to content

backend: refactor StartHeadlampServer by extracting runServer - #6217

Merged
illume merged 1 commit into
kubernetes-sigs:mainfrom
srajang1805:backend/split-start-headlamp-server
Jul 1, 2026
Merged

illume merged 1 commit into
kubernetes-sigs:mainfrom
srajang1805:backend/split-start-headlamp-server

Conversation

@srajang1805

Copy link
Copy Markdown
Contributor

Summary

This PR refactors StartHeadlampServer by extracting the server startup and shutdown logic into a dedicated runServer helper.

The extraction removes the existing //nolint:funlen suppression while preserving the original behavior. StartHeadlampServer now focuses on orchestration, with the server lifecycle encapsulated in a smaller helper.

Changes

  • Extracted runServer(config, cancel, handler) from StartHeadlampServer.

  • Moved:

    • HTTP server creation
    • TLS/plain HTTP startup
    • Graceful shutdown handling
    • Server error handling
  • Removed the //nolint:funlen suppression from StartHeadlampServer.

  • No functional changes or API changes.

Advantages

  • Removes the need for the //nolint:funlen suppression.
  • Improves separation of responsibilities between orchestration and server lifecycle management.
  • Makes StartHeadlampServer easier to read and maintain.
  • Keeps the server startup logic localized in a dedicated helper.
  • Preserves existing runtime behavior.

Verification

  • Relevant tests passed

Notes for Reviewers

  • This is intended to be a refactoring only with no behavioral changes.
  • The extracted helper is unexported and does not modify the public API.
  • The diff is intentionally small and primarily consists of moving existing logic into runServer.
  • The primary goal is to improve readability and eliminate the //nolint:funlen suppression.

@kubernetes-prow kubernetes-prow Bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Jun 26, 2026
@kubernetes-prow
kubernetes-prow Bot requested review from illume and skoeva June 26, 2026 19:48
@kubernetes-prow kubernetes-prow Bot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 26, 2026
@illume
illume requested a review from Copilot June 28, 2026 10:15

@illume illume 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.

Thanks for these changes.

Can you please have a look at the git commits to see if they meet the contribution guidelines? We use a Linux kernel style of git commits. See the contributing guide for general context, and please see previous git commits with git log for examples.

Commits that need attention
  • backend: Extract runServer from StartHeadlampServer, drop nolint:funlen — Only one file changed inside backend/; add a sub-area so it's clear what was touched (e.g. backend: ComponentName: description).
Commit guidelines
  • Use atomic commits focused on a single change.
  • Use the title format <area>: <Description of changes> — description must start with a capital letter.
  • Keep the title under 72 characters (soft requirement).
  • Explain the intention and why the change is needed.
  • Make commit titles meaningful and describe what changed.
  • Do not add code that a later commit rewrites; squash or reorder commits instead.
  • Do not include Fixes #NN in commit messages.

Good examples:

  • frontend: HomeButton: Fix so it navigates to home
  • backend: config: Add enable-dynamic-clusters flag

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

This PR refactors the backend server startup path by extracting the HTTP server lifecycle (listen + graceful shutdown + error handling) from StartHeadlampServer into a new unexported helper, runServer, to improve readability and remove the //nolint:funlen suppression without changing behavior.

Changes:

  • Removed the //nolint:funlen suppression on StartHeadlampServer by extracting the server lifecycle logic.
  • Added runServer(config, cancel, handler) to encapsulate server creation, ListenAndServe(TLS), graceful shutdown wiring, and startup error handling.

Extract server creation, graceful shutdown, TLS/plain listening, and
error handling from StartHeadlampServer into a new runServer helper.

StartHeadlampServer now focuses on setup (telemetry, router, static
files, handler assembly). The server lifecycle concern is entirely in
runServer, which accepts the config, cancel func, and handler.

Removes the //nolint:funlen annotation — both functions are now within
the funlen limit.
@srajang1805
srajang1805 force-pushed the backend/split-start-headlamp-server branch from 7ec9166 to 01a760b Compare June 29, 2026 05:12
@srajang1805
srajang1805 requested a review from illume June 29, 2026 05:12
@illume
illume requested a review from Copilot June 29, 2026 10:53

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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@illume illume 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.

🎉 thanks!

@kubernetes-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: illume, srajang1805

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

@kubernetes-prow kubernetes-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 1, 2026
@illume
illume merged commit 15b2014 into kubernetes-sigs:main Jul 1, 2026
10 of 11 checks passed
@illume illume added this to the v0.44.0 milestone Jul 27, 2026
@illume illume added backend Issues related to the backend quality Related to improving the quality of the app labels Jul 27, 2026
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. backend Issues related to the backend cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. quality Related to improving the quality of the app size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants