@@ -153,13 +153,8 @@ func ParseAndValidateConfig(v *viper.Viper) (*config.Config, error) {
153153 }
154154
155155 if cfg .PodSpecPatch != nil {
156- for _ , c := range cfg .PodSpecPatch .Containers {
157- if c .Image != strings .ToLower (c .Image ) {
158- return nil , fmt .Errorf ("container image contains uppercase letters: %s" , c .Image )
159- }
160- if len (c .Command ) != 0 || len (c .Args ) != 0 {
161- return nil , scheduler .ErrNoCommandModification
162- }
156+ if err := processPodSpecPatch (cfg .PodSpecPatch ); err != nil {
157+ return nil , fmt .Errorf ("invalid pod spec patch: %w" , err )
163158 }
164159 }
165160
@@ -181,6 +176,29 @@ func ParseAndValidateConfig(v *viper.Viper) (*config.Config, error) {
181176 return cfg , nil
182177}
183178
179+ func processPodSpecPatch (podSpec * corev1.PodSpec ) error {
180+ for idx , c := range podSpec .Containers {
181+ if c .Image != strings .ToLower (c .Image ) {
182+ return fmt .Errorf ("container image for container at index %d contains uppercase letters: %s" , idx , c .Image )
183+ }
184+
185+ if len (c .Command ) != 0 || len (c .Args ) != 0 {
186+ return fmt .Errorf ("container at index %d (image: %s): %w" , idx , c .Image , scheduler .ErrNoCommandModification )
187+ }
188+
189+ var err error
190+ if podSpec .Containers [idx ].Resources .Requests , err = recapitalizeHugePagesResourceMap (c .Resources .Requests ); err != nil {
191+ return fmt .Errorf ("processing resource requests for container at index %d (image: %s): %w" , idx , c .Image , err )
192+ }
193+
194+ if podSpec .Containers [idx ].Resources .Limits , err = recapitalizeHugePagesResourceMap (c .Resources .Limits ); err != nil {
195+ return fmt .Errorf ("processing resource limits for container at index %d (image: %s): %w" , idx , c .Image , err )
196+ }
197+ }
198+
199+ return nil
200+ }
201+
184202// Viper downcases keys in maps used in inputs, but in the case of resource classes where hugepages are used, it
185203// gets downcased to "hugepages-2mi". This function fixes that by recapitlizing the "Mi" part for any hugepages resource
186204// claims. This is important because the hugepages resource name must be capitalized as "hugepages-2Mi" (or similar),
0 commit comments