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

Add a client_state.json admin endpoint to expose the client address set #1768

Merged
merged 2 commits into from Jan 5, 2018

Conversation

adleong
Copy link
Member

@adleong adleong commented Jan 3, 2018

Add client_state.json admin endpoint which outputs the current address set for each client in the client registry.

Sample output:

{
  "/$/inet/localhost/4100": {
    "state": "bound",
    "addresses": [
      "localhost:4100"
    ]
  },
  "/#/io.l5d.k8s/emojivoto/grpc/voting-svc": {
    "state": "bound",
    "addresses": [
      "172.17.0.8:8080",
      "172.17.0.7:8080",
      "172.17.0.5:8080"
    ]
  }
}

Signed-off-by: Alex Leong alex@buoyant.io

…set of each client

Signed-off-by: Alex Leong <alex@buoyant.io>
@adleong adleong self-assigned this Jan 3, 2018
@adleong adleong requested a review from olix0r January 3, 2018 21:51
@adleong
Copy link
Member Author

adleong commented Jan 3, 2018

cc @obeattie

override def apply(request: Request): Future[Response] = {
val entries = ClientRegistry.registrants.map { entry =>
val LoadBalancerFactory.Dest(va) = entry.params[LoadBalancerFactory.Dest]
va.changes.toFuture().map(entry.addr -> _)
Copy link
Member

Choose a reason for hiding this comment

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

can we limit this to entries where entry.addr is a Name or Path so that we don't encode weird things for clients that don't do name resolution?

override def apply(request: Request): Future[Response] = {
val entries = ClientRegistry.registrants.map { entry =>
val LoadBalancerFactory.Dest(va) = entry.params[LoadBalancerFactory.Dest]
va.changes.toFuture().map(entry.addr -> _)
Copy link
Member

Choose a reason for hiding this comment

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

Why va.changes.toFuture() and not va.sample()?

case Addr.Failed(why) => s"Failed: ${why.getMessage}"
case a@Addr.Pending => a.toString
case a@Addr.Neg => a.toString
}
Copy link
Member

Choose a reason for hiding this comment

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

wait what is the type of state? This seems a little annoying to decode if the type is "a list or maybe a string".

Perhaps better to have a case class that encodes e.g. "state": "bound", "addrs": [] etc (i'd bet that we even have this somewhere already for namerd's http api)

Signed-off-by: Alex Leong <alex@buoyant.io>
// only display clients with a Path name
Try(Path.read(entry.addr)).isReturn
}.map { entry =>
val LoadBalancerFactory.Dest(va) = entry.params[LoadBalancerFactory.Dest]
Copy link
Member

Choose a reason for hiding this comment

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

Are we confident that LoadBalancerFactory.Dest's Var is reference-counted? Do we need to ensure this higher up in the stack when we get the result from an interpreter?

@adleong adleong merged commit ce01c23 into master Jan 5, 2018
@adleong adleong deleted the alex/client-state branch January 5, 2018 17:58
@siggy siggy added this to the 1.3.5 milestone Jan 9, 2018
@hawkw hawkw mentioned this pull request Jan 17, 2018
hawkw added a commit that referenced this pull request Jan 18, 2018
## 1.3.5 2018-01-17

* 🎓 H2 router and `io.l5d.mesh` Namerd interface are no longer experimental ([#1782](#1782))! 🎓
* Add an experimental namer for Rancher service discovery ([#1740](#1740)). A huge thank you to [@fangel](https://github.com/fangel) for contributing this namer!
* Kubernetes
  * Fix a bug that could cause the `io.l5d.k8s` namer to get "stuck" and fail to recieve updates from an endpoint ([#1755](#1755)). Contributed by [@obeattie](https://github.com/obeattie).
* Admin UI
  * Add `/admin/client_state.json` endpoint to return the current address set of each client ([#1768](#1768)).
  * Fix an error when using the admin UI to perform delegations with a dtab stored in Namerd over the `io.l5d.thriftNameInterpreter` interface ([#1762](#1762)). Thanks to [@jackkleeman](https://github.com/jackkleeman)!
  * Render an error instead of a blank page for failures on Namerd's dtab playground ([#1770](#1770)).
* Namerd
  * Errors parsing dtabs stored in Consul are now surfaced in log messages ([#1760](#1760)).
  * Fix an error where Linekrd could sometimes miss updates from Namerd when using the `io.l5d.thriftNameInterpreter` interface ([#1753](#1753)). Thanks to [@obeattie](https://github.com/obeattie)!
@nikolay-pshenichny
Copy link
Contributor

nit: this PR adds '/client_state.json', but in the 1.3.5 release info the endpoint is '/admin/client_state.json`

@hawkw
Copy link
Member

hawkw commented Jan 24, 2018

@nikolay-pshenichny whoops! Will fix that.

hawkw added a commit that referenced this pull request Jan 24, 2018
See #1768 (comment).

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
@obeattie
Copy link
Contributor

Thank you so much for this 🙌

hawkw added a commit that referenced this pull request Jan 24, 2018
See #1768 (comment).

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
Tim-Brooks pushed a commit to Tim-Brooks/linkerd that referenced this pull request Dec 20, 2018
Jest is faster, has more flexibility to run a subset of the tests, and will allow 
us to remove a bunch of our assertion libraries.

Many thanks to @grampelberg for prior work on this (linkerd#1000)

This PR:
- changes the test runner from karma to jest
- moves individual tests from /test/ to/js/components` where jest expects them
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.

None yet

6 participants