Skip to content

Commit aa8bbed

Browse files
masipauskasMartynas Asipauskas
andauthored
Sanitize jsonb column from unicode null character, hide jobFailureInfo jsonb map behind enableJobRunFailureInfoMap (disabled by default) (#4829)
* Unicode null termination characters in /dev/termination-log will no longer break lookout ingester. * We're gating the error categorisation error map behind feature flag (as we're likely to change field shape due to load on the DB). Co-authored-by: Martynas Asipauskas <[email protected]>
1 parent 900ac89 commit aa8bbed

13 files changed

Lines changed: 180 additions & 32 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,5 @@ tmp/
113113
tmp.*
114114
*.tmp.*
115115
.aider*
116+
117+
.claude/

internal/lookout/pruner/pruner_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func TestPruneDb(t *testing.T) {
134134
for _, tc := range testCases {
135135
t.Run(tc.testName, func(t *testing.T) {
136136
err := lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
137-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, "armadaproject.io/", []string{}, &compress.NoOpCompressor{})
137+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, "armadaproject.io/", []string{}, &compress.NoOpCompressor{}, false)
138138
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
139139

140140
ctx, cancel := armadacontext.WithTimeout(armadacontext.Background(), 5*time.Minute)

internal/lookout/repository/getjoberror_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
func TestGetJobError(t *testing.T) {
1818
err := lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
19-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{})
19+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{}, false)
2020
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
2121
errMsg := "some bad error happened!"
2222
_ = NewJobSimulator(converter, store).

internal/lookout/repository/getjobrundebugmessage_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
func TestGetJobRunDebugMessage(t *testing.T) {
1818
err := lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
19-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{})
19+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{}, false)
2020
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
2121

2222
debugMessageStrings := []string{

internal/lookout/repository/getjobrunerror_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616

1717
func TestGetJobRunError(t *testing.T) {
1818
err := lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
19-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{})
19+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{}, false)
2020
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
2121

2222
errorStrings := []string{

internal/lookout/repository/getjobs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ var (
5959
func withGetJobsSetup(f func(*instructions.InstructionConverter, *lookoutdb.LookoutDb, *SqlGetJobsRepository, *clock.FakeClock) error) error {
6060
testClock := clock.NewFakeClock(time.Now())
6161
return lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
62-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{})
62+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{}, false)
6363
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
6464
repo := NewSqlGetJobsRepository(db)
6565
repo.clock = testClock

internal/lookout/repository/getjobspec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818

1919
func TestGetJobSpec(t *testing.T) {
2020
err := lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
21-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{})
21+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{}, false)
2222
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
2323

2424
job := NewJobSimulator(converter, store).
@@ -54,7 +54,7 @@ func TestGetJobSpec(t *testing.T) {
5454
func TestMIGRATEDGetJobSpec(t *testing.T) {
5555
var migratedResult *api.Job
5656
err := lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
57-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{})
57+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{}, false)
5858
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
5959

6060
_ = NewJobSimulator(converter, store).

internal/lookout/repository/groupjobs_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222

2323
func withGroupJobsSetup(f func(*instructions.InstructionConverter, *lookoutdb.LookoutDb, *SqlGroupJobsRepository) error) error {
2424
return lookout.WithLookoutDb(func(db *pgxpool.Pool) error {
25-
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{})
25+
converter := instructions.NewInstructionConverter(metrics.Get().Metrics, userAnnotationPrefix, []string{}, &compress.NoOpCompressor{}, false)
2626
store := lookoutdb.NewLookoutDb(db, nil, metrics.Get(), 10, 10)
2727
repo := NewSqlGroupJobsRepository(db)
2828
return f(converter, store, repo)

internal/lookoutingester/configuration/types.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ type LookoutIngesterConfiguration struct {
4949
Profiling *profilingconfig.ProfilingConfig
5050
// List of Regexes which will identify fatal errors when inserting into postgres
5151
FatalInsertionErrors []string
52+
// When true, populate FailureInfo on terminal job run errors from the proto FailureInfo field.
53+
// When false, set FailureInfo to an empty map for terminal errors.
54+
EnableJobRunFailureInfoMap bool
5255
}
5356

5457
func (c *LookoutIngesterConfiguration) GetUserAnnotationPrefix() string {

internal/lookoutingester/dbloadtester/simulator.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ func Setup(lookoutIngesterConfig configuration.LookoutIngesterConfiguration, tes
7979
panic(errors.WithMessage(err, "Error creating compressor"))
8080
}
8181

82-
converter := instructions.NewInstructionConverter(m.Metrics, lookoutIngesterConfig.UserAnnotationPrefix, []string{}, compressor)
82+
converter := instructions.NewInstructionConverter(m.Metrics, lookoutIngesterConfig.UserAnnotationPrefix, []string{}, compressor, lookoutIngesterConfig.EnableJobRunFailureInfoMap)
8383

8484
submitJobTemplate := &v1.PodSpec{}
8585
err = clientUtil.BindJsonOrYaml(testConfig.JobTemplateFile, submitJobTemplate)

0 commit comments

Comments
 (0)