@@ -54,6 +54,7 @@ class VeCPCRBuilderConfig(AutoSerializableMixin):
5454 cr_instance_name : str = field (default = AUTO_CREATE_VE , metadata = {"description" : "CR instance name" , "render_template" : True })
5555 cr_namespace_name : str = field (default = AUTO_CREATE_VE , metadata = {"description" : "CR namespace" , "render_template" : True })
5656 cr_repo_name : str = field (default = AUTO_CREATE_VE , metadata = {"description" : "CR repository name" })
57+ cr_auto_create_instance_type : str = field (default = "Micro" , metadata = {"description" : "CR instance type when auto-creating (Micro or Enterprise)" })
5758 cr_region : str = field (default = "cn-beijing" , metadata = {"description" : "CR region" })
5859
5960 cp_workspace_name : str = field (default = DEFAULT_WORKSPACE_NAME , metadata = {"description" : "Code Pipeline workspace name" })
@@ -224,7 +225,7 @@ def build(self, config: VeCPCRBuilderConfig) -> BuildResult:
224225 if 'pipeline_id' in resources :
225226 builder_config .cp_pipeline_id = resources ['pipeline_id' ]
226227
227- error_msg = f"Build failed: { str (e )} "
228+ error_msg = str (e )
228229
229230 return BuildResult (
230231 success = False ,
@@ -679,6 +680,10 @@ def _upload_to_tos(self, archive_path: str, config: VeCPCRBuilderConfig) -> str:
679680 return tos_url
680681
681682 except Exception as e :
683+ if "AccountDisable" in str (e ):
684+ raise Exception (f"Tos Service is not enabled, please enable it in the console. Enable services at: https://console.volcengine.com/agentkit/region:agentkit+cn-beijing/auth" )
685+ if "TooManyBuckets" in str (e ):
686+ raise Exception (f"You have reached the maximum number of buckets allowed. Please delete some buckets and try again." )
682687 raise Exception (f"Failed to upload to TOS: { str (e )} " )
683688
684689 def _prepare_cr_resources (self , config : VeCPCRBuilderConfig ) -> CRServiceConfig :
@@ -698,6 +703,7 @@ def _prepare_cr_resources(self, config: VeCPCRBuilderConfig) -> CRServiceConfig:
698703 instance_name = config .cr_instance_name ,
699704 namespace_name = config .cr_namespace_name ,
700705 repo_name = config .cr_repo_name ,
706+ auto_create_instance_type = config .cr_auto_create_instance_type ,
701707 region = config .cr_region
702708 )
703709
@@ -726,18 +732,24 @@ def config_updater(service: str, cr_config_dict: Dict[str, Any]) -> None:
726732 cr_result = cr_service .ensure_cr_resources (cr_config , common_config )
727733
728734 if not cr_result .success :
729- error_msg = f"CR resource preparation failed: { cr_result .error } "
730- self .reporter .error (error_msg )
731- raise Exception (error_msg )
735+ raise Exception (cr_result .error )
732736
733- # Ensure public endpoint access for image pulls
734- self .reporter .info ("Ensuring CR public endpoint access..." )
735- public_result = cr_service .ensure_public_endpoint (cr_config )
736-
737- if not public_result .success :
738- error_msg = f"Public endpoint configuration failed: { public_result .error } "
739- self .reporter .error (error_msg )
740- raise Exception (error_msg )
737+ # Ensure public endpoint access for image pulls (controlled by global config)
738+ try :
739+ from agentkit .toolkit .config .global_config import get_global_config
740+ gc = get_global_config ()
741+ do_check = getattr (getattr (gc , 'defaults' , None ), 'cr_public_endpoint_check' , None )
742+ except Exception :
743+ do_check = None
744+ if do_check is False :
745+ self .reporter .info ("Skipping CR public endpoint check per global config" )
746+ else :
747+ self .reporter .info ("Ensuring CR public endpoint access..." )
748+ public_result = cr_service .ensure_public_endpoint (cr_config )
749+
750+ if not public_result .success :
751+ error_msg = f"Public endpoint configuration failed: { public_result .error } "
752+ raise Exception (error_msg )
741753
742754 self .reporter .success ("CR resource preparation completed" )
743755 self .reporter .info (f" Instance: { cr_result .instance_name } " )
@@ -937,10 +949,10 @@ def _prepare_pipeline_resources(self, config: VeCPCRBuilderConfig, tos_url: str,
937949 {"Key" : "DOCKERFILE_PATH" , "Value" : "/workspace/agentkit-app/Dockerfile" , "Dynamic" : True , "Env" : True },
938950 {"Key" : "DOWNLOAD_PATH" , "Value" : "/workspace" , "Dynamic" : True , "Env" : True },
939951 {"Key" : "PROJECT_ROOT_DIR" , "Value" : "/workspace/agentkit-app" , "Dynamic" : True , "Env" : True },
940- {"Key" : "TOS_BUCKET_NAME" , "Value" : "" , "Dynamic" : True , "Env" : True },
952+ {"Key" : "TOS_BUCKET_NAME" , "Value" : "" , "Dynamic" : True },
953+ {"Key" : "TOS_REGION" , "Value" : "" , "Dynamic" : True },
941954 {"Key" : "TOS_PROJECT_FILE_NAME" , "Value" : "" , "Dynamic" : True , "Env" : True },
942955 {"Key" : "TOS_PROJECT_FILE_PATH" , "Value" : "" , "Dynamic" : True , "Env" : True },
943- {"Key" : "TOS_REGION" , "Value" : "" , "Dynamic" : True , "Env" : True },
944956 {"Key" : "CR_NAMESPACE" , "Value" : "" , "Dynamic" : True , "Env" : True },
945957 {"Key" : "CR_INSTANCE" , "Value" : "" , "Dynamic" : True , "Env" : True },
946958 {"Key" : "CR_DOMAIN" , "Value" : "" , "Dynamic" : True , "Env" : True },
@@ -1030,9 +1042,9 @@ def download_and_show_logs(run_id: str):
10301042 # Prepare build parameters for pipeline execution
10311043 build_parameters = [
10321044 {"Key" : "TOS_BUCKET_NAME" , "Value" : config .tos_bucket },
1045+ {"Key" : "TOS_REGION" , "Value" : config .tos_region },
10331046 {"Key" : "TOS_PROJECT_FILE_NAME" , "Value" : os .path .basename (config .tos_object_key )},
10341047 {"Key" : "TOS_PROJECT_FILE_PATH" , "Value" : config .tos_object_key },
1035- {"Key" : "TOS_REGION" , "Value" : config .tos_region },
10361048 {"Key" : "PROJECT_ROOT_DIR" , "Value" : f"/workspace/{ agent_name } " },
10371049 {"Key" : "DOWNLOAD_PATH" , "Value" : "/workspace" },
10381050 {"Key" : "DOCKERFILE_PATH" , "Value" : f"/workspace/{ agent_name } /Dockerfile" },
@@ -1128,4 +1140,4 @@ def download_and_show_logs(run_id: str):
11281140 return image_url
11291141
11301142 except Exception as e :
1131- raise Exception (f"Build execution failed: { str (e )} " )
1143+ raise Exception (f"Build execution failed: { str (e )} " )
0 commit comments