@@ -738,19 +738,27 @@ def _scale_pods(self, scale_types, release, app_settings):
738738 self .log (err , logging .ERROR )
739739 raise ServiceUnavailable (err ) from e
740740
741- def _set_default_config (self , config = None , procfile_types = None ):
742- procfile_types = self .procfile_types if procfile_types is None else procfile_types
741+ def _set_default_limit (self , config , procfile_type ):
742+ if procfile_type not in config .limits :
743+ plan = LimitPlan .get_default ()
744+ config .limits [procfile_type ] = plan .id
745+ config .save (update_fields = ['limits' ])
746+ return config
747+
748+ def _set_default_config (self ):
743749 plan = LimitPlan .get_default ()
744750 limits = {PROCFILE_TYPE_WEB : plan .id , PROCFILE_TYPE_RUN : plan .id }
745751 try :
746- config = self .config_set .latest () if config is None else config
747- for procfile_type in procfile_types :
748- limits [procfile_type ] = config .limits .get (procfile_type , plan .id )
749- if limits != config .limits :
750- config .limits = limits
751- config .save (update_fields = ['limits' ])
752+ config = self .config_set .latest ()
753+ limits [PROCFILE_TYPE_WEB ] = config .limits .get (PROCFILE_TYPE_WEB , plan .id )
754+ limits [PROCFILE_TYPE_RUN ] = config .limits .get (PROCFILE_TYPE_RUN , plan .id )
752755 except Config .DoesNotExist :
753756 config = Config .objects .create (owner = self .owner , app = self , limits = limits )
757+ for procfile_type in self .procfile_types :
758+ limits [procfile_type ] = config .limits .get (procfile_type , plan .id )
759+ if limits != config .limits :
760+ config .limits = limits
761+ config .save (update_fields = ['limits' ])
754762 return config
755763
756764 def _create_default_ingress (self , target_port ):
@@ -993,9 +1001,8 @@ def _gather_app_settings(self, release, app_settings, procfile_type, replicas, v
9931001 """
9941002
9951003 envs = self ._build_env_vars (release )
996- config = release .config
9971004 # Obtain a limit plan that must exist, if raise error here, it must be a bug
998- self ._set_default_config ( config , procfile_types = [ procfile_type ] )
1005+ config = self ._set_default_limit ( release . config , procfile_type )
9991006 limit_plan = LimitPlan .objects .get (id = config .limits .get (procfile_type ))
10001007
10011008 # see if the app config has deploy batch preference, otherwise use global
0 commit comments