@@ -96,36 +96,42 @@ func ConfigureCacheSettings(workflow *v1alpha1.Workflow, remove bool) *v1alpha1.
9696 for _ , template := range configuredWorkflow .Spec .Templates {
9797 if template .Container != nil {
9898 if len (template .Container .Args ) > 0 {
99- if remove && slices .Contains (template .Container .Args , cacheDisabledArg ) {
100- containerArgs := make ([]string , len (template .Container .Args )- 1 )
101- for index , arg := range template .Container .Args {
102- if arg == cacheDisabledArg {
103- containerArgs = append (template .Container .Args [:index ], template .Container .Args [index + 1 :]... )
104- break
99+ if remove {
100+ // Remove cache_disabled arg if it exists
101+ if slices .Contains (template .Container .Args , cacheDisabledArg ) {
102+ for index , arg := range template .Container .Args {
103+ if arg == cacheDisabledArg {
104+ template .Container .Args = append (template .Container .Args [:index ], template .Container .Args [index + 1 :]... )
105+ break
106+ }
105107 }
106108 }
107- template .Container .Args = containerArgs
108109 } else {
109- if slices .Contains (template .Container .Args , "--run_id" ) {
110+ // Add cache_disabled arg if it doesn't exist and this is a driver container
111+ if slices .Contains (template .Container .Args , "--run_id" ) && ! slices .Contains (template .Container .Args , cacheDisabledArg ) {
110112 template .Container .Args = append (template .Container .Args , cacheDisabledArg )
111113 }
112114 }
113115 }
114116 for index , userContainer := range template .InitContainers {
115117 if remove {
116- userArgs := make ([]string , len (userContainer .Args )- 1 )
117- for userArgsIndex , arg := range userContainer .Args {
118- if arg == cacheDisabledArg {
119- userArgs = append (userContainer .Args [:userArgsIndex ], userContainer .Args [userArgsIndex + 1 :]... )
120- break
118+ // Remove cache_disabled arg if it exists
119+ if slices .Contains (userContainer .Args , cacheDisabledArg ) {
120+ for userArgsIndex , arg := range userContainer .Args {
121+ if arg == cacheDisabledArg {
122+ userContainer .Args = append (userContainer .Args [:userArgsIndex ], userContainer .Args [userArgsIndex + 1 :]... )
123+ break
124+ }
121125 }
122126 }
123- userContainer .Args = userArgs
124127 } else {
125- if len (userContainer .Args ) > 0 {
126- userContainer .Args = append (userContainer .Args , cacheDisabledArg )
127- } else {
128- userContainer .Args = []string {cacheDisabledArg }
128+ // Add cache_disabled arg if it doesn't exist
129+ if ! slices .Contains (userContainer .Args , cacheDisabledArg ) {
130+ if len (userContainer .Args ) > 0 {
131+ userContainer .Args = append (userContainer .Args , cacheDisabledArg )
132+ } else {
133+ userContainer .Args = []string {cacheDisabledArg }
134+ }
129135 }
130136 }
131137 template .InitContainers [index ].Args = userContainer .Args
0 commit comments