@@ -10,20 +10,13 @@ import (
10
10
11
11
"github.com/cilium/cilium/api/v1/models"
12
12
endpoint_id "github.com/cilium/cilium/pkg/endpoint/id"
13
+ "github.com/cosmonic/netreap/internal/netreap"
13
14
nomad_api "github.com/hashicorp/nomad/api"
14
15
"go.uber.org/zap"
15
16
16
17
backoff "github.com/cenkalti/backoff/v4"
17
18
)
18
19
19
- const (
20
- netreapLabelPrefix = "netreap"
21
- nomadLabelPrefix = "nomad"
22
- jobIDLabel = "nomad.job_id"
23
- taskGroupLabel = "nomad.task_group_id"
24
- namespaceLabel = "nomad.namespace"
25
- )
26
-
27
20
type EndpointReaper struct {
28
21
cilium EndpointUpdater
29
22
nomadAllocations AllocationInfo
@@ -271,9 +264,9 @@ func stringArrayEqual(left []string, right []string) bool {
271
264
}
272
265
273
266
func (e * EndpointReaper ) labelEndpoint (endpoint * models.Endpoint , allocation * nomad_api.Allocation ) {
274
- newLabels := models.Labels {fmt .Sprintf ("%s:%s=%s" , netreapLabelPrefix , jobIDLabel , allocation .JobID )}
275
- newLabels = append (newLabels , fmt .Sprintf ("%s:%s=%s" , netreapLabelPrefix , namespaceLabel , allocation .Namespace ))
276
- newLabels = append (newLabels , fmt .Sprintf ("%s:%s=%s" , netreapLabelPrefix , taskGroupLabel , allocation .TaskGroup ))
267
+ newLabels := models.Labels {fmt .Sprintf ("%s:%s=%s" , netreap . LabelSourceNetreap , netreap . LabelKeyNomadJobID , allocation .JobID )}
268
+ newLabels = append (newLabels , fmt .Sprintf ("%s:%s=%s" , netreap . LabelSourceNetreap , netreap . LabelKeyNomadNamespace , allocation .Namespace ))
269
+ newLabels = append (newLabels , fmt .Sprintf ("%s:%s=%s" , netreap . LabelSourceNetreap , netreap . LabelKeyNomadTaskGroupID , allocation .TaskGroup ))
277
270
278
271
// Combine the metadata from the job and the task group with the task group taking precedence
279
272
metadata := make (map [string ]string )
@@ -290,7 +283,7 @@ func (e *EndpointReaper) labelEndpoint(endpoint *models.Endpoint, allocation *no
290
283
}
291
284
292
285
for k , v := range metadata {
293
- newLabels = append (newLabels , fmt .Sprintf ("%s:%s=%s" , nomadLabelPrefix , k , v ))
286
+ newLabels = append (newLabels , fmt .Sprintf ("%s:%s=%s" , netreap . LabelSourceNomad , k , v ))
294
287
}
295
288
296
289
oldLabels := models.Labels {}
@@ -308,6 +301,13 @@ func (e *EndpointReaper) labelEndpoint(endpoint *models.Endpoint, allocation *no
308
301
return
309
302
}
310
303
304
+ zap .L ().Info ("Patching labels on endpoint" ,
305
+ zap .String ("container-id" , allocation .ID ),
306
+ zap .Int64 ("endpoint-id" , endpoint .ID ),
307
+ zap .Strings ("new-labels" , newLabels ),
308
+ zap .Strings ("old-labels" , oldLabels ),
309
+ )
310
+
311
311
ecr := & models.EndpointChangeRequest {
312
312
ContainerID : allocation .ID ,
313
313
ContainerName : allocation .Name ,
0 commit comments