@@ -73,6 +73,7 @@ def affinity_spec(key, value):
7373 'topologyKey' : 'kubernetes.io/hostname'
7474 }
7575
76+
7677def affinity_preferred_spec (key , value , topology_key = 'kubernetes.io/hostname' , operator = 'In' ):
7778 """
7879 Generates a Kubernetes preferred affinity term.
@@ -192,17 +193,6 @@ def change_pod_manifest(self: KubeSpawner):
192193
193194 # set user quota cpu/mem usage if value has a "value" else don't change the value
194195
195- logging .info ("Setting user quota cpu/mem usage" )
196-
197- if self .cpu_guarantee is None : # This eventually comes from the current profile. Profile wins over user quota, if set.
198- set_key_value (self , key = "cpu_guarantee" , value = float (user_quotas .get ("quota-ws-guaranteecpu" )))
199- if self .cpu_limit is None :
200- set_key_value (self , key = "cpu_limit" , value = float (user_quotas .get ("quota-ws-maxcpu" )))
201- if self .mem_guarantee is None :
202- set_key_value (self , key = "mem_guarantee" , value = user_quotas .get ("quota-ws-guaranteemem" ), unit = "G" )
203- if self .mem_limit is None :
204- set_key_value (self , key = "mem_limit" , value = user_quotas .get ("quota-ws-maxmem" ), unit = "G" )
205-
206196 # Default value, might be overwritten by the app config
207197 self .storage_pvc_ensure = bool (self .pvc_name )
208198
@@ -256,6 +246,12 @@ def change_pod_manifest(self: KubeSpawner):
256246 except :
257247 logging .error ("Error loading Spawner extra configuration" , exc_info = True )
258248
249+ logging .info ("Setting user quota cpu/mem usage" )
250+
251+ set_key_value (self , key = "cpu_guarantee" , value = float (user_quotas .get ("quota-ws-guaranteecpu" , self .cpu_guarantee )))
252+ set_key_value (self , key = "cpu_limit" , value = float (user_quotas .get ("quota-ws-maxcpu" , self .cpu_limit )))
253+ set_key_value (self , key = "mem_guarantee" , value = user_quotas .get ("quota-ws-guaranteemem" , self .mem_guarantee ), unit = "G" )
254+ set_key_value (self , key = "mem_limit" , value = user_quotas .get ("quota-ws-maxmem" , self .mem_limit ), unit = "G" )
259255 # check if there is an applicationHook defined in the values.yaml
260256 # if so then execute the applicationHook function with "self" as parameter
261257 #
0 commit comments