Skip to content

Commit 8b7f04e

Browse files
committed
feat: add coding-agent proxy sidecar support
1 parent 06886df commit 8b7f04e

7 files changed

Lines changed: 686 additions & 90 deletions

File tree

bin/opslevel-runner-coding-agent

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu
4+
SCRIPT_DIR="${BASH_SOURCE[0]%/*}"
5+
6+
# source for KUBECONFIG and k8s context to be set
7+
source "$SCRIPT_DIR/setup-kind.sh" opslevel-runner
8+
9+
exec watchexec --watch "$SCRIPT_DIR/../src" --exts go,mod,sum --restart \
10+
-- go run -C "$SCRIPT_DIR/../src" . --log-level TRACE run \
11+
--mode=faktory \
12+
--queues=coding-agent \
13+
--queue=coding-agent \
14+
--job-pod-max-wait=900 \
15+
--runner-pod-namespace=default \
16+
--job-agent-mode=true --metrics-port=10355 \
17+
--job-pod-helper-image=localhost/opslevel-runner:dev \
18+
--job-pod-requests-cpu="${OPSLEVEL_JOB_POD_REQUESTS_CPU:-50}" \
19+
--job-pod-requests-memory="${OPSLEVEL_JOB_POD_REQUESTS_MEMORY:-32}"

src/Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
faktory: faktory
22
runner: ../bin/opslevel-runner-runner
3+
coding-agent: ../bin/opslevel-runner-coding-agent
34
image-builder: watchexec --watch cmd/enqueue.go --watch cmd/root.go --watch main.go --watch go.mod --watch go.sum --watch ../Dockerfile -- HELPER_IMAGE=localhost/opslevel-runner:dev ../bin/build-helper-image.sh opslevel-runner

src/cmd/enqueue.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package cmd
22

33
import (
4+
"encoding/json"
45
"fmt"
56
"os"
67
"time"
78

89
faktory "github.com/contribsys/faktory/client"
10+
"github.com/rs/zerolog/log"
911
"github.com/spf13/cobra"
1012
"gopkg.in/yaml.v3"
1113
)
@@ -32,6 +34,7 @@ var enqueueCmd = &cobra.Command{
3234
Run: func(cmd *cobra.Command, args []string) {
3335
job, err := readFaktoryJobInput()
3436
cobra.CheckErr(err)
37+
3538
client, err := faktory.Open()
3639
cobra.CheckErr(err)
3740

@@ -58,6 +61,12 @@ var enqueueCmd = &cobra.Command{
5861
}
5962
}
6063

64+
if log.Debug().Enabled() {
65+
if b, merr := json.Marshal(j); merr == nil {
66+
log.Debug().RawJSON("payload", b).Msg("Submitting Faktory job")
67+
}
68+
}
69+
6170
if job.Batch != "" {
6271
batch, err := client.BatchOpen(job.Batch)
6372
cobra.CheckErr(err)

src/cmd/faktory.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func runJob(ctx context.Context, helper worker.Helper, job opslevel.RunnerJob) p
172172
go streamer.Run(ctx)
173173

174174
pkg.MetricJobsProcessing.Inc()
175-
logger.Info().Msgf("Starting job '%s'", job.Id)
175+
logger.Info().Str("job_id", string(job.Id)).Msg("job started")
176176
runner := pkg.NewJobRunner("faktory", cfgFile)
177177
outcome := runner.Run(ctx, job, streamer.Stdout, streamer.Stderr)
178178
streamer.Flush(outcome)
@@ -186,7 +186,12 @@ func emitJobStartedMetrics() time.Time {
186186

187187
func emitJobCompleteMetrics(jobStart time.Time, job opslevel.RunnerJob, outcome pkg.JobOutcome) {
188188
jobDuration := time.Since(jobStart)
189-
log.Info().Str("outcome", outcome.Message).Msgf("Finished job '%s' took '%s' and had outcome '%s'", job.Id, jobDuration, outcome.Outcome)
189+
log.Info().
190+
Str("job_id", string(job.Id)).
191+
Str("outcome", string(outcome.Outcome)).
192+
Int64("duration_ms", jobDuration.Milliseconds()).
193+
Str("outcome_message", outcome.Message).
194+
Msg("job finished")
190195
pkg.MetricJobsDuration.Observe(jobDuration.Seconds())
191196
pkg.MetricJobsFinished.WithLabelValues(string(outcome.Outcome)).Inc()
192197
pkg.MetricJobsProcessing.Dec()

0 commit comments

Comments
 (0)