Skip to content

Commit

Permalink
add groups endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Ferdudas97 committed Aug 4, 2023
1 parent 08f5a33 commit b4d7cf4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
Lists all changes with user impact.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).

## [0.19.36]

### Changed
- Added debug endpoint, which returns current groups

## [0.19.35]

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestBody
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.ResponseBody
import org.springframework.web.bind.annotation.RestController
import pl.allegro.tech.servicemesh.envoycontrol.groups.Group
import io.envoyproxy.envoy.config.core.v3.Node as NodeV3
import io.envoyproxy.envoy.extensions.filters.http.rbac.v3.RBAC as RBACFilter

Expand All @@ -57,6 +58,15 @@ class SnapshotDebugController(val debugService: SnapshotDebugService) {
)
}

@GetMapping("/groups")
fun globalSnapshot(@RequestParam(required = false) discoveryServiceName: String?)
: ResponseEntity<Collection<Group>> {
return ResponseEntity(
debugService.groups(discoveryServiceName),
HttpStatus.OK
)
}

@GetMapping("/snapshot-global")
fun globalSnapshot(@RequestParam(defaultValue = "false") xds: Boolean): ResponseEntity<SnapshotDebugInfo> {
return ResponseEntity(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import pl.allegro.tech.servicemesh.envoycontrol.ControlPlane
import pl.allegro.tech.servicemesh.envoycontrol.groups.Group
import pl.allegro.tech.servicemesh.envoycontrol.logger
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.GlobalSnapshot
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.IpFromServiceDiscovery
import pl.allegro.tech.servicemesh.envoycontrol.snapshot.SnapshotUpdater
import kotlin.concurrent.fixedRateTimer

@Component
class SnapshotDebugService(
Expand All @@ -30,6 +32,14 @@ class SnapshotDebugService(
}
}

fun groups(discoveryServiceName: String?): Collection<Group> {
return if (discoveryServiceName != null) {
cache.groups().filter { it.discoveryServiceName == discoveryServiceName}
} else {
cache.groups()
}
}

fun globalSnapshot(xds: Boolean): SnapshotDebugInfo {
val globalSnapshot = snapshotUpdater.getGlobalSnapshot()
if (xds) {
Expand Down

0 comments on commit b4d7cf4

Please sign in to comment.