Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/server: Trim public API to return *http.Server #246

Closed
wants to merge 1 commit into from

Conversation

wking
Copy link
Member

@wking wking commented Dec 17, 2018

Builds on #240; review that first.

The previous API required consumers to construct a handler and pass that handler back into a separate function to create a server based on the handler. With this commit, I've rerolled the API to return the handler directly, and the new public API is just NewBootstrapServer and NewClusterServer. To serve both HTTP and HTTPS from the returned server, I'm making shallow copies and altering Addr to set the per-protocol ports in those copies.

I've also made some server -> config renames in the types that have getConfig methods. And APIHandler is now configHandler. That helps consolidate the /config/* handling under a consistent name, so we have:

  • An *http.Server that is the server (e.g. as returned by NewClusterServer).
  • That server's handler is a muxer, and one of the muxer handlers is the configHandler for /config/*.
  • The configHandler structure holds a getConfig function, and we have bootstrapConfig and clusterConfig which can supply getConfig. Using a function type for this avoids the need for an interface and mock getConfig type.

@openshift-ci-robot openshift-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Dec 17, 2018
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wking

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

The pull request process is described here

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-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 17, 2018
@abhinavdahiya
Copy link
Contributor

/hold

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 17, 2018
@abhinavdahiya
Copy link
Contributor

abhinavdahiya commented Dec 17, 2018

IMO i liked the interface and i want like to keep it that way.

@wking
Copy link
Member Author

wking commented Dec 18, 2018

IMO i liked the interface and i want like to keep it that way.

Do you have suggestions for testing the complete muxer with the approach master's currently taking? Currently it's tucked in there with the code launching listen-and-serve goroutines.

And, if we're looking for smaller chunks of 8eef742816f1 where we agree, do you like bootstrapServer as the name of a struct whose only method is GetConfig? Or are you ok with me renaming that to bootstrapConfig?

@wking wking force-pushed the server-api-reroll branch 2 times, most recently from a9d032b to 5f0a6a7 Compare December 18, 2018 05:35
@wking
Copy link
Member Author

wking commented Dec 18, 2018

unit:

2018/12/18 05:39:17 Executing test unit
2018/12/18 05:45:00 Ran for 7m12s
error: could not run steps: failed to wait for test pod to complete: could not wait for pod completion: the pod ci-op-wyc89v0p/unit failed after 5m41s (failed containers: ):  unknown

Dunno what that's about.

/retest

The previous API required consumers to construct a handler and pass
that handler back into a separate function to create a server based on
the handler.  With this commit, I've rerolled the API to return the
handler directly, and the new public API is just NewBootstrapServer
and NewClusterServer.  To serve both HTTP and HTTPS from the returned
server, I'm making shallow copies and altering Addr to set the
per-protocol ports in those copies.

I've also made some "server" -> "config" renames in the types that
have getConfig methods.  And APIHandler is now configHandler.  That
helps consolidate the /config/* handling under a consistent name, so
we have:

* An http.Server that is the server (e.g. as returned by
  NewClusterServer).
* That server's handler is a muxer, and one of the muxer handlers is
  the configHandler for /config/*.
* The configHandler structure holds a getConfig function, and we have
  bootstrapConfig and clusterConfig which can supply getConfig.  Using
  a function type for this avoids the need for an interface and mock
  getConfig type.

The defaultHandler gives us our usual empty 404s for requests that
don't match our other handlers.  Without it, we'd have returned Go's
default:

  404 page not found

body, and had unit-test failures like:

  --- FAIL: TestHandler (0.00s)
      --- FAIL: TestHandler/GET_/does-not-exist (0.00s)
          api_test.go:93: response body length 19 does not match Content-Length -1
@wking
Copy link
Member Author

wking commented Dec 19, 2018

Rebased onto master with 5f0a6a7 -> 6cfa51c now that #240 has landed.

@ashcrow
Copy link
Member

ashcrow commented Jan 2, 2019

Testing looks happy now 😄

@wking wking mentioned this pull request Jan 5, 2019
@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 10, 2019
@openshift-ci-robot
Copy link
Contributor

@wking: PR needs rebase.

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/test-infra repository.

@openshift-ci-robot
Copy link
Contributor

@wking: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
ci/prow/e2e-aws-op 6cfa51c link /test e2e-aws-op

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@wking
Copy link
Member Author

wking commented Jan 16, 2019

With #267 landed and #239 obsolete, I don't have anything consuming this anymore. I'll leave further API decisions in this package up to @abhinavdahiya and the other maintainers ;).

/close

@openshift-ci-robot
Copy link
Contributor

@wking: Closed this PR.

In response to this:

With #267 landed and #239 obsolete, I don't have anything consuming this anymore. I'll leave further API decisions in this package up to @abhinavdahiya and the other maintainers ;).

/close

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/test-infra repository.

osherdp pushed a commit to osherdp/machine-config-operator that referenced this pull request Apr 13, 2021
…managed

Bug 1813175: abort metrics in general if removed/unmanaged
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. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants