From 86794b51705e11d359caee2ed610522b47841a84 Mon Sep 17 00:00:00 2001 From: Jerry Gong Date: Thu, 17 Oct 2024 09:41:17 -0400 Subject: [PATCH] Address comment --- master/pkg/model/task_container_defaults.go | 13 +++++-------- master/pkg/schemas/expconf/log_pattern_config.go | 6 +++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/master/pkg/model/task_container_defaults.go b/master/pkg/model/task_container_defaults.go index 9c44bab5f6a9..ed89cd46c23b 100644 --- a/master/pkg/model/task_container_defaults.go +++ b/master/pkg/model/task_container_defaults.go @@ -49,7 +49,7 @@ type TaskContainerDefaultsConfig struct { StartupHook string `json:"startup_hook"` - LogPolicies *expconf.LogPoliciesConfig `json:"log_policies"` + LogPolicies expconf.LogPoliciesConfig `json:"log_policies"` PreemptionTimeout int `json:"preemption_timeout,omitempty"` @@ -319,13 +319,10 @@ func (c TaskContainerDefaultsConfig) Merge( res.Pbs.SetSbatchArgs(tmp) } - if other.LogPolicies != nil { - if res.LogPolicies == nil { - res.LogPolicies = other.LogPolicies - } else { - logPolicies := res.LogPolicies.Merge(*other.LogPolicies) - res.LogPolicies = &logPolicies - } + if res.LogPolicies == nil { + res.LogPolicies = other.LogPolicies + } else { + res.LogPolicies = res.LogPolicies.Merge(other.LogPolicies) } if other.PreemptionTimeout > 0 { diff --git a/master/pkg/schemas/expconf/log_pattern_config.go b/master/pkg/schemas/expconf/log_pattern_config.go index 91711e434c22..ea89ac366d68 100644 --- a/master/pkg/schemas/expconf/log_pattern_config.go +++ b/master/pkg/schemas/expconf/log_pattern_config.go @@ -22,14 +22,14 @@ const ( type LogPoliciesConfigV0 []LogPolicyV0 // WithDefaults implements the Defaultable psuedointerface. -func (b *LogPoliciesConfigV0) WithDefaults() *LogPoliciesConfigV0 { +func (b LogPoliciesConfigV0) WithDefaults() LogPoliciesConfigV0 { eccErrorPattern := ECCErrorPattern eccErrorSignal := ECCErrorSignal cudaOomPattern := CUDAOOMPattern cudaOomSignal := CUDAOOMSignal - if b != nil && len(*b) == 0 { - return &LogPoliciesConfigV0{ + if b != nil && len(b) == 0 { + return LogPoliciesConfigV0{ LogPolicyV0{RawPattern: eccErrorPattern, RawActions: []LogActionV0{{Signal: &eccErrorSignal}}}, LogPolicyV0{RawPattern: cudaOomPattern, RawActions: []LogActionV0{{Signal: &cudaOomSignal}}}, }