Skip to content

Commit 66daf3b

Browse files
authored
API: Admin endpoint cluster id filter for listing nodes (#2641)
Adds support to query nodes in non-default clusters
1 parent c5af930 commit 66daf3b

5 files changed

Lines changed: 164 additions & 76 deletions

File tree

packages/api/internal/api/api.gen.go

Lines changed: 108 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/api/internal/handlers/admin.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ import (
1414
"github.com/e2b-dev/infra/packages/shared/pkg/telemetry"
1515
)
1616

17-
func (a *APIStore) GetNodes(c *gin.Context) {
18-
result, err := a.orchestrator.AdminNodes()
17+
func (a *APIStore) GetNodes(c *gin.Context, params api.GetNodesParams) {
18+
clusterID := clusters.WithClusterFallback(params.ClusterID)
19+
result, err := a.orchestrator.AdminNodes(clusterID)
1920
if err != nil {
2021
telemetry.ReportCriticalError(c.Request.Context(), "error when getting nodes", err)
2122
a.sendAPIStoreError(c, http.StatusInternalServerError, "Error when getting nodes")

packages/api/internal/orchestrator/admin.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ import (
99
"github.com/e2b-dev/infra/packages/api/internal/api"
1010
)
1111

12-
func (o *Orchestrator) AdminNodes() ([]*api.Node, error) {
12+
func (o *Orchestrator) AdminNodes(clusterID uuid.UUID) ([]*api.Node, error) {
1313
var result []*api.Node
1414

1515
for _, n := range o.nodes.Items() {
16-
// Skip all nodes that are not running in local (Nomad) cluster
17-
if !n.IsNomadManaged() {
16+
if n.ClusterID != clusterID {
1817
continue
1918
}
2019

spec/openapi.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,14 +291,14 @@ components:
291291
additionalProperties:
292292
type: array
293293
items:
294-
$ref: '#/components/schemas/SandboxNetworkRule'
294+
$ref: "#/components/schemas/SandboxNetworkRule"
295295

296296
SandboxNetworkRule:
297297
type: object
298298
description: Transform rule applied to egress requests matching a domain pattern.
299299
properties:
300300
transform:
301-
$ref: '#/components/schemas/SandboxNetworkTransform'
301+
$ref: "#/components/schemas/SandboxNetworkTransform"
302302

303303
SandboxNetworkTransform:
304304
type: object
@@ -2431,7 +2431,7 @@ paths:
24312431
additionalProperties:
24322432
type: array
24332433
items:
2434-
$ref: '#/components/schemas/SandboxNetworkRule'
2434+
$ref: "#/components/schemas/SandboxNetworkRule"
24352435
allow_internet_access:
24362436
type: boolean
24372437
description:
@@ -3091,6 +3091,14 @@ paths:
30913091
tags: [admin]
30923092
security:
30933093
- AdminTokenAuth: []
3094+
parameters:
3095+
- in: query
3096+
name: clusterID
3097+
description: Identifier of the cluster
3098+
required: false
3099+
schema:
3100+
type: string
3101+
format: uuid
30943102
responses:
30953103
"200":
30963104
description: Successfully returned all nodes

0 commit comments

Comments
 (0)