Skip to content

Commit 295a79a

Browse files
committed
List configured domains for each cluster node
1 parent 48f5d9b commit 295a79a

12 files changed

Lines changed: 447 additions & 22 deletions

File tree

cluster/about.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ package cluster
22

33
import (
44
"errors"
5+
"slices"
56
"time"
67

78
"github.com/datarhei/core/v16/cluster/raft"
8-
"github.com/datarhei/core/v16/slices"
99
)
1010

1111
type ClusterRaft struct {
@@ -44,6 +44,7 @@ type ClusterNodeGPUResources struct {
4444
type ClusterNode struct {
4545
ID string
4646
Name string
47+
Domains []string
4748
Version string
4849
State string
4950
Error error
@@ -87,7 +88,7 @@ type ClusterAbout struct {
8788
func (c *cluster) About() (ClusterAbout, error) {
8889
c.stateLock.RLock()
8990
hasLeader := c.hasRaftLeader
90-
domains := slices.Copy(c.hostnames)
91+
domains := slices.Clone(c.hostnames)
9192
c.stateLock.RUnlock()
9293

9394
about := ClusterAbout{
@@ -135,9 +136,19 @@ func (c *cluster) About() (ClusterAbout, error) {
135136
for _, node := range nodes {
136137
nodeAbout := node.About()
137138

139+
nodeDomains := []string{}
140+
for _, d := range nodeAbout.HostNames {
141+
if slices.Contains(domains, d) {
142+
continue
143+
}
144+
145+
nodeDomains = append(nodeDomains, d)
146+
}
147+
138148
node := ClusterNode{
139149
ID: nodeAbout.ID,
140150
Name: nodeAbout.Name,
151+
Domains: nodeDomains,
141152
Version: nodeAbout.Version,
142153
State: nodeAbout.State,
143154
Error: nodeAbout.Error,

cluster/docs/ClusterAPI_docs.go

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,8 @@ const docTemplateClusterAPI = `{
13081308
},
13091309
"limitCPU": {
13101310
"description": "percent",
1311-
"type": "number"
1311+
"type": "number",
1312+
"format": "float64"
13121313
},
13131314
"limitGPU": {
13141315
"description": "GPU limits",
@@ -1320,11 +1321,13 @@ const docTemplateClusterAPI = `{
13201321
},
13211322
"limitMemory": {
13221323
"description": "bytes",
1323-
"type": "integer"
1324+
"type": "integer",
1325+
"format": "int64"
13241326
},
13251327
"limitWaitFor": {
13261328
"description": "seconds",
1327-
"type": "integer"
1329+
"type": "integer",
1330+
"format": "int64"
13281331
},
13291332
"logPatterns": {
13301333
"description": "will be interpreted as regular expressions",
@@ -1353,7 +1356,8 @@ const docTemplateClusterAPI = `{
13531356
},
13541357
"reconnectDelay": {
13551358
"description": "seconds",
1356-
"type": "integer"
1359+
"type": "integer",
1360+
"format": "int64"
13571361
},
13581362
"reference": {
13591363
"type": "string"
@@ -1364,11 +1368,13 @@ const docTemplateClusterAPI = `{
13641368
},
13651369
"staleTimeout": {
13661370
"description": "seconds",
1367-
"type": "integer"
1371+
"type": "integer",
1372+
"format": "int64"
13681373
},
13691374
"timeout": {
13701375
"description": "seconds",
1371-
"type": "integer"
1376+
"type": "integer",
1377+
"format": "int64"
13721378
}
13731379
}
13741380
},
@@ -1417,19 +1423,23 @@ const docTemplateClusterAPI = `{
14171423
"properties": {
14181424
"decoder": {
14191425
"description": "percent 0-100",
1420-
"type": "number"
1426+
"type": "number",
1427+
"format": "float64"
14211428
},
14221429
"encoder": {
14231430
"description": "percent 0-100",
1424-
"type": "number"
1431+
"type": "number",
1432+
"format": "float64"
14251433
},
14261434
"memory": {
14271435
"description": "bytes",
1428-
"type": "integer"
1436+
"type": "integer",
1437+
"format": "int64"
14291438
},
14301439
"usage": {
14311440
"description": "percent 0-100",
1432-
"type": "number"
1441+
"type": "number",
1442+
"format": "float64"
14331443
}
14341444
}
14351445
},
@@ -2036,6 +2046,9 @@ const docTemplateClusterAPI = `{
20362046
"resources": {
20372047
"type": "object",
20382048
"properties": {
2049+
"limit_wait_for_sec": {
2050+
"type": "integer"
2051+
},
20392052
"max_cpu_usage": {
20402053
"description": "percent 0-100",
20412054
"type": "number"

cluster/docs/ClusterAPI_swagger.json

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,7 +1301,8 @@
13011301
},
13021302
"limitCPU": {
13031303
"description": "percent",
1304-
"type": "number"
1304+
"type": "number",
1305+
"format": "float64"
13051306
},
13061307
"limitGPU": {
13071308
"description": "GPU limits",
@@ -1313,11 +1314,13 @@
13131314
},
13141315
"limitMemory": {
13151316
"description": "bytes",
1316-
"type": "integer"
1317+
"type": "integer",
1318+
"format": "int64"
13171319
},
13181320
"limitWaitFor": {
13191321
"description": "seconds",
1320-
"type": "integer"
1322+
"type": "integer",
1323+
"format": "int64"
13211324
},
13221325
"logPatterns": {
13231326
"description": "will be interpreted as regular expressions",
@@ -1346,7 +1349,8 @@
13461349
},
13471350
"reconnectDelay": {
13481351
"description": "seconds",
1349-
"type": "integer"
1352+
"type": "integer",
1353+
"format": "int64"
13501354
},
13511355
"reference": {
13521356
"type": "string"
@@ -1357,11 +1361,13 @@
13571361
},
13581362
"staleTimeout": {
13591363
"description": "seconds",
1360-
"type": "integer"
1364+
"type": "integer",
1365+
"format": "int64"
13611366
},
13621367
"timeout": {
13631368
"description": "seconds",
1364-
"type": "integer"
1369+
"type": "integer",
1370+
"format": "int64"
13651371
}
13661372
}
13671373
},
@@ -1410,19 +1416,23 @@
14101416
"properties": {
14111417
"decoder": {
14121418
"description": "percent 0-100",
1413-
"type": "number"
1419+
"type": "number",
1420+
"format": "float64"
14141421
},
14151422
"encoder": {
14161423
"description": "percent 0-100",
1417-
"type": "number"
1424+
"type": "number",
1425+
"format": "float64"
14181426
},
14191427
"memory": {
14201428
"description": "bytes",
1421-
"type": "integer"
1429+
"type": "integer",
1430+
"format": "int64"
14221431
},
14231432
"usage": {
14241433
"description": "percent 0-100",
1425-
"type": "number"
1434+
"type": "number",
1435+
"format": "float64"
14261436
}
14271437
}
14281438
},
@@ -2029,6 +2039,9 @@
20292039
"resources": {
20302040
"type": "object",
20312041
"properties": {
2042+
"limit_wait_for_sec": {
2043+
"type": "integer"
2044+
},
20322045
"max_cpu_usage": {
20332046
"description": "percent 0-100",
20342047
"type": "number"

cluster/docs/ClusterAPI_swagger.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,19 @@ definitions:
1818
type: array
1919
limitCPU:
2020
description: percent
21+
format: float64
2122
type: number
2223
limitGPU:
2324
allOf:
2425
- $ref: '#/definitions/app.ConfigLimitGPU'
2526
description: GPU limits
2627
limitMemory:
2728
description: bytes
29+
format: int64
2830
type: integer
2931
limitWaitFor:
3032
description: seconds
33+
format: int64
3134
type: integer
3235
logPatterns:
3336
description: will be interpreted as regular expressions
@@ -48,6 +51,7 @@ definitions:
4851
type: boolean
4952
reconnectDelay:
5053
description: seconds
54+
format: int64
5155
type: integer
5256
reference:
5357
type: string
@@ -56,9 +60,11 @@ definitions:
5660
type: string
5761
staleTimeout:
5862
description: seconds
63+
format: int64
5964
type: integer
6065
timeout:
6166
description: seconds
67+
format: int64
6268
type: integer
6369
type: object
6470
app.ConfigIO:
@@ -91,15 +97,19 @@ definitions:
9197
properties:
9298
decoder:
9399
description: percent 0-100
100+
format: float64
94101
type: number
95102
encoder:
96103
description: percent 0-100
104+
format: float64
97105
type: number
98106
memory:
99107
description: bytes
108+
format: int64
100109
type: integer
101110
usage:
102111
description: percent 0-100
112+
format: float64
103113
type: number
104114
type: object
105115
client.AboutResponse:
@@ -508,6 +518,8 @@ definitions:
508518
type: object
509519
resources:
510520
properties:
521+
limit_wait_for_sec:
522+
type: integer
511523
max_cpu_usage:
512524
description: percent 0-100
513525
type: number

cluster/node/node.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/datarhei/core/v16/config"
1414
"github.com/datarhei/core/v16/ffmpeg/skills"
1515
"github.com/datarhei/core/v16/log"
16+
"github.com/datarhei/core/v16/slices"
1617
)
1718

1819
type Node struct {
@@ -129,6 +130,7 @@ var maxLastContact time.Duration = 5 * time.Second
129130
type About struct {
130131
ID string
131132
Name string
133+
HostNames []string
132134
Version string
133135
Address string
134136
State string
@@ -177,6 +179,7 @@ func (n *Node) About() About {
177179
}
178180

179181
a.Name = n.coreAbout.Name
182+
a.HostNames = slices.Copy(n.config.Host.Name)
180183
a.Error = n.nodeLastErr
181184
a.LastContact = n.nodeLastContact
182185
if time.Since(a.LastContact) > maxLastContact {

0 commit comments

Comments
 (0)