Skip to content

Commit 18a90c9

Browse files
committed
Add --labels flag, fix slot acquisition, fix p4_connect.act schema
- Add --labels CLI flag for agent runtime label declaration - Send labels in heartbeat for server-side seeding - Cap slot acquisition at 256 with ephemeral UUID fallback - Fix p4_connect.act type from 'orchestrator' to 'generic'
1 parent c8e03f2 commit 18a90c9

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

agent/models.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ type StatusReport struct {
7575
// HeartbeatRequest is sent periodically with agent metrics.
7676
type HeartbeatRequest struct {
7777
UUID string `json:"uuid,omitempty"`
78+
Labels string `json:"labels,omitempty"`
7879
CPUPercent float64 `json:"cpu_percent"`
7980
MemPercent float64 `json:"mem_percent"`
8081
MemUsedBytes int64 `json:"mem_used_bytes"`

agent/worker.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ type Worker struct {
2424
client *Client
2525
docker DockerConfig
2626
vcsOpts vcs.Options
27+
labels string
2728
pollInterval time.Duration
2829
uuid string
2930
log *logrus.Entry
@@ -32,11 +33,12 @@ type Worker struct {
3233
lastCounters *RawCounters
3334
}
3435

35-
func NewWorker(client *Client, docker DockerConfig, vcsOpts vcs.Options) *Worker {
36+
func NewWorker(client *Client, docker DockerConfig, vcsOpts vcs.Options, labels string) *Worker {
3637
return &Worker{
3738
client: client,
3839
docker: docker,
3940
vcsOpts: vcsOpts,
41+
labels: labels,
4042
pollInterval: 1 * time.Second,
4143
uuid: loadOrGenerateUUID(),
4244
log: logrus.WithField("component", "agent"),
@@ -586,13 +588,13 @@ func (w *Worker) buildHeartbeatRequest() HeartbeatRequest {
586588
snap, err := Snapshot()
587589
if err != nil {
588590
w.log.WithError(err).Warn("metrics snapshot error")
589-
return HeartbeatRequest{UUID: w.uuid}
591+
return HeartbeatRequest{UUID: w.uuid, Labels: w.labels}
590592
}
591593

592594
w.metricsMu.Lock()
593595
defer w.metricsMu.Unlock()
594596

595-
req := HeartbeatRequest{UUID: w.uuid}
597+
req := HeartbeatRequest{UUID: w.uuid, Labels: w.labels}
596598
if w.lastCounters != nil {
597599
// CPU percent
598600
if snap.CPUInstant {

cmd/cmd_agent.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import (
1616
var (
1717
flagAgentServer string
1818
flagAgentToken string
19+
flagAgentLabels string
1920
flagAgentDockerDisabled bool
2021
flagAgentDockerDefaultImage string
2122
flagAgentP4Client string
@@ -35,6 +36,7 @@ func init() {
3536
if os.Getenv("ACT_AGENT_TOKEN") == "" {
3637
cmdAgent.MarkFlagRequired("token")
3738
}
39+
cmdAgent.Flags().StringVar(&flagAgentLabels, "labels", envOr("ACT_AGENT_LABELS", ""), "Comma-separated labels for job matching (env: ACT_AGENT_LABELS)")
3840
cmdAgent.Flags().BoolVar(&flagAgentDockerDisabled, "docker-disabled", envOrBool("ACT_AGENT_DOCKER_DISABLED", false), "Disable Docker execution, always run natively")
3941
cmdAgent.Flags().StringVar(&flagAgentDockerDefaultImage, "docker-default-image", envOr("ACT_AGENT_DOCKER_DEFAULT_IMAGE", ""), "Force this Docker image for all scripts")
4042
cmdAgent.Flags().StringVar(&flagAgentP4Client, "p4-client", envOr("ACT_AGENT_P4CLIENT", ""), "Reuse an existing Perforce workspace instead of creating a temporary one (env: ACT_AGENT_P4CLIENT)")
@@ -68,7 +70,7 @@ func cmdAgentRun(cmd *cobra.Command, args []string) {
6870
DefaultImage: flagAgentDockerDefaultImage,
6971
}, vcs.Options{
7072
P4Client: flagAgentP4Client,
71-
})
73+
}, flagAgentLabels)
7274

7375
log.WithField("server", serverURL).Info("connecting")
7476
err := w.Run(ctx)

tests_e2e/scripts/p4_connect.act

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ editor:
22
version:
33
created: v1.0.0
44
entry: start
5-
type: orchestrator
5+
type: generic
66
nodes:
77
- id: start
88
type: core/start@v1

0 commit comments

Comments
 (0)