From fd69318ce7bb5f9dcc23075ef06c470080517be2 Mon Sep 17 00:00:00 2001 From: Anna <2496253516@qq.com> Date: Tue, 26 Nov 2024 15:16:17 +0800 Subject: [PATCH] feat: tenant version database upgrader --story=120234234 --- src/common/index/collections/apitask.go | 72 +- .../index/collections/applicationbase.go | 57 +- src/common/index/collections/asstdes.go | 37 +- src/common/index/collections/auditlog.go | 56 +- src/common/index/collections/business_set.go | 6 +- src/common/index/collections/delarchive.go | 93 +- src/common/index/collections/dynamicgroup.go | 41 +- .../index/collections/field_template.go | 2 +- .../index/collections/full_sync_cond.go | 4 +- src/common/index/collections/hostapplyrule.go | 60 +- src/common/index/collections/hostbase.go | 176 +- src/common/index/collections/hostlock.go | 17 +- src/common/index/collections/kube.go | 104 +- src/common/index/collections/manager.go | 13 +- src/common/index/collections/modulebase.go | 119 +- .../index/collections/modulehostconfig.go | 82 +- .../collections/obj_attr_des_template.go | 2 +- src/common/index/collections/objasst.go | 57 +- src/common/index/collections/objattdes.go | 55 +- .../index/collections/objclassification.go | 18 +- src/common/index/collections/objdes.go | 36 +- .../collections/object_unique_template.go | 2 +- .../index/collections/objectbasemapping.go | 2 +- src/common/index/collections/objectunique.go | 27 +- src/common/index/collections/platbase.go | 31 +- src/common/index/collections/process.go | 40 +- .../collections/processinstancerelation.go | 77 +- .../index/collections/processtemplate.go | 49 +- src/common/index/collections/project.go | 10 +- src/common/index/collections/propertygroup.go | 79 +- .../index/collections/servicecategory.go | 32 +- .../index/collections/serviceinstance.go | 81 +- .../index/collections/servicetemplate.go | 50 +- .../index/collections/servicetemplateattr.go | 5 +- src/common/index/collections/setbase.go | 83 +- .../collections/setservicetemplaterelation.go | 29 +- src/common/index/collections/settemplate.go | 31 +- .../index/collections/settemplateattr.go | 5 +- src/common/index/collections/topographics.go | 15 +- src/scene_server/admin_server/iam/synciam.go | 4 +- src/scene_server/admin_server/imports.go | 185 +- src/scene_server/admin_server/logics/index.go | 10 +- .../admin_server/service/migrate.go | 35 +- .../admin_server/service/service.go | 6 + .../admin_server/service/tenant_upgrader.go | 64 + .../admin_server/upgrader/common.go | 52 + .../upgrader/{ => history}/compare.go | 2 +- .../upgrader/{ => history}/configadmin.go | 2 +- .../upgrader/{ => history}/doc.go | 2 +- .../admin_server/upgrader/history/register.go | 387 ++ .../admin_server/upgrader/history/upgrader.go | 2 + .../upgrader/{ => history}/util.go | 2 +- .../upgrader/history/v3.0.8/addDefauleApp.go | 13 +- .../upgrader/history/v3.0.8/addPlatData.go | 6 +- .../history/v3.0.8/addPresetObjects.go | 24 +- .../upgrader/history/v3.0.8/addSystemData.go | 4 +- .../upgrader/history/v3.0.8/createtable.go | 4 +- .../upgrader/history/v3.0.8/pkg.go | 6 +- .../upgrader/history/v3.0.8/upgradeBKBiz.go | 12 +- .../v3.0.9-beta.1/fixes_supplier_account.go | 4 +- .../upgrader/history/v3.0.9-beta.1/pkg.go | 6 +- .../v3.0.9-beta.3/fixes_port_pattern.go | 6 +- .../upgrader/history/v3.0.9-beta.3/pkg.go | 6 +- .../v3.1.0-alpha.2/addBkStartParamRegex.go | 8 +- .../upgrader/history/v3.1.0-alpha.2/pkg.go | 6 +- .../upgrader/history/x08.09.04.01/pkg.go | 6 +- .../x08.09.04.01/updateSystemProperty.go | 6 +- .../x08.09.17.01/create_table_netcollect.go | 4 +- .../upgrader/history/x08.09.17.01/pkg.go | 6 +- .../upgrader/history/x08.09.18.01/pkg.go | 6 +- .../upgrader/history/x08.09.18.01/upgrader.go | 4 +- .../upgrader/history/x08.09.26.01/pkg.go | 6 +- .../upgrader/history/x08.09.26.01/upgrader.go | 4 +- .../upgrader/history/x18.09.30.01/pkg.go | 6 +- .../upgrader/history/x18.09.30.01/upgrader.go | 4 +- .../upgrader/history/x18.10.10.01/pkg.go | 6 +- .../upgrader/history/x18.10.10.01/procsrv.go | 8 +- .../history/x18.10.30.01/association.go | 14 +- .../upgrader/history/x18.10.30.01/pkg.go | 6 +- .../upgrader/history/x18.11.19.01/pkg.go | 6 +- .../history/x18.11.19.01/reconcil_unique.go | 8 +- .../history/x18.12.12.01/add_aix_property.go | 4 +- .../upgrader/history/x18.12.12.01/pkg.go | 6 +- .../history/x18.12.12.01/reconcil_unique.go | 6 +- .../history/x18.12.12.01/set_tcp_default.go | 4 +- .../fix_module_name_property_group.go | 4 +- .../upgrader/history/x18.12.12.02/pkg.go | 6 +- .../x18.12.12.03/fixAssociationTypeName.go | 4 +- .../x18.12.12.03/fixEventSubscribeLastTime.go | 4 +- .../upgrader/history/x18.12.12.03/pkg.go | 6 +- .../x18.12.12.04/fix_bk_obj_asst_id.go | 4 +- .../upgrader/history/x18.12.12.04/pkg.go | 6 +- .../upgrader/history/x18.12.12.05/pkg.go | 6 +- .../x18.12.12.05/remove_deleted_inst_asst.go | 6 +- .../upgrader/history/x18.12.12.06/pkg.go | 6 +- .../history/x18.12.12.06/reconcil_unique.go | 6 +- .../x18.12.13.01/addswitchAssociation.go | 8 +- .../upgrader/history/x18.12.13.01/pkg.go | 6 +- .../history/x19.01.18.01/drop_index.go | 4 +- .../upgrader/history/x19.01.18.01/pkg.go | 6 +- .../x19.02.15.10/fixAssociationTypeName.go | 4 +- .../x19.02.15.10/fixEventSubscribeLastTime.go | 4 +- .../upgrader/history/x19.02.15.10/pkg.go | 6 +- .../upgrader/history/x19.04.16.01/pkg.go | 6 +- .../x19.04.16.01/removeDescriptionField.go | 4 +- .../upgrader/history/x19.04.16.02/pkg.go | 6 +- .../history/x19.04.16.02/updateFranceName.go | 4 +- .../upgrader/history/x19.04.16.03/pkg.go | 6 +- .../x19.04.16.03/updateAttributeCreateTime.go | 4 +- .../x19.05.16.01/add_default_category.go | 4 +- .../x19.05.16.01/add_inner_category.go | 4 +- .../x19.05.16.01/add_module_property.go | 8 +- .../x19.05.16.01/change_process_name.go | 4 +- .../history/x19.05.16.01/create_table.go | 4 +- .../upgrader/history/x19.05.16.01/pkg.go | 6 +- .../x19.05.16.01/update_process_property.go | 40 +- .../x19.05.16.01/upgrade_service_template.go | 6 +- .../upgrader/history/x19.08.19.01/pkg.go | 6 +- .../remove_proc_fresh_instance.go | 4 +- .../history/x19.08.19.01/update_ip_regex.go | 4 +- .../delete_host_plat_association.go | 4 +- .../upgrader/history/x19.08.20.01/pkg.go | 6 +- .../fix_service_instance_max_id.go | 4 +- .../upgrader/history/x19.08.26.02/pkg.go | 7 +- .../model_attr_group_collapse_flag.go | 4 +- .../upgrader/history/x19.09.03.01/pkg.go | 7 +- .../update_set_description_property.go | 4 +- .../upgrader/history/x19.09.03.02/pkg.go | 6 +- ...et_module_set_template_field_uneditable.go | 4 +- .../upgrader/history/x19.09.03.03/pkg.go | 6 +- ...et_module_set_template_field_uneditable.go | 8 +- .../upgrader/history/x19.09.03.04/pkg.go | 6 +- ...et_module_set_template_field_uneditable.go | 4 +- .../x19.09.03.05/create_inst_name_index.go | 4 +- .../x19.09.03.05/create_object_id_index.go | 4 +- .../upgrader/history/x19.09.03.05/pkg.go | 6 +- .../upgrader/history/x19.09.03.06/pkg.go | 6 +- .../update_proc_start_param_placeholder.go | 4 +- .../update_set_description_field_type.go | 4 +- .../upgrader/history/x19.09.03.07/pkg.go | 6 +- .../history/x19.09.03.07/remove_metadata.go | 10 +- .../upgrader/history/x19.09.03.08/pkg.go | 6 +- .../x19.09.03.08/update_process_property.go | 4 +- .../upgrader/history/x19.10.22.01/pkg.go | 6 +- .../history/x19.10.22.01/update_cpu_unit.go | 4 +- .../history/x19.10.22.02/add_host_index.go | 4 +- .../upgrader/history/x19.10.22.02/pkg.go | 6 +- .../upgrader/history/x19.10.22.03/pkg.go | 6 +- .../remove_mainline_property_required.go | 4 +- .../upgrader/history/x20.01.13.01/pkg.go | 6 +- .../update_none_property_group.go | 4 +- .../x20.02.17.01/fix_proctemp_procname.go | 4 +- .../upgrader/history/x20.02.17.01/pkg.go | 6 +- .../drop_plat_vpcid_index.go | 4 +- .../y3.10.202104221702/inner_object_index.go | 4 +- .../y3.10.202104221702/mapping.go | 4 +- .../{ => history}/y3.10.202104221702/pkg.go | 6 +- .../y3.10.202104221702/split_inst_table.go | 4 +- .../{ => history}/y3.10.202105251041/pkg.go | 6 +- .../unqiue_index_delete_must_check.go | 4 +- .../{ => history}/y3.10.202105261459/pkg.go | 6 +- .../update_config_admin.go | 10 +- .../y3.10.202106031151/add_unix_property.go | 4 +- .../{ => history}/y3.10.202106031151/pkg.go | 6 +- .../update_process_pri_range.go | 4 +- .../drop_set_template_version_column.go | 6 +- .../{ => history}/y3.10.202107011735/pkg.go | 6 +- .../change_host_attr_editable.go | 4 +- .../{ => history}/y3.10.202107021056/pkg.go | 6 +- .../{ => history}/y3.10.202107161611/pkg.go | 6 +- .../y3.10.202107161611/proc_bind_change.go | 4 +- .../y3.10.202107271945/delete_history_task.go | 4 +- .../{ => history}/y3.10.202107271945/pkg.go | 6 +- .../add_solaris_property.go | 4 +- .../{ => history}/y3.10.202107301510/pkg.go | 6 +- .../{ => history}/y3.10.202107311844/pkg.go | 6 +- .../set_proc_bind_ip_not_reuqired.go | 4 +- .../migrate_iam_sysinstances.go | 4 +- .../{ => history}/y3.10.202109131607/pkg.go | 6 +- .../{ => history}/y3.10.202109131607/util.go | 0 .../migrate_svc_inst_id_to_proc.go | 8 +- .../{ => history}/y3.10.202109181134/pkg.go | 6 +- .../y3.10.202112071130/migrate_api_task.go | 6 +- .../{ => history}/y3.10.202112071130/pkg.go | 6 +- .../{ => history}/y3.10.202112071431/pkg.go | 6 +- .../y3.10.202112071431}/updateAdminConfigc.go | 12 +- .../add_bind_info_option.go | 4 +- .../{ => history}/y3.10.202112171521/pkg.go | 6 +- .../y3.10.202203011516/add_biz_set.go | 12 +- .../{ => history}/y3.10.202203011516/pkg.go | 6 +- .../y3.10.202203021455/add_classification.go | 6 +- .../{ => history}/y3.10.202203021455/pkg.go | 6 +- .../add_agent_id_and_ipv6_attr.go | 8 +- .../{ => history}/y3.10.202203031512/pkg.go | 6 +- .../y3.10.202204181447/add_business_set.go | 4 +- .../{ => history}/y3.10.202204181447/pkg.go | 6 +- .../{ => history}/y3.10.202204271725/pkg.go | 6 +- .../service_template_host_apply.go | 6 +- .../{ => history}/y3.10.202205182148/pkg.go | 6 +- .../y3.10.202205182148/update_business_set.go | 4 +- .../init_template_attribute.go | 0 .../{ => history}/y3.10.202206081408/pkg.go | 6 +- .../add_host_favourite_type_column.go | 4 +- .../{ => history}/y3.10.202208032125/pkg.go | 6 +- .../add_cloud_host_related_attr.go | 6 +- .../{ => history}/y3.10.202209231617/pkg.go | 6 +- .../init_kube_collection.go | 0 .../{ => history}/y3.10.202209281408/pkg.go | 6 +- .../objattrdes_ismultichoice.go | 6 +- .../{ => history}/y3.10.202302031117/pkg.go | 6 +- .../y3.10.202302062350/add_project.go | 12 +- .../{ => history}/y3.10.202302062350/pkg.go | 6 +- .../add_freebsd_property.go | 0 .../{ => history}/y3.10.202303072103/pkg.go | 6 +- .../{ => history}/y3.10.202303301611/pkg.go | 6 +- .../update_host_outeripv6_option.go | 0 .../update_process_ipv6attr_option.go | 0 .../y3.10.202303301718/objattrdes_default.go | 4 +- .../{ => history}/y3.10.202303301718/pkg.go | 6 +- .../add_model_quote_relation.go | 4 +- .../{ => history}/y3.10.202304012150/pkg.go | 6 +- .../add_agent_id_related_attr.go | 12 +- .../{ => history}/y3.10.202305110949/pkg.go | 6 +- .../{ => history}/y3.10.202305151505/pkg.go | 6 +- .../update_bk_cloud_word.go | 5 +- .../y3.10.202307171520/add_field_template.go | 0 .../add_template_id_column.go | 0 .../{ => history}/y3.10.202307171520/pkg.go | 6 +- .../delete_host_apply_rule.go | 0 .../{ => history}/y3.11.202309050900/pkg.go | 6 +- .../init_shared_cluster_table.go | 0 .../{ => history}/y3.12.202309211735/pkg.go | 6 +- .../y3.12.202310301633/add_recorded_fields.go | 6 +- .../{ => history}/y3.12.202310301633/pkg.go | 6 +- .../y3.12.202310302130/add_business_set.go | 4 +- .../{ => history}/y3.12.202310302130/pkg.go | 6 +- .../add_sort_number_column.go | 0 .../{ => history}/y3.12.202311061800/pkg.go | 6 +- .../y3.13.202401221600/encode_pod_label.go | 0 .../{ => history}/y3.13.202401221600/pkg.go | 6 +- .../{ => history}/y3.13.202402181900/pkg.go | 6 +- .../update_biz_set_desc_field.go | 0 .../migrate_inner_classification.go | 4 +- .../{ => history}/y3.13.202402191140/pkg.go | 6 +- .../y3.13.202402281158/add_mac_os_type.go | 0 .../{ => history}/y3.13.202402281158/pkg.go | 6 +- .../migrate_host_message.go | 4 +- .../{ => history}/y3.13.202403151855/pkg.go | 6 +- .../add_unassigned_cloud_area.go | 4 +- .../change_default_area_default_field.go | 4 +- .../{ => history}/y3.13.202404221100/pkg.go | 6 +- .../y3.13.202404221100/update_host_field.go | 4 +- .../add_cloud_region_zone_attr.go | 4 +- .../{ => history}/y3.13.202405080955/pkg.go | 6 +- .../{ => history}/y3.13.202407191507/pkg.go | 6 +- .../y3.13.202407191507/upgrade_container.go | 4 +- .../y3.13.202407191507/upgrade_del_archive.go | 4 +- .../y3.13.202408011044/del_kube_audit.go | 4 +- .../{ => history}/y3.13.202408011044/pkg.go | 6 +- .../{ => history}/y3.13.202408071435/pkg.go | 6 +- .../y3.13.202408071435/update_config_admin.go | 4 +- .../add_pod_table_node_index.go | 0 .../{ => history}/y3.13.202410091435/pkg.go | 6 +- .../init_full_sync_cond_table.go | 0 .../{ => history}/y3.14.202404031701/pkg.go | 6 +- .../y3.14.202405141035/add_self_incr_id.go | 4 +- .../{ => history}/y3.14.202405141035/pkg.go | 6 +- .../{ => history}/y3.14.202410100930/pkg.go | 6 +- .../y3.14.202410100930/updateAdminConfigc.go | 4 +- .../y3.6.201909062359/add_module_property.go | 6 +- .../y3.6.201909062359/add_set_property.go | 6 +- .../history/y3.6.201909062359/create_table.go | 4 +- .../initialize_set_template_field.go | 4 +- .../upgrader/history/y3.6.201909062359/pkg.go | 6 +- .../upgrader/history/y3.6.201909272359/pkg.go | 6 +- .../history/y3.6.201909272359/task.go | 4 +- .../upgrader/history/y3.6.201910091234/pkg.go | 6 +- .../settemplate_sync_status.go | 4 +- .../y3.6.201911121930/add_recycle_module.go | 10 +- .../upgrader/history/y3.6.201911121930/pkg.go | 6 +- .../upgrader/history/y3.6.201911122106/pkg.go | 6 +- .../set_process_auto_start.go | 4 +- .../upgrader/history/y3.6.201911141015/pkg.go | 6 +- .../y3.6.201911141015/remove_metadata.go | 12 +- .../obj_host_add_field_type_list.go | 6 +- .../upgrader/history/y3.6.201911141516/pkg.go | 6 +- .../history/y3.6.201911261109/create_table.go | 6 +- .../history/y3.6.201911261109/init_chart.go | 4 +- .../upgrader/history/y3.6.201911261109/pkg.go | 6 +- .../upgrader/history/y3.6.201912241627/pkg.go | 6 +- .../sort_bk_property_index.go | 6 +- .../init_host_property_apply.go | 4 +- .../upgrader/history/y3.7.201911141719/pkg.go | 6 +- .../add_host_outer_ip_unique.go | 4 +- .../upgrader/history/y3.7.201912121117/pkg.go | 6 +- .../add_set_template_version.go | 10 +- .../upgrader/history/y3.7.201912171427/pkg.go | 6 +- .../add_bk_port_enable_property.go | 10 +- .../upgrader/history/y3.7.202002231026/pkg.go | 6 +- .../create_audit_log_table.go | 6 +- .../upgrader/history/y3.8.202001172032/pkg.go | 6 +- .../y3.8.202002101113/migrate_event_id.go | 4 +- .../upgrader/history/y3.8.202002101113/pkg.go | 6 +- .../add_bk_port_enable_property.go | 6 +- .../upgrader/history/y3.8.202004141131/pkg.go | 6 +- .../add_proc_gateway_attr.go | 10 +- .../upgrader/history/y3.8.202004151435/pkg.go | 6 +- .../fix_set_template_version_time_empty.go | 4 +- .../upgrader/history/y3.8.202004241035/pkg.go | 6 +- .../history/y3.8.202004291536/add_index.go | 10 +- .../upgrader/history/y3.8.202004291536/pkg.go | 6 +- .../add_service_instance_index.go | 4 +- .../upgrader/history/y3.8.202006021120/pkg.go | 6 +- .../y3.8.202006092135/init_config_admin.go | 6 +- .../upgrader/history/y3.8.202006092135/pkg.go | 6 +- .../create_table_del_archive.go | 4 +- .../upgrader/history/y3.8.202006231730/pkg.go | 6 +- .../change_host_ip_user_to_array.go | 4 +- .../upgrader/history/y3.8.202006241144/pkg.go | 6 +- .../change_attr_sla_editable.go | 4 +- .../upgrader/history/y3.8.202006281530/pkg.go | 6 +- .../change_bk_mainlin_set_biz_asst.go | 4 +- .../upgrader/history/y3.8.202007011748/pkg.go | 6 +- .../y3.8.202008051650/add_module_attr.go | 6 +- .../upgrader/history/y3.8.202008051650/pkg.go | 6 +- .../upgrader/history/y3.8.202008111026/pkg.go | 6 +- .../remove_bk_supplier_id.go | 4 +- .../y3.8.202008241747/addCpuMemDiskUnit.go | 4 +- .../upgrader/history/y3.8.202008241747/pkg.go | 6 +- .../upgrader/history/y3.8.202009101702/pkg.go | 6 +- .../y3.8.202009101702/proc_bind_change.go | 10 +- .../y3.9.202002131522/add_cloud_host_attr.go | 7 +- .../y3.9.202002131522/add_cloud_host_index.go | 4 +- .../add_cloud_host_unique.go | 4 +- .../add_cloud_sync_tables.go | 6 +- .../y3.9.202002131522/add_plat_index.go | 4 +- .../y3.9.202002131522/add_plat_unique_key.go | 4 +- .../y3.9.202002131522/init_plat_attr.go | 6 +- .../{ => history}/y3.9.202002131522/pkg.go | 6 +- .../y3.9.202002131522/remove_old_tables.go | 0 .../remove_resource_fault_recycle.go | 5 +- .../y3.9.202002131522/upgrade_cloud_area.go | 4 +- .../change_metadata_to_bizid.go | 4 +- .../{ => history}/y3.9.202008101530/pkg.go | 6 +- .../add_objectl_field_ishidden.go | 4 +- .../{ => history}/y3.9.202008121631/pkg.go | 6 +- .../{ => history}/y3.9.202008172134/pkg.go | 6 +- .../y3.9.202008172134/update_audit_table.go | 4 +- .../y3.9.202010131456/create_table.go | 4 +- .../y3.9.202010131456/migrate_history.go | 4 +- .../{ => history}/y3.9.202010131456/pkg.go | 6 +- .../add_bizid_on_common_attr.go | 4 +- .../{ => history}/y3.9.202010151455/pkg.go | 6 +- .../y3.9.202010151650/add_cloudid_index.go | 4 +- .../{ => history}/y3.9.202010151650/pkg.go | 6 +- .../y3.9.202010211805/add_host_lock_table.go | 6 +- .../{ => history}/y3.9.202010211805/pkg.go | 6 +- .../{ => history}/y3.9.202010281615/pkg.go | 6 +- .../y3.9.202010281615/update_inst_time_val.go | 4 +- .../y3.9.202011021415/create_unique_index.go | 4 +- .../{ => history}/y3.9.202011021415/pkg.go | 6 +- .../change_attr_bkosType_editable.go | 4 +- .../{ => history}/y3.9.202011021501/pkg.go | 6 +- .../y3.9.202011171550/change_process_attr.go | 12 +- .../{ => history}/y3.9.202011171550/pkg.go | 6 +- .../{ => history}/y3.9.202011172152/pkg.go | 6 +- .../y3.9.202011172152/remove_field.go | 4 +- .../y3.9.202011192014/change_unique_index.go | 4 +- .../{ => history}/y3.9.202011192014/pkg.go | 6 +- .../{ => history}/y3.9.202011201146/pkg.go | 6 +- .../remove_redundant_items.go | 4 +- .../add_bizid_on_self_defined_node.go | 4 +- .../{ => history}/y3.9.202011241510/pkg.go | 6 +- .../{ => history}/y3.9.202011251014/pkg.go | 6 +- .../y3.9.202011251014/proc_bind_change.go | 10 +- .../{ => history}/y3.9.202011301723/pkg.go | 6 +- .../y3.9.202011301723/remove_default_field.go | 4 +- .../change_proc_attr_index.go | 6 +- .../{ => history}/y3.9.202012011450/pkg.go | 6 +- .../add_del_archive_index.go | 6 +- .../{ => history}/y3.9.202101061721/pkg.go | 6 +- .../y3.9.202102011055/add_os_type_index.go | 4 +- .../{ => history}/y3.9.202102011055/pkg.go | 6 +- .../add_instass_proc_index.go | 4 +- .../{ => history}/y3.9.202102261105/pkg.go | 6 +- .../{ => history}/y3.9.202103031533/pkg.go | 6 +- .../remove_bk_cpu_mhz_field.go | 4 +- .../{ => history}/y3.9.202103231621/pkg.go | 6 +- .../update_host_empty_special_field.go | 4 +- .../add_bk_cpu_architecture_attr.go | 4 +- .../{ => history}/y3.9.202104011012/pkg.go | 6 +- .../change_set_unique_index.go | 4 +- .../{ => history}/y3.9.202104211151/pkg.go | 6 +- .../{ => history}/y3.9.202105261459/pkg.go | 6 +- .../y3.9.202105261459}/update_config_admin.go | 10 +- .../y3.9.202106031151/add_unix_property.go | 4 +- .../{ => history}/y3.9.202106031151/pkg.go | 6 +- .../update_process_pri_range.go | 7 +- .../{ => history}/y3.9.202106291420/index.go | 4 +- .../{ => history}/y3.9.202106291420/pkg.go | 6 +- .../change_host_attr_editable.go | 4 +- .../{ => history}/y3.9.202106301910/pkg.go | 6 +- .../drop_set_template_version_column.go | 6 +- .../{ => history}/y3.9.202107011154/pkg.go | 6 +- .../{ => history}/y3.9.202107161611/pkg.go | 6 +- .../y3.9.202107161611/proc_bind_change.go | 4 +- .../y3.9.202107271940/delete_history_task.go | 4 +- .../{ => history}/y3.9.202107271940/pkg.go | 6 +- .../y3.9.202107301510/add_solaris_property.go | 4 +- .../{ => history}/y3.9.202107301510/pkg.go | 6 +- .../{ => history}/y3.9.202107311844/pkg.go | 6 +- .../set_proc_bind_ip_not_reuqired.go | 4 +- .../y3.9.202112061431/add_bind_info_option.go | 4 +- .../{ => history}/y3.9.202112061431/pkg.go | 6 +- .../y3.9.202112071130/migrate_api_task.go | 6 +- .../{ => history}/y3.9.202112071130/pkg.go | 6 +- .../{ => history}/y3.9.202112071431/pkg.go | 6 +- .../y3.9.202112071431}/updateAdminConfigc.go | 12 +- .../admin_server/upgrader/register.go | 385 +- .../upgrader/tools/create_index.go | 68 + .../upgrader/tools/create_table.go | 45 + .../admin_server/upgrader/upgrader.go | 62 +- .../admin_server/upgrader/utils.go | 40 + .../data/add_applicationbase_data.go | 237 + .../data/add_asstdes_data.go | 109 + .../data/add_bizsetbase_data.go | 98 + .../data/add_idgenerator_data.go | 86 + .../data/add_modulebase_data.go | 164 + .../data/add_objAttDesc_data.go | 246 + .../data/add_objasst_data.go | 88 + .../data/add_objclassfication_data.go | 98 + .../data/add_objdes_data.go | 217 + .../data/add_objectunique_data.go | 234 + .../data/add_platbase_data.go | 105 + .../data/add_propertygroup_data.go | 245 + .../data/add_servicecategory_data.go | 204 + .../data/add_setbase_data.go | 57 + .../y3.15.202411071530/data/add_systemdata.go | 70 + .../y3.15.202411071530/data/objAttDescData.go | 4268 +++++++++++++++++ .../upgrader/y3.15.202411071530/indexes.go | 2249 +++++++++ .../upgrader/y3.15.202411071530/initdata.go | 35 + .../upgrader/y3.15.202411071530/pkg.go | 31 + .../y3.15.202411071530/tableIndexMap.go | 144 + .../coreservice/core/model/attribute_curd.go | 3 +- 444 files changed, 11710 insertions(+), 2405 deletions(-) create mode 100644 src/scene_server/admin_server/service/tenant_upgrader.go create mode 100644 src/scene_server/admin_server/upgrader/common.go rename src/scene_server/admin_server/upgrader/{ => history}/compare.go (99%) rename src/scene_server/admin_server/upgrader/{ => history}/configadmin.go (99%) rename src/scene_server/admin_server/upgrader/{ => history}/doc.go (98%) create mode 100644 src/scene_server/admin_server/upgrader/history/register.go create mode 100644 src/scene_server/admin_server/upgrader/history/upgrader.go rename src/scene_server/admin_server/upgrader/{ => history}/util.go (99%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202104221702/drop_plat_vpcid_index.go (92%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202104221702/inner_object_index.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202104221702/mapping.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202104221702/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202104221702/split_inst_table.go (99%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202105251041/pkg.go (81%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202105251041/unqiue_index_delete_must_check.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202105261459/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{y3.9.202105261459 => history/y3.10.202105261459}/update_config_admin.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202106031151/add_unix_property.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202106031151/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202106031151/update_process_pri_range.go (90%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107011735/drop_set_template_version_column.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107011735/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107021056/change_host_attr_editable.go (92%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107021056/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107161611/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107161611/proc_bind_change.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107271945/delete_history_task.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107271945/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107301510/add_solaris_property.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107301510/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107311844/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202107311844/set_proc_bind_ip_not_reuqired.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202109131607/migrate_iam_sysinstances.go (99%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202109131607/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202109131607/util.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202109181134/migrate_svc_inst_id_to_proc.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202109181134/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202112071130/migrate_api_task.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202112071130/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202112071431/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{y3.9.202112071431 => history/y3.10.202112071431}/updateAdminConfigc.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202112171521/add_bind_info_option.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202112171521/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202203011516/add_biz_set.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202203011516/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202203021455/add_classification.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202203021455/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202203031512/add_agent_id_and_ipv6_attr.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202203031512/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202204181447/add_business_set.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202204181447/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202204271725/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202204271725/service_template_host_apply.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202205182148/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202205182148/update_business_set.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202206081408/init_template_attribute.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202206081408/pkg.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202208032125/add_host_favourite_type_column.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202208032125/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202209231617/add_cloud_host_related_attr.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202209231617/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202209281408/init_kube_collection.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202209281408/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202302031117/objattrdes_ismultichoice.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202302031117/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202302062350/add_project.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202302062350/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202303072103/add_freebsd_property.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202303072103/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202303301611/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202303301611/update_host_outeripv6_option.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202303301611/update_process_ipv6attr_option.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202303301718/objattrdes_default.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202303301718/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202304012150/add_model_quote_relation.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202304012150/pkg.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202305110949/add_agent_id_related_attr.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202305110949/pkg.go (90%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202305151505/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202305151505/update_bk_cloud_word.go (92%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202307171520/add_field_template.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202307171520/add_template_id_column.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.10.202307171520/pkg.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.11.202309050900/delete_host_apply_rule.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.11.202309050900/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202309211735/init_shared_cluster_table.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202309211735/pkg.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202310301633/add_recorded_fields.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202310301633/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202310302130/add_business_set.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202310302130/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202311061800/add_sort_number_column.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.12.202311061800/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202401221600/encode_pod_label.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202401221600/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202402181900/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202402181900/update_biz_set_desc_field.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202402191140/migrate_inner_classification.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202402191140/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202402281158/add_mac_os_type.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202402281158/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202403151855/migrate_host_message.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202403151855/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202404221100/add_unassigned_cloud_area.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202404221100/change_default_area_default_field.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202404221100/pkg.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202404221100/update_host_field.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202405080955/add_cloud_region_zone_attr.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202405080955/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202407191507/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202407191507/upgrade_container.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202407191507/upgrade_del_archive.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202408011044/del_kube_audit.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202408011044/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202408071435/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202408071435/update_config_admin.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202410091435/add_pod_table_node_index.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.13.202410091435/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.14.202404031701/init_full_sync_cond_table.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.14.202404031701/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.14.202405141035/add_self_incr_id.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.14.202405141035/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.14.202410100930/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.14.202410100930/updateAdminConfigc.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/add_cloud_host_attr.go (90%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/add_cloud_host_index.go (91%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/add_cloud_host_unique.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/add_cloud_sync_tables.go (90%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/add_plat_index.go (92%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/add_plat_unique_key.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/init_plat_attr.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/pkg.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/remove_old_tables.go (100%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/remove_resource_fault_recycle.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202002131522/upgrade_cloud_area.go (92%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202008101530/change_metadata_to_bizid.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202008101530/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202008121631/add_objectl_field_ishidden.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202008121631/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202008172134/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202008172134/update_audit_table.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010131456/create_table.go (92%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010131456/migrate_history.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010131456/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010151455/add_bizid_on_common_attr.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010151455/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010151650/add_cloudid_index.go (90%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010151650/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010211805/add_host_lock_table.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010211805/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010281615/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202010281615/update_inst_time_val.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011021415/create_unique_index.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011021415/pkg.go (80%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011021501/change_attr_bkosType_editable.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011021501/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011171550/change_process_attr.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011171550/pkg.go (88%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011172152/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011172152/remove_field.go (97%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011192014/change_unique_index.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011192014/pkg.go (80%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011201146/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011201146/remove_redundant_items.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011241510/add_bizid_on_self_defined_node.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011241510/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011251014/pkg.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011251014/proc_bind_change.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011301723/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202011301723/remove_default_field.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202012011450/change_proc_attr_index.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202012011450/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202101061721/add_del_archive_index.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202101061721/pkg.go (86%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202102011055/add_os_type_index.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202102011055/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202102261105/add_instass_proc_index.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202102261105/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202103031533/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202103031533/remove_bk_cpu_mhz_field.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202103231621/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202103231621/update_host_empty_special_field.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202104011012/add_bk_cpu_architecture_attr.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202104011012/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202104211151/change_set_unique_index.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202104211151/pkg.go (87%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202105261459/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{y3.10.202105261459 => history/y3.9.202105261459}/update_config_admin.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202106031151/add_unix_property.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202106031151/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202106031151/update_process_pri_range.go (90%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202106291420/index.go (93%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202106291420/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202106301910/change_host_attr_editable.go (92%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202106301910/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107011154/drop_set_template_version_column.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107011154/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107161611/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107161611/proc_bind_change.go (89%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107271940/delete_history_task.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107271940/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107301510/add_solaris_property.go (95%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107301510/pkg.go (83%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107311844/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202107311844/set_proc_bind_ip_not_reuqired.go (94%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202112061431/add_bind_info_option.go (96%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202112061431/pkg.go (84%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202112071130/migrate_api_task.go (98%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202112071130/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{ => history}/y3.9.202112071431/pkg.go (85%) rename src/scene_server/admin_server/upgrader/{y3.10.202112071431 => history/y3.9.202112071431}/updateAdminConfigc.go (94%) create mode 100644 src/scene_server/admin_server/upgrader/tools/create_index.go create mode 100644 src/scene_server/admin_server/upgrader/tools/create_table.go create mode 100644 src/scene_server/admin_server/upgrader/utils.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_applicationbase_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_asstdes_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_bizsetbase_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_idgenerator_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_modulebase_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objAttDesc_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objasst_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objclassfication_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objdes_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objectunique_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_platbase_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_propertygroup_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_servicecategory_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_setbase_data.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_systemdata.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/data/objAttDescData.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/indexes.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/initdata.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/pkg.go create mode 100644 src/scene_server/admin_server/upgrader/y3.15.202411071530/tableIndexMap.go diff --git a/src/common/index/collections/apitask.go b/src/common/index/collections/apitask.go index 243e12d7af..7e11955752 100644 --- a/src/common/index/collections/apitask.go +++ b/src/common/index/collections/apitask.go @@ -28,43 +28,53 @@ func init() { } // TODO: -// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commAPITaskIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedAPITaskIndexes = []types.Index{ +// +// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix +var commAPITaskIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "taskID", + Keys: bson.D{{"task_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "flag_status_createTime", + Keys: bson.D{{"flag", 1}, {"status", 1}, {"create_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "lastTime_status", + Keys: bson.D{{"last_time", 1}, {"status", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, { - Name: "idx_taskID", - Keys: bson.D{{ - "task_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "lastTime", + Keys: bson.D{{"last_time", 1}}, + Background: false, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_name_status_createTime", - Keys: bson.D{ - {"create_time", 1}, - {"name", 1}, - {"status", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "createTime_name_status", + Keys: bson.D{{"create_time", 1}, {"name", 1}, {"status", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_status_lastTime", - Keys: bson.D{ - {"status", 1}, - {"last_time", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "status_lastTime", + Keys: bson.D{{"status", 1}, {"last_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_name_flag_createTime", - Keys: bson.D{ - {"name", 1}, - {"flag", 1}, - {"create_time", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "name_flag_createTime", + Keys: bson.D{{"name", 1}, {"flag", 1}, {"create_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedAPITaskIndexes = []types.Index{} diff --git a/src/common/index/collections/applicationbase.go b/src/common/index/collections/applicationbase.go index 40cfeb2763..38ca7e5856 100644 --- a/src/common/index/collections/applicationbase.go +++ b/src/common/index/collections/applicationbase.go @@ -27,40 +27,41 @@ func init() { } -// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commApplicationBaseIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedApplicationBaseIndexes = []types.Index{ +// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix +var commApplicationBaseIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "default", + Keys: bson.D{{"default", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, { - Name: "default_1", - Keys: bson.D{{ - "default", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizName", + Keys: bson.D{{"bk_biz_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"bk_biz_name": map[string]string{common.BKDBType: "string"}}, }, { - Name: "bk_biz_id_1_bk_supplier_account_1", - Keys: bson.D{ - {"bk_biz_id", 1}, - {"bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "default_1_bk_supplier_account_1", - Keys: bson.D{ - {"default", 1}, - {"bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "default_bkSupplierAccount", + Keys: bson.D{{"default", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_bizID", - Keys: bson.D{ - {"bk_biz_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedApplicationBaseIndexes = []types.Index{} diff --git a/src/common/index/collections/asstdes.go b/src/common/index/collections/asstdes.go index 4943d59e1f..a8d563cd98 100644 --- a/src/common/index/collections/asstdes.go +++ b/src/common/index/collections/asstdes.go @@ -28,30 +28,27 @@ func init() { } // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commAsstDesIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedAsstDesIndexes = []types.Index{ +var commAsstDesIndexes = []types.Index{ { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_supplierId", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_asstId", - Keys: bson.D{{ - "bk_asst_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedAsstDesIndexes = []types.Index{} diff --git a/src/common/index/collections/auditlog.go b/src/common/index/collections/auditlog.go index 80da49b747..6d852bda79 100644 --- a/src/common/index/collections/auditlog.go +++ b/src/common/index/collections/auditlog.go @@ -29,46 +29,38 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commAuditLogIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedAuditLogIndexes = []types.Index{ +var commAuditLogIndexes = []types.Index{ { - Name: "index_id", - Keys: bson.D{{ - "id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "index_operationTime", - Keys: bson.D{{ - "operation_time", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "operationTime", + Keys: bson.D{{"operation_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "index_user", - Keys: bson.D{{ - "user", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "user", + Keys: bson.D{{"user", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "index_resourceName", - Keys: bson.D{{ - "resource_name", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "resourceName", + Keys: bson.D{{"resource_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "index_operationTime_auditType_resourceType_action", - Keys: bson.D{ - {"audit_type", 1}, - {"resource_type", 1}, - {"action", 1}, - {"operation_time", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "auditType_resourceName_action_operationTime", + Keys: bson.D{{"audit_type", 1}, {"resource_type", 1}, {"action", 1}, {"operation_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedAuditLogIndexes = []types.Index{} diff --git a/src/common/index/collections/business_set.go b/src/common/index/collections/business_set.go index 432b440ece..23af62258d 100644 --- a/src/common/index/collections/business_set.go +++ b/src/common/index/collections/business_set.go @@ -25,7 +25,7 @@ func init() { var commBizSetIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + "biz_set_id", + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetID", Keys: bson.D{{ common.BKBizSetIDField, 1}, }, @@ -33,7 +33,7 @@ var commBizSetIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "biz_set_name", + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetName", Keys: bson.D{{ common.BKBizSetNameField, 1}, }, @@ -41,7 +41,7 @@ var commBizSetIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "biz_set_id_biz_set_name_owner_id", + Name: common.CCLogicIndexNamePrefix + "bkBizSetID_bkBizSetName_bkSupplierAccount", Keys: bson.D{ {common.BKBizSetIDField, 1}, {common.BKBizSetNameField, 1}, diff --git a/src/common/index/collections/delarchive.go b/src/common/index/collections/delarchive.go index b0c2459459..dc09755cc7 100644 --- a/src/common/index/collections/delarchive.go +++ b/src/common/index/collections/delarchive.go @@ -31,65 +31,66 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commDelArchiveIndexes = []types.Index{{ - Name: common.CCLogicIndexNamePrefix + "time", - Keys: bson.D{{"time", -1}}, - Background: true, - ExpireAfterSeconds: 7 * 24 * 60 * 60, -}} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedDelArchiveIndexes = []types.Index{ +var commDelArchiveIndexes = []types.Index{ { - Name: "oid_1", - Keys: bson.D{{ - "oid", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "oid_coll", + Keys: bson.D{{"oid", 1}, {"coll", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_oid_coll", - Keys: bson.D{ - {"oid", 1}, - {"coll", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "coll", + Keys: bson.D{{"coll", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_coll", - Keys: bson.D{{ - "coll", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "oid", + Keys: bson.D{{"oid", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "time", + Keys: bson.D{{"time", -1}}, + Background: true, + ExpireAfterSeconds: 7 * 24 * 60 * 60, + PartialFilterExpression: make(map[string]interface{}), }, } +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedDelArchiveIndexes = []types.Index{} + var commKubeDelArchiveIndexes = []types.Index{ { - Name: common.CCLogicIndexNamePrefix + "time", - Keys: bson.D{{"time", -1}}, - Background: true, - ExpireAfterSeconds: 2 * 24 * 60 * 60, - }, { - Name: common.CCLogicIndexNamePrefix + "coll_oid", + Name: common.CCLogicUniqueIdxNamePrefix + "coll_oid", Keys: bson.D{ {"coll", 1}, {"oid", 1}, }, - Unique: true, - Background: true, - }, { - Name: common.CCLogicIndexNamePrefix + "coll", - Keys: bson.D{ - {"coll", 1}, - }, - Background: true, - }, { - Name: common.CCLogicIndexNamePrefix + "oid", - Keys: bson.D{ - {"oid", 1}, - }, - Background: true, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "coll", + Keys: bson.D{{"coll", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "oid", + Keys: bson.D{{"oid", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "time", + Keys: bson.D{{"time", -1}}, + Background: true, + ExpireAfterSeconds: 2 * 24 * 60 * 60, + PartialFilterExpression: make(map[string]interface{}), }, } diff --git a/src/common/index/collections/dynamicgroup.go b/src/common/index/collections/dynamicgroup.go index 250d0430d3..fa4133877e 100644 --- a/src/common/index/collections/dynamicgroup.go +++ b/src/common/index/collections/dynamicgroup.go @@ -29,33 +29,28 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commDynamicGroupIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedDynamicGroupIndexes = []types.Index{ +var commDynamicGroupIndexes = []types.Index{ { - Name: "id_1", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "id_1_bk_biz_id_1", - Keys: bson.D{ - {"bk_biz_id", 1}, - {"id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID_ID", + Keys: bson.D{{"bk_biz_id", 1}, {"id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_biz_id_1_name_1", - Keys: bson.D{ - {"bk_biz_id", 1}, - {"name", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_name", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedDynamicGroupIndexes = []types.Index{} diff --git a/src/common/index/collections/field_template.go b/src/common/index/collections/field_template.go index 70f99f0669..f92bbf19a0 100644 --- a/src/common/index/collections/field_template.go +++ b/src/common/index/collections/field_template.go @@ -30,7 +30,7 @@ func init() { var commFieldTemplateIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ { common.BKFieldID, 1, diff --git a/src/common/index/collections/full_sync_cond.go b/src/common/index/collections/full_sync_cond.go index eb9103da46..07af9403f8 100644 --- a/src/common/index/collections/full_sync_cond.go +++ b/src/common/index/collections/full_sync_cond.go @@ -31,7 +31,7 @@ func init() { var commFullSyncCondIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + fullsynccond.IDField, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ {fullsynccond.IDField, 1}, }, @@ -39,7 +39,7 @@ var commFullSyncCondIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "resource_subResource", + Name: common.CCLogicUniqueIdxNamePrefix + "resource_subResource_bkSupplierAccount", Keys: bson.D{ {fullsynccond.ResourceField, 1}, {fullsynccond.SubResField, 1}, diff --git a/src/common/index/collections/hostapplyrule.go b/src/common/index/collections/hostapplyrule.go index b0ca3e3e4d..04b4b68b01 100644 --- a/src/common/index/collections/hostapplyrule.go +++ b/src/common/index/collections/hostapplyrule.go @@ -27,11 +27,32 @@ func init() { } -// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix +// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix var commHostApplyRuleIndexes = []types.Index{ - { - Name: common.CCLogicUniqueIdxNamePrefix + "bizID_ModuleID_serviceTemplateID_attrID", + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{ + {common.BKAppIDField, 1}, + }, + Background: false, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{ + {common.BKFieldID, 1}, + }, + Unique: true, + Background: false, + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID", + Keys: bson.D{ + {common.BKModuleIDField, 1}, + }, + Background: false, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_bkModuleID_serviceTemplateID_bkAttributeID", Keys: bson.D{ {common.BKAppIDField, 1}, {common.BKModuleIDField, 1}, @@ -42,7 +63,7 @@ var commHostApplyRuleIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "host_property_under_service_template", + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID_bkAttributeID", Keys: bson.D{ {common.BKServiceTemplateIDField, 1}, {common.BKAttributeIDField, 1}, @@ -50,7 +71,7 @@ var commHostApplyRuleIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "bizID_serviceTemplateID_attrID", + Name: common.CCLogicIndexNamePrefix + "bkBizID_serviceTemplateID_bkAttributeID", Keys: bson.D{ {common.BKAppIDField, 1}, {common.BKServiceTemplateIDField, 1}, @@ -59,7 +80,7 @@ var commHostApplyRuleIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "bizID_moduleID_attrID", + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkModuleID_bkAttributeID", Keys: bson.D{ {common.BKAppIDField, 1}, {common.BKModuleIDField, 1}, @@ -68,7 +89,7 @@ var commHostApplyRuleIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "moduleID_attrID", + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkAttributeID", Keys: bson.D{ {common.BKModuleIDField, 1}, {common.BKAttributeIDField, 1}, @@ -78,27 +99,4 @@ var commHostApplyRuleIndexes = []types.Index{ } // deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedHostApplyRuleIndexes = []types.Index{ - { - Name: "bk_biz_id", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: false, - }, - { - Name: "id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: false, - }, - { - Name: "bk_module_id", - Keys: bson.D{{ - "bk_module_id", 1}, - }, - Background: false, - }, -} +var deprecatedHostApplyRuleIndexes = []types.Index{} diff --git a/src/common/index/collections/hostbase.go b/src/common/index/collections/hostbase.go index 8aefd16b17..eb201c44a0 100644 --- a/src/common/index/collections/hostbase.go +++ b/src/common/index/collections/hostbase.go @@ -27,128 +27,122 @@ func init() { } -// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix +// 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix var commHostBaseIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + "bkHostInnerIP_bkCloudID", - Keys: bson.D{ - {common.BKHostInnerIPField, 1}, - {common.BKCloudIDField, 1}, - }, - Unique: true, - Background: true, - PartialFilterExpression: map[string]interface{}{ - common.BKHostInnerIPField: map[string]string{common.BKDBType: "string"}, - common.BKCloudIDField: map[string]string{common.BKDBType: "number"}, - // only hosts with addressing = "static" must satisfy the uniqueness of inner ip + cloud id - common.BKAddressingField: common.BKAddressingStatic, - }, + Name: common.CCLogicIndexNamePrefix + "bkHostName", + Keys: bson.D{{"bk_host_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bkHostInnerIPv6_bkCloudID", - Keys: bson.D{ - {common.BKHostInnerIPv6Field, 1}, - {common.BKCloudIDField, 1}, - }, - Unique: true, - Background: true, - PartialFilterExpression: map[string]interface{}{ - common.BKHostInnerIPv6Field: map[string]string{common.BKDBType: "string"}, - common.BKCloudIDField: map[string]string{common.BKDBType: "number"}, - // only hosts with addressing = "static" must satisfy the uniqueness of inner ipv6 + cloud id - common.BKAddressingField: common.BKAddressingStatic, - }, + Name: common.CCLogicIndexNamePrefix + "bkHostInnerIP", + Keys: bson.D{{"bk_host_innerip", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bkAgentID", - Keys: bson.D{ - {common.BKAgentIDField, 1}, - }, + Name: common.CCLogicIndexNamePrefix + "bkCloudInstID", + Keys: bson.D{{"bk_cloud_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkCloudID", + Keys: bson.D{{"bk_cloud_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkOsType", + Keys: bson.D{{"bk_os_type", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostOuterIP", + Keys: bson.D{{"bk_host_outerip", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"bk_host_outerip": map[string]string{common.BKDBType: "string"}}, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkCloudInstID_bkCloudVendor", + Keys: bson.D{{"bk_cloud_inst_id", 1}, {"bk_cloud_vendor", 1}}, Unique: true, Background: true, PartialFilterExpression: map[string]interface{}{ - common.BKAgentIDField: map[string]string{ - common.BKDBType: "string", - // allows multiple hosts to not bind agentID, in this case they will have a default empty agentID of "" - common.BKDBGT: "", - }, + "bk_cloud_inst_id": map[string]string{common.BKDBType: "string"}, + "bk_cloud_vendor": map[string]string{common.BKDBType: "string"}, }, }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedHostBaseIndexes = []types.Index{ { - Name: "bk_host_name_1", - Keys: bson.D{{ - "bk_host_name", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkHostID_bkSupplierAccount", + Keys: bson.D{{"bk_host_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_host_innerip_1", - Keys: bson.D{{ - "bk_host_innerip", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_host_id_1_bk_supplier_account_1", - Keys: bson.D{ - {"bk_host_id", 1}, - {"bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, - /* { - Name: "innerIP_platID", - Keys: bson.D{{ - "bk_host_innerip", 1} - "bk_cloud_id": 1, - }, - Background: false, - }, */ { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkAssetID", + Keys: bson.D{{"bk_asset_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_cloud_id_1", - Keys: bson.D{{ - "bk_cloud_id", 1}, - }, + Name: common.CCLogicUniqueIdxNamePrefix + "bkAgentID", + Keys: bson.D{{"bk_agent_id", 1}}, + Unique: true, Background: true, + PartialFilterExpression: map[string]interface{}{"bk_agent_id": map[string]string{common.BKDBType: "string", + common.BKDBGT: ""}}, }, { - Name: "idx_unique_hostID", - Keys: bson.D{{ - "bk_host_id", 1}, - }, + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostInnerIP_bkCloudID", + Keys: bson.D{{"bk_host_innerip", 1}, {"bk_cloud_id", 1}}, Unique: true, Background: true, - }, - { - Name: "cloudInstID", - Keys: bson.D{{ - "bk_cloud_inst_id", 1}, + PartialFilterExpression: map[string]interface{}{ + "bk_host_innerip": map[string]string{common.BKDBType: "string"}, + "bk_cloud_id": map[string]string{common.BKDBType: "number"}, + "bk_addressing": "static", }, - Background: true, }, { - Name: "bk_idx_bk_asset_id", - Keys: bson.D{{ - "bk_asset_id", 1}, - }, + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostInnerIPV6_bkCloudID", + Keys: bson.D{{"bk_host_innerip_v6", 1}, {"bk_cloud_id", 1}}, + Unique: true, Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_cloud_id": map[string]string{common.BKDBType: "number"}, + "bk_addressing": "static", + "bk_host_innerip_v6": map[string]string{common.BKDBType: "string"}, + }, }, { - Name: "bk_os_type_1", - Keys: bson.D{{ - "bk_os_type", 1}, - }, + Name: common.CCLogicUniqueIdxNamePrefix + "bkCloudID_bkHostInnerIP", + Keys: bson.D{{"bk_cloud_id", 1}, {"bk_host_innerip", 1}}, + Unique: true, Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_cloud_id": map[string]string{common.BKDBType: "number"}, + "bk_host_innerip": map[string]string{common.BKDBType: "string"}, + "bk_addressing": "static", + }, }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedHostBaseIndexes = []types.Index{} diff --git a/src/common/index/collections/hostlock.go b/src/common/index/collections/hostlock.go index 6eb35cbfec..2f42989388 100644 --- a/src/common/index/collections/hostlock.go +++ b/src/common/index/collections/hostlock.go @@ -29,15 +29,14 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commHostLockIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedHostLockIndexes = []types.Index{ +var commHostLockIndexes = []types.Index{ { - Name: "bk_host_id_1", - Keys: bson.D{{ - "bk_host_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedHostLockIndexes = []types.Index{} diff --git a/src/common/index/collections/kube.go b/src/common/index/collections/kube.go index 24f82c5f59..9729248ba1 100644 --- a/src/common/index/collections/kube.go +++ b/src/common/index/collections/kube.go @@ -46,7 +46,7 @@ func init() { var commWorkLoadIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ {common.BKFieldID, 1}, }, @@ -54,7 +54,7 @@ var commWorkLoadIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bk_namespace_id_name", + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", Keys: bson.D{ {kubetypes.BKNamespaceIDField, 1}, {common.BKFieldName, 1}, @@ -63,7 +63,7 @@ var commWorkLoadIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicIndexNamePrefix + "cluster_uid", + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", Keys: bson.D{ {kubetypes.ClusterUIDField, 1}, {common.TenantID, 1}, @@ -71,7 +71,7 @@ var commWorkLoadIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "cluster_id", + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", Keys: bson.D{ {kubetypes.BKClusterIDFiled, 1}, {common.TenantID, 1}, @@ -79,7 +79,7 @@ var commWorkLoadIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "name", + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", Keys: bson.D{ {common.BKFieldName, 1}, {common.TenantID, 1}, @@ -90,7 +90,7 @@ var commWorkLoadIndexes = []types.Index{ var commContainerIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ {common.BKFieldID, 1}, }, @@ -98,7 +98,7 @@ var commContainerIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bk_pod_id_container_uid", + Name: common.CCLogicUniqueIdxNamePrefix + "bkPodID_containerUID", Keys: bson.D{ {kubetypes.BKPodIDField, 1}, {kubetypes.ContainerUIDField, 1}, @@ -107,7 +107,7 @@ var commContainerIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicIndexNamePrefix + "pod_id", + Name: common.CCLogicIndexNamePrefix + "bkPodID_bkSupplierAccount", Keys: bson.D{ {kubetypes.BKPodIDField, 1}, {common.TenantID, 1}, @@ -115,7 +115,7 @@ var commContainerIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "biz_id", + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkSupplierAccount", Keys: bson.D{ {kubetypes.BKBizIDField, 1}, {common.TenantID, 1}, @@ -123,7 +123,7 @@ var commContainerIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "cluster_id", + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", Keys: bson.D{ {kubetypes.BKClusterIDFiled, 1}, {common.TenantID, 1}, @@ -131,7 +131,7 @@ var commContainerIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "namespace_id", + Name: common.CCLogicIndexNamePrefix + "bkNamespaceID_bkSupplierAccount", Keys: bson.D{ {kubetypes.BKNamespaceIDField, 1}, {common.TenantID, 1}, @@ -139,7 +139,7 @@ var commContainerIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "reference_id_reference_kind", + Name: common.CCLogicIndexNamePrefix + "refID_refKind_bkSupplierAccount", Keys: bson.D{ {kubetypes.RefIDField, 1}, {kubetypes.RefKindField, 1}, @@ -151,7 +151,7 @@ var commContainerIndexes = []types.Index{ var commPodIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ {common.BKFieldID, 1}, }, @@ -159,7 +159,7 @@ var commPodIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bk_reference_id_reference_kind_name", + Name: common.CCLogicUniqueIdxNamePrefix + "refID_refKind_name", Keys: bson.D{ {kubetypes.RefIDField, 1}, {kubetypes.RefKindField, 1}, @@ -169,67 +169,67 @@ var commPodIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicIndexNamePrefix + "reference_name_reference_kind", + Name: common.CCLogicIndexNamePrefix + "bkHostID_bkSupplierAccount", Keys: bson.D{ - {kubetypes.RefNameField, 1}, - {kubetypes.RefIDField, 1}, + {common.BKHostIDField, 1}, {common.TenantID, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "cluster_id", + Name: common.CCLogicIndexNamePrefix + "refName_refID_bkSupplierAccount", Keys: bson.D{ - {kubetypes.BKClusterIDFiled, 1}, + {kubetypes.RefNameField, 1}, + {kubetypes.RefIDField, 1}, {common.TenantID, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "cluster_uid", + Name: common.CCLogicIndexNamePrefix + "clusterID_bkSupplierAccount", Keys: bson.D{ - {kubetypes.ClusterUIDField, 1}, + {kubetypes.BKClusterIDFiled, 1}, {common.TenantID, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "namespace_id", + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", Keys: bson.D{ - {kubetypes.BKNamespaceIDField, 1}, + {kubetypes.ClusterUIDField, 1}, {common.TenantID, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "reference_id_reference_kind", + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", Keys: bson.D{ - {kubetypes.RefIDField, 1}, - {kubetypes.RefKindField, 1}, + {common.BKFieldName, 1}, {common.TenantID, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "name", + Name: common.CCLogicIndexNamePrefix + "bkNodeID", Keys: bson.D{ - {common.BKFieldName, 1}, - {common.TenantID, 1}, + {kubetypes.BKNodeIDField, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "bk_host_id", + Name: common.CCLogicIndexNamePrefix + "bkNamespaceID_bkSupplierAccount", Keys: bson.D{ - {common.BKHostIDField, 1}, + {kubetypes.BKNamespaceIDField, 1}, {common.TenantID, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "node_id", + Name: common.CCLogicIndexNamePrefix + "refID_refKind_bkSupplierAccount", Keys: bson.D{ - {kubetypes.BKNodeIDField, 1}, + {kubetypes.RefIDField, 1}, + {kubetypes.RefKindField, 1}, + {common.TenantID, 1}, }, Background: true, }, @@ -237,7 +237,7 @@ var commPodIndexes = []types.Index{ var commNamespaceIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ {common.BKFieldID, 1}, }, @@ -245,7 +245,7 @@ var commNamespaceIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bk_cluster_id_name", + Name: common.CCLogicUniqueIdxNamePrefix + "bkClusterID_name", Keys: bson.D{ {kubetypes.BKClusterIDFiled, 1}, {common.BKFieldName, 1}, @@ -254,7 +254,7 @@ var commNamespaceIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicIndexNamePrefix + "cluster_uid", + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", Keys: bson.D{ {kubetypes.ClusterUIDField, 1}, {common.TenantID, 1}, @@ -262,7 +262,7 @@ var commNamespaceIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "cluster_id", + Name: common.CCLogicIndexNamePrefix + "clusterID_bkSupplierAccount", Keys: bson.D{ {kubetypes.BKClusterIDFiled, 1}, {common.TenantID, 1}, @@ -270,7 +270,7 @@ var commNamespaceIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "name", + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", Keys: bson.D{ {common.BKFieldName, 1}, {common.TenantID, 1}, @@ -281,7 +281,7 @@ var commNamespaceIndexes = []types.Index{ var commNodeIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ {common.BKFieldID, 1}, }, @@ -289,7 +289,7 @@ var commNodeIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bk_cluster_id_name", + Name: common.CCLogicUniqueIdxNamePrefix + "bkClusterID_name", Keys: bson.D{ {kubetypes.BKClusterIDFiled, 1}, {common.BKFieldName, 1}, @@ -298,7 +298,7 @@ var commNodeIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "biz_id_cluster_uid", + Name: common.CCLogicIndexNamePrefix + "bkBizID_clusterUID_bkSupplierAccount", Keys: bson.D{ {common.BKAppIDField, 1}, {kubetypes.ClusterUIDField, 1}, @@ -307,7 +307,7 @@ var commNodeIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "biz_id_cluster_id", + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkClusterID_bkSupplierAccount", Keys: bson.D{ {common.BKAppIDField, 1}, {kubetypes.BKClusterIDFiled, 1}, @@ -316,7 +316,7 @@ var commNodeIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "biz_id_host_id", + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkHostID_bkSupplierAccount", Keys: bson.D{ {common.BKAppIDField, 1}, {common.BKHostIDField, 1}, @@ -325,7 +325,7 @@ var commNodeIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "biz_id_name", + Name: common.CCLogicIndexNamePrefix + "bkBizID_name_bkSupplierAccount", Keys: bson.D{ {common.BKAppIDField, 1}, {common.BKFieldName, 1}, @@ -337,7 +337,7 @@ var commNodeIndexes = []types.Index{ var commClusterIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ {common.BKFieldID, 1}, }, @@ -345,7 +345,7 @@ var commClusterIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "uid", + Name: common.CCLogicUniqueIdxNamePrefix + "UID", Keys: bson.D{ {kubetypes.UidField, 1}, }, @@ -353,7 +353,7 @@ var commClusterIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "bk_biz_id_name", + Name: common.CCLogicIndexNamePrefix + "bkBizID_name_bkSupplierAccount", Keys: bson.D{ {common.BKAppIDField, 1}, {common.BKFieldName, 1}, @@ -362,7 +362,7 @@ var commClusterIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + common.BKAppIDField, + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkSupplierAccount", Keys: bson.D{ {common.BKAppIDField, 1}, {common.TenantID, 1}, @@ -370,7 +370,7 @@ var commClusterIndexes = []types.Index{ Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "xid", + Name: common.CCLogicIndexNamePrefix + "xid_bkSupplierAccount", Keys: bson.D{ {kubetypes.XidField, 1}, {common.TenantID, 1}, @@ -381,7 +381,7 @@ var commClusterIndexes = []types.Index{ var nsSharedClusterRelIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + "namespace_id", + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID", Keys: bson.D{ {kubetypes.BKNamespaceIDField, 1}, }, @@ -389,14 +389,14 @@ var nsSharedClusterRelIndexes = []types.Index{ Unique: true, }, { - Name: common.CCLogicIndexNamePrefix + "biz_id", + Name: common.CCLogicIndexNamePrefix + "bkBizID", Keys: bson.D{ {kubetypes.BKBizIDField, 1}, }, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + "asst_biz_id", + Name: common.CCLogicIndexNamePrefix + "bkAsstBizID", Keys: bson.D{ {kubetypes.BKAsstBizIDField, 1}, }, diff --git a/src/common/index/collections/manager.go b/src/common/index/collections/manager.go index 1a9100cc0a..d45427a7ae 100644 --- a/src/common/index/collections/manager.go +++ b/src/common/index/collections/manager.go @@ -46,14 +46,8 @@ func indexKeyEqual(toDBIndex, dbIndex types.Index) bool { return false } - toDBIndexMap := toDBIndex.Keys.Map() - dbIndexMap := dbIndex.Keys.Map() - for key, val := range toDBIndexMap { - dbVal, exists := dbIndexMap[key] - if !exists { - return false - } - if val != dbVal { + for i := 0; i < len(toDBIndex.Keys); i++ { + if toDBIndex.Keys[i].Key != dbIndex.Keys[i].Key || toDBIndex.Keys[i].Value != dbIndex.Keys[i].Value { return false } } @@ -68,7 +62,8 @@ func Indexes() map[string][]types.Index { } // DeprecatedIndexName TODO -// DeprecatedIndexName 未规范索引的名字。用来对需要删除的未规范索引 +// +// DeprecatedIndexName 未规范索引的名字。用来对需要删除的未规范索引 func DeprecatedIndexName() map[string][]string { return deprecatedIndexName } diff --git a/src/common/index/collections/modulebase.go b/src/common/index/collections/modulebase.go index df13ff0283..b82f76e580 100644 --- a/src/common/index/collections/modulebase.go +++ b/src/common/index/collections/modulebase.go @@ -29,88 +29,85 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commModuleBaseIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedModuleBaseIndexes = []types.Index{ +var commModuleBaseIndexes = []types.Index{ { - Name: "bk_module_name_1", - Keys: bson.D{{ - "bk_module_name", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkModuleName", + Keys: bson.D{{"bk_module_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "default_1", - Keys: bson.D{{ - "default", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "default", + Keys: bson.D{{"default", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_biz_id_1", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_set_id_1", - Keys: bson.D{{ - "bk_set_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSetID", + Keys: bson.D{{"bk_set_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_parent_id_1", - Keys: bson.D{{ - "bk_parent_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkParentID", + Keys: bson.D{{"bk_parent_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_module_id_1_bk_biz_id_1", - Keys: bson.D{ - {"bk_module_id", 1}, - {"bk_biz_id", 1}, - }, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_bkSetID_bkModuleName", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_set_id", 1}, {"bk_module_name", 1}}, + Unique: true, Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_biz_id": map[string]string{common.BKDBType: "number"}, + "bk_set_id": map[string]string{common.BKDBType: "number"}, + "bk_module_name": map[string]string{common.BKDBType: "string"}}, }, { - Name: "idx_unique_moduleID", - Keys: bson.D{{ - "bk_module_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkBizID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_idx_set_template_id_service_template_id", - Keys: bson.D{ - {"set_template_id", 1}, - {"service_template_id", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkModuleID", + Keys: bson.D{{"bk_module_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_idx_set_template_id", - Keys: bson.D{{ - "set_template_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "setTemplateID_serviceTemplateID", + Keys: bson.D{{"set_template_id", 1}, {"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_idx_service_template_id", - Keys: bson.D{{ - "service_template_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "setTemplateID", + Keys: bson.D{{"set_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID", + Keys: bson.D{{"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedModuleBaseIndexes = []types.Index{} diff --git a/src/common/index/collections/modulehostconfig.go b/src/common/index/collections/modulehostconfig.go index 1c4f7b6372..7c83523026 100644 --- a/src/common/index/collections/modulehostconfig.go +++ b/src/common/index/collections/modulehostconfig.go @@ -31,65 +31,55 @@ func init() { var commModuleHostConfigIndexes = []types.Index{ { - Name: "bkcc_idx_bkBizID_bkHostID", - Keys: bson.D{{"bk_biz_id", 1}, {"bk_host_id", 1}}, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedModuleHostConfigIndexes = []types.Index{ { - Name: "bk_biz_id_1", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_host_id_1", - Keys: bson.D{{ - "bk_host_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkModuleID", + Keys: bson.D{{"bk_module_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_module_id_1", - Keys: bson.D{{ - "bk_module_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSetID", + Keys: bson.D{{"bk_set_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_set_id_1", - Keys: bson.D{{ - "bk_set_id", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkModuleID_bkHostID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_host_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_module_id_1_bk_biz_id_1", - Keys: bson.D{ - {"bk_module_id", 1}, - {"bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkHostID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_set_id_1_bk_biz_id_1", - Keys: bson.D{ - {"bk_set_id", 1}, - {"bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkBizID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_moduleID_hostID", - Keys: bson.D{ - {"bk_module_id", 1}, - {"bk_host_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSetID_bkBizID", + Keys: bson.D{{"bk_set_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedModuleHostConfigIndexes = []types.Index{} diff --git a/src/common/index/collections/obj_attr_des_template.go b/src/common/index/collections/obj_attr_des_template.go index 956e25f126..edcf303cb1 100644 --- a/src/common/index/collections/obj_attr_des_template.go +++ b/src/common/index/collections/obj_attr_des_template.go @@ -30,7 +30,7 @@ func init() { var commObjAttDesTemplateIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ { common.BKFieldID, 1, diff --git a/src/common/index/collections/objasst.go b/src/common/index/collections/objasst.go index cc9025e00f..2d29393318 100644 --- a/src/common/index/collections/objasst.go +++ b/src/common/index/collections/objasst.go @@ -29,46 +29,39 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commObjAsstIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedObjAsstIndexes = []types.Index{ +var commObjAsstIndexes = []types.Index{ { - Name: "bk_obj_id_1", - Keys: bson.D{{ - "bk_obj_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_asst_obj_id_1", - Keys: bson.D{{ - "bk_asst_obj_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID", + Keys: bson.D{{"bk_asst_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_obj_id_1_bk_asst_obj_id_1_bk_asst_id_1", - Keys: bson.D{ - {"bk_obj_id", 1}, - {"bk_asst_obj_id", 1}, - {"bk_asst_id", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkAsstObjID_bkAsstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_asst_obj_id", 1}, {"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedObjAsstIndexes = []types.Index{} diff --git a/src/common/index/collections/objattdes.go b/src/common/index/collections/objattdes.go index 5313ecdb73..0a876670a9 100644 --- a/src/common/index/collections/objattdes.go +++ b/src/common/index/collections/objattdes.go @@ -42,40 +42,39 @@ var commObjAttDesIndexes = []types.Index{ }, Background: true, }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedObjAttDesIndexes = []types.Index{ { - Name: "bk_obj_id_1", - Keys: bson.D{{ - "bk_obj_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_objID_propertyID_bizID", - Keys: bson.D{ - {"bk_property_id", 1}, - {"bk_biz_id", 1}, - {"bk_obj_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID_bkPropertyID_bkBizID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_property_id", 1}, {"bk_biz_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_Id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkTemplateID_bkSupplierAccount", + Keys: bson.D{{"bk_template_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedObjAttDesIndexes = []types.Index{} diff --git a/src/common/index/collections/objclassification.go b/src/common/index/collections/objclassification.go index c738f4a5ce..24499b3af4 100644 --- a/src/common/index/collections/objclassification.go +++ b/src/common/index/collections/objclassification.go @@ -50,16 +50,14 @@ var commObjClassificationIndexes = []types.Index{ common.BKClassificationNameField: map[string]string{common.BKDBType: "string"}, }, }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedObjClassificationIndexes = []types.Index{ { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedObjClassificationIndexes = []types.Index{} diff --git a/src/common/index/collections/objdes.go b/src/common/index/collections/objdes.go index cfbeb955a9..b5bc5130a8 100644 --- a/src/common/index/collections/objdes.go +++ b/src/common/index/collections/objdes.go @@ -50,30 +50,26 @@ var commObjDesIndexes = []types.Index{ common.BKObjNameField: map[string]string{common.BKDBType: "string"}, }, }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedObjDesIndexes = []types.Index{ { - Name: "bk_classification_id_1", - Keys: bson.D{{ - "bk_classification_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkClassificationID", + Keys: bson.D{{"bk_classification_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedObjDesIndexes = []types.Index{} diff --git a/src/common/index/collections/object_unique_template.go b/src/common/index/collections/object_unique_template.go index 659e56c011..b212585d95 100644 --- a/src/common/index/collections/object_unique_template.go +++ b/src/common/index/collections/object_unique_template.go @@ -30,7 +30,7 @@ func init() { var commObjectUniqueTemplateIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{ { common.BKFieldID, 1, diff --git a/src/common/index/collections/objectbasemapping.go b/src/common/index/collections/objectbasemapping.go index ac0551ff8b..9cce81e9c1 100644 --- a/src/common/index/collections/objectbasemapping.go +++ b/src/common/index/collections/objectbasemapping.go @@ -29,7 +29,7 @@ func init() { var commInstanceObjectBaseMappingIndexes = []types.Index{ { - Name: common.CCLogicIndexNamePrefix + "InstID", + Name: common.CCLogicIndexNamePrefix + "bkInstID", Keys: bson.D{{ common.BKInstIDField, 1}, }, diff --git a/src/common/index/collections/objectunique.go b/src/common/index/collections/objectunique.go index 348d88741c..3f9e45b455 100644 --- a/src/common/index/collections/objectunique.go +++ b/src/common/index/collections/objectunique.go @@ -42,23 +42,20 @@ var commObjectUniqueIndexes = []types.Index{ }, Background: true, }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedObjectUniqueIndexes = []types.Index{ { - Name: "bk_obj_id", - Keys: bson.D{{ - "bk_obj_id", 1}, - }, - Background: false, + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: false, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedObjectUniqueIndexes = []types.Index{} diff --git a/src/common/index/collections/platbase.go b/src/common/index/collections/platbase.go index 6171d4a277..81a4489bf0 100644 --- a/src/common/index/collections/platbase.go +++ b/src/common/index/collections/platbase.go @@ -41,22 +41,25 @@ var commPlatBaseIndexes = []types.Index{ common.BKCloudNameField: map[string]string{common.BKDBType: "string"}, }, }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedPlatBaseIndexes = []types.Index{ { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "vpcID", - Keys: bson.D{{ - "bk_vpc_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkVpcID", + Keys: bson.D{{"bk_vpc_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkCloudID", + Keys: bson.D{{"bk_cloud_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedPlatBaseIndexes = []types.Index{} diff --git a/src/common/index/collections/process.go b/src/common/index/collections/process.go index 5f68471c80..c10c1103c4 100644 --- a/src/common/index/collections/process.go +++ b/src/common/index/collections/process.go @@ -31,7 +31,7 @@ func init() { var commProcessIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + "svcInstID_bkProcName", + Name: common.CCLogicUniqueIdxNamePrefix + "serviceInstanceID_bkProcessName", Keys: bson.D{ {common.BKServiceInstanceIDField, 1}, {common.BKProcessNameField, 1}, @@ -44,7 +44,7 @@ var commProcessIndexes = []types.Index{ }, }, { - Name: common.CCLogicUniqueIdxNamePrefix + "svcInstID_bkFuncName_bkStartParamRegex", + Name: common.CCLogicUniqueIdxNamePrefix + "serviceInstanceID_bkFuncName_bkStartParamRegex", Keys: bson.D{ {common.BKServiceInstanceIDField, 1}, {common.BKFuncName, 1}, @@ -58,30 +58,26 @@ var commProcessIndexes = []types.Index{ common.BKStartParamRegex: map[string]string{common.BKDBType: "string"}, }, }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedProcessIndexes = []types.Index{ { - Name: "bk_biz_id_1", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_procID", - Keys: bson.D{{ - "bk_process_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkProcessID", + Keys: bson.D{{"bk_process_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedProcessIndexes = []types.Index{} diff --git a/src/common/index/collections/processinstancerelation.go b/src/common/index/collections/processinstancerelation.go index dcfe8ae32f..a87242c951 100644 --- a/src/common/index/collections/processinstancerelation.go +++ b/src/common/index/collections/processinstancerelation.go @@ -29,61 +29,52 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commProcessInstanceRelationIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedProcessInstanceRelationIndexes = []types.Index{ +var commProcessInstanceRelationIndexes = []types.Index{ { - Name: "idx_bkServiceInstanceID", - Keys: bson.D{{ - "service_instance_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "serviceInstanceID", + Keys: bson.D{{"service_instance_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_bkProcessTemplateID", - Keys: bson.D{{ - "process_template_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "processTemplateID", + Keys: bson.D{{"process_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_bkBizID", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_bkProcessID", - Keys: bson.D{{ - "bk_process_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkProcessID", + Keys: bson.D{{"bk_process_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_bkHostID", - Keys: bson.D{{ - "bk_host_id", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "serviceInstanceID_bkProcessID", + Keys: bson.D{{"service_instance_id", 1}, {"bk_process_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_serviceInstID_ProcID", - Keys: bson.D{ - {"service_instance_id", 1}, - {"bk_process_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkProcessID_bkHostID", + Keys: bson.D{{"bk_process_id", 1}, {"bk_host_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_procID_hostID", - Keys: bson.D{ - {"bk_process_id", 1}, - {"bk_host_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedProcessInstanceRelationIndexes = []types.Index{} diff --git a/src/common/index/collections/processtemplate.go b/src/common/index/collections/processtemplate.go index b9603edda1..2435ee1a59 100644 --- a/src/common/index/collections/processtemplate.go +++ b/src/common/index/collections/processtemplate.go @@ -29,39 +29,34 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commProcessTemplateIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedProcessTemplateIndexes = []types.Index{ +var commProcessTemplateIndexes = []types.Index{ { - Name: "idx_serviceTemplateID", - Keys: bson.D{{ - "service_template_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID", + Keys: bson.D{{"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_bkBizID", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "serviceTemplateID_bkProcessName", + Keys: bson.D{{"service_template_id", 1}, {"bk_process_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_idx_service_template_id_bk_process_name", - Keys: bson.D{ - {"bk_process_name", 1}, - {"service_template_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedProcessTemplateIndexes = []types.Index{} diff --git a/src/common/index/collections/project.go b/src/common/index/collections/project.go index 16be88c068..6c51613168 100644 --- a/src/common/index/collections/project.go +++ b/src/common/index/collections/project.go @@ -30,31 +30,31 @@ func init() { var commProjectIndexes = []types.Index{ { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{{common.BKFieldID, 1}}, Background: true, Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKProjectIDField, + Name: common.CCLogicUniqueIdxNamePrefix + "bkProjectID", Keys: bson.D{{common.BKProjectIDField, 1}}, Background: true, Unique: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKProjectNameField, + Name: common.CCLogicUniqueIdxNamePrefix + "bkProjectName", Keys: bson.D{{common.BKProjectNameField, 1}}, Unique: true, Background: true, }, { - Name: common.CCLogicUniqueIdxNamePrefix + common.BKProjectCodeField, + Name: common.CCLogicUniqueIdxNamePrefix + "bkProjectCode", Keys: bson.D{{common.BKProjectCodeField, 1}}, Unique: true, Background: true, }, { - Name: common.CCLogicIndexNamePrefix + common.BKProjectStatusField, + Name: common.CCLogicIndexNamePrefix + "bkStatus", Keys: bson.D{{common.BKProjectStatusField, 1}}, Background: true, }, diff --git a/src/common/index/collections/propertygroup.go b/src/common/index/collections/propertygroup.go index 51e34d7e07..4da079ee4d 100644 --- a/src/common/index/collections/propertygroup.go +++ b/src/common/index/collections/propertygroup.go @@ -29,57 +29,54 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commPropertyGroupIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedPropertyGroupIndexes = []types.Index{ +var commPropertyGroupIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, { - Name: "bk_obj_id_1", - Keys: bson.D{{ - "bk_obj_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkGroupID", + Keys: bson.D{{"bk_group_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_group_id_1", - Keys: bson.D{{ - "bk_group_id", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID_bkBizID_bkGroupName", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_biz_id", 1}, {"bk_group_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_groupName", - Keys: bson.D{ - {"bk_obj_id", 1}, - {"bk_biz_id", 1}, - {"bk_group_name", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID_bkBizID_bkGroupIndex", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_biz_id", 1}, {"bk_group_index", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_groupId", - Keys: bson.D{ - {"bk_obj_id", 1}, - {"bk_biz_id", 1}, - {"bk_group_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID_bkBizID_bkGroupID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_biz_id", 1}, {"bk_group_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedPropertyGroupIndexes = []types.Index{} diff --git a/src/common/index/collections/servicecategory.go b/src/common/index/collections/servicecategory.go index d0c26a77bd..b8ff9aed04 100644 --- a/src/common/index/collections/servicecategory.go +++ b/src/common/index/collections/servicecategory.go @@ -29,26 +29,22 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commServiceCategoryIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedServiceCategoryIndexes = []types.Index{ +var commServiceCategoryIndexes = []types.Index{ { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_Name_parentID_bizID", - Keys: bson.D{ - {"bk_parent_id", 1}, - {"bk_biz_id", 1}, - {"name", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "name_bkParentID_bkBizID", + Keys: bson.D{{"name", 1}, {"bk_parent_id", 1}, {"bk_biz_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedServiceCategoryIndexes = []types.Index{} diff --git a/src/common/index/collections/serviceinstance.go b/src/common/index/collections/serviceinstance.go index 7a2f5700f2..c494fc05eb 100644 --- a/src/common/index/collections/serviceinstance.go +++ b/src/common/index/collections/serviceinstance.go @@ -31,64 +31,55 @@ func init() { var commServiceInstanceIndexes = []types.Index{ { - Name: "bkcc_idx_bkBizID_ID", - Keys: bson.D{{"bk_biz_id", 1}, {"id", 1}}, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, -} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedServiceInstanceIndexes = []types.Index{ { - Name: "idx_bkBizID", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID", + Keys: bson.D{{"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_serviceTemplateID", - Keys: bson.D{{ - "service_template_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkModuleID", + Keys: bson.D{{"bk_module_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "moduleID", - Keys: bson.D{{ - "bk_module_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID_ID", + Keys: bson.D{{"bk_biz_id", 1}, {"id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_module_id_1_bk_biz_id_1", - Keys: bson.D{ - {"bk_module_id", 1}, - {"bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkBizID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_biz_id_1_bk_host_id_1", - Keys: bson.D{ - {"bk_biz_id", 1}, - {"bk_host_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkHostID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_idx_host_id", - Keys: bson.D{{ - "bk_host_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedServiceInstanceIndexes = []types.Index{} diff --git a/src/common/index/collections/servicetemplate.go b/src/common/index/collections/servicetemplate.go index 90f8fed7c0..d2ca82783d 100644 --- a/src/common/index/collections/servicetemplate.go +++ b/src/common/index/collections/servicetemplate.go @@ -29,40 +29,34 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commServiceTemplateIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedServiceTemplateIndexes = []types.Index{ +var commServiceTemplateIndexes = []types.Index{ { - Name: "id_1_bk_biz_id_1", - Keys: bson.D{ - {"id", 1}, - {"bk_biz_id", 1}, - }, - Background: true, // 1, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_bkBizID", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_name", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "ID_bkBizID", + Keys: bson.D{{"id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_idx_bk_biz_id_name", - Keys: bson.D{ - {"bk_biz_id", 1}, - {"name", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedServiceTemplateIndexes = []types.Index{} diff --git a/src/common/index/collections/servicetemplateattr.go b/src/common/index/collections/servicetemplateattr.go index 30bf9c3245..a73a598dec 100644 --- a/src/common/index/collections/servicetemplateattr.go +++ b/src/common/index/collections/servicetemplateattr.go @@ -35,7 +35,7 @@ var commServiceTemplateAttrIndexes = []types.Index{ common.BKFieldID, 1, }, }, - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Unique: true, Background: true, }, @@ -51,8 +51,7 @@ var commServiceTemplateAttrIndexes = []types.Index{ common.BKAttributeIDField, 1, }, }, - Name: common.CCLogicUniqueIdxNamePrefix + common.BKAppIDField + "_" + common.BKServiceTemplateIDField + "_" + - common.BKAttributeIDField, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_serviceTemplateID_bkAttributeID", Background: true, Unique: true, }, diff --git a/src/common/index/collections/setbase.go b/src/common/index/collections/setbase.go index d762aa9a10..faffdf2a97 100644 --- a/src/common/index/collections/setbase.go +++ b/src/common/index/collections/setbase.go @@ -29,61 +29,62 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commSetBaseIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedSetBaseIndexes = []types.Index{ +var commSetBaseIndexes = []types.Index{ { - Name: "bk_parent_id_1", - Keys: bson.D{{ - "bk_parent_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkParentID", + Keys: bson.D{{"bk_parent_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_biz_id_1", - Keys: bson.D{{ - "bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_supplier_account_1", - Keys: bson.D{{ - "bk_supplier_account", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_set_name_1", - Keys: bson.D{{ - "bk_set_name", 1}, - }, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSetName", + Keys: bson.D{{"bk_set_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "bk_set_id_1_bk_biz_id_1", - Keys: bson.D{ - {"bk_set_id", 1}, - {"bk_biz_id", 1}, - }, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkParentID_bkSetName", + Keys: bson.D{{"bk_parent_id", 1}, {"bk_set_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_setID", - Keys: bson.D{{ - "bk_set_id", 1}, - }, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_bkSetName_bkParentID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_set_name", 1}, {"bk_parent_id", 1}}, Unique: true, Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_set_name": map[string]string{common.BKDBType: "string"}, + "bk_parent_id": map[string]string{common.BKDBType: "number"}, + "bk_biz_id": map[string]string{common.BKDBType: "number"}}, }, { - Name: "idx_unique_parentID_setName", - Keys: bson.D{ - {common.BKParentIDField, 1}, - {common.BKSetNameField, 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicIndexNamePrefix + "bkSetID_bkBizID", + Keys: bson.D{{"bk_set_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkSetID", + Keys: bson.D{{"bk_set_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedSetBaseIndexes = []types.Index{} diff --git a/src/common/index/collections/setservicetemplaterelation.go b/src/common/index/collections/setservicetemplaterelation.go index 3634f2fb53..40c15b9a3a 100644 --- a/src/common/index/collections/setservicetemplaterelation.go +++ b/src/common/index/collections/setservicetemplaterelation.go @@ -29,19 +29,22 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commSetServiceTemplateRelationIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedSetServiceTemplateRelationIndexes = []types.Index{ +var commSetServiceTemplateRelationIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "setTemplateID_serviceTemplateID", + Keys: bson.D{{"set_template_id", 1}, {"service_template_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, { - // 这个是手动建, 拼写错误 - Name: "idx_unque_setTemplateID_serviceTemplateID", - Keys: bson.D{ - {"bk_biz_id", 1}, - {"set_template_id", 1}, - {"service_template_id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_setTemplateID_serviceTemplateID", + Keys: bson.D{{"bk_biz_id", 1}, {"set_template_id", 1}, {"service_template_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedSetServiceTemplateRelationIndexes = []types.Index{} diff --git a/src/common/index/collections/settemplate.go b/src/common/index/collections/settemplate.go index e039f92cf8..c2836cf73b 100644 --- a/src/common/index/collections/settemplate.go +++ b/src/common/index/collections/settemplate.go @@ -29,25 +29,22 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commSetTemplateIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedSetTemplateIndexes = []types.Index{ +var commSetTemplateIndexes = []types.Index{ { - Name: "idx_id", - Keys: bson.D{{ - "id", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, { - Name: "idx_unique_bizID_name", - Keys: bson.D{ - {"bk_biz_id", 1}, - {"name", 1}, - }, - Unique: true, - Background: true, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_name", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedSetTemplateIndexes = []types.Index{} diff --git a/src/common/index/collections/settemplateattr.go b/src/common/index/collections/settemplateattr.go index 141ea55224..e7b34c198b 100644 --- a/src/common/index/collections/settemplateattr.go +++ b/src/common/index/collections/settemplateattr.go @@ -35,7 +35,7 @@ var commSetTemplateAttrIndexes = []types.Index{ common.BKFieldID, 1, }, }, - Name: common.CCLogicUniqueIdxNamePrefix + common.BKFieldID, + Name: common.CCLogicUniqueIdxNamePrefix + "ID", Unique: true, Background: true, }, @@ -51,8 +51,7 @@ var commSetTemplateAttrIndexes = []types.Index{ common.BKAttributeIDField, 1, }, }, - Name: common.CCLogicUniqueIdxNamePrefix + common.BKAppIDField + "_" + common.BKSetTemplateIDField + "_" + - common.BKAttributeIDField, + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_setTemplateID_bkAttributeID", Background: true, Unique: true, }, diff --git a/src/common/index/collections/topographics.go b/src/common/index/collections/topographics.go index ca2af21d0f..ce4419e766 100644 --- a/src/common/index/collections/topographics.go +++ b/src/common/index/collections/topographics.go @@ -29,12 +29,9 @@ func init() { // 新加和修改后的索引,索引名字一定要用对应的前缀,CCLogicUniqueIdxNamePrefix|common.CCLogicIndexNamePrefix -var commTopoGraphicsIndexes = []types.Index{} - -// deprecated 未规范化前的索引,只允许删除不允许新加和修改, -var deprecatedTopoGraphicsIndexes = []types.Index{ +var commTopoGraphicsIndexes = []types.Index{ { - Name: "scope_type_1_scope_id_1_node_type_1_bk_obj_id_1_bk_inst_id_1", + Name: common.CCLogicUniqueIdxNamePrefix + "scopeType_scopeID_nodeType_bkObjID_bkInstID", Keys: bson.D{ {"scope_type", 1}, {"scope_id", 1}, @@ -42,7 +39,11 @@ var deprecatedTopoGraphicsIndexes = []types.Index{ {"bk_obj_id", 1}, {"bk_inst_id", 1}, }, - Unique: true, - Background: true, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), }, } + +// deprecated 未规范化前的索引,只允许删除不允许新加和修改, +var deprecatedTopoGraphicsIndexes = []types.Index{} diff --git a/src/scene_server/admin_server/iam/synciam.go b/src/scene_server/admin_server/iam/synciam.go index a9b205e504..e2c6d37be9 100644 --- a/src/scene_server/admin_server/iam/synciam.go +++ b/src/scene_server/admin_server/iam/synciam.go @@ -29,7 +29,7 @@ import ( "configcenter/src/common/metadata" "configcenter/src/common/util" "configcenter/src/scene_server/admin_server/logics" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/redis" ) @@ -105,7 +105,7 @@ func (s *syncor) SyncIAM(iamCli *iamcli.IAM, redisCli redis.Client, lgc *logics. rid := util.GenerateRID() for dbReady := false; !dbReady; { var err error - dbReady, err = upgrader.DBReady(context.Background(), s.db) + dbReady, err = history.DBReady(context.Background(), s.db) if err != nil { blog.Errorf("sync iam, check whether db initialization is complete failed, err: %v, rid: %s", err, rid) time.Sleep(5 * time.Second) diff --git a/src/scene_server/admin_server/imports.go b/src/scene_server/admin_server/imports.go index b2d3544970..6d341475a3 100644 --- a/src/scene_server/admin_server/imports.go +++ b/src/scene_server/admin_server/imports.go @@ -15,105 +15,108 @@ package main import ( // v3.9.x - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202002131522" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202008101530" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202008121631" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202008172134" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202010131456" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202010151455" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202010151650" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202010211805" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202010281615" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011021415" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011021501" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011171550" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011172152" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011192014" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011201146" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011241510" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011251014" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202011301723" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202012011450" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202101061721" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202102011055" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202102261105" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202103031533" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202103231621" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202104011012" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202104211151" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202105261459" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202106031151" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202106291420" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202106301910" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202107011154" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202107161611" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202107271940" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202107301510" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202107311844" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202112061431" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202112071130" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.9.202112071431" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202002131522" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202008101530" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202008121631" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202008172134" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202010131456" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202010151455" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202010151650" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202010211805" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202010281615" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011021415" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011021501" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011171550" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011172152" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011192014" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011201146" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011241510" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011251014" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202011301723" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202012011450" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202101061721" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202102011055" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202102261105" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202103031533" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202103231621" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202104011012" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202104211151" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202105261459" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202106031151" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202106291420" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202106301910" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202107011154" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202107161611" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202107271940" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202107301510" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202107311844" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202112061431" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202112071130" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.9.202112071431" // v3.10.x - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202104221702" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202105251041" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202105261459" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202106031151" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202107011735" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202107021056" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202107161611" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202107271945" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202107301510" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202107311844" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202109131607" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202109181134" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202112071130" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202112071431" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202112171521" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202203011516" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202203021455" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202203031512" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202204181447" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202204271725" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202205182148" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202206081408" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202208032125" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202209231617" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202209281408" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202302031117" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202302062350" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202303072103" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202303301611" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202303301718" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202304012150" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202305110949" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202305151505" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.10.202307171520" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202104221702" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202105251041" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202105261459" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202106031151" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202107011735" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202107021056" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202107161611" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202107271945" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202107301510" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202107311844" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202109131607" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202109181134" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202112071130" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202112071431" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202112171521" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202203011516" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202203021455" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202203031512" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202204181447" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202204271725" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202205182148" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202206081408" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202208032125" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202209231617" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202209281408" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202302031117" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202302062350" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202303072103" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202303301611" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202303301718" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202304012150" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202305110949" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202305151505" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.10.202307171520" // v3.11.x - _ "configcenter/src/scene_server/admin_server/upgrader/y3.11.202309050900" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.11.202309050900" // v3.12.x - _ "configcenter/src/scene_server/admin_server/upgrader/y3.12.202309211735" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.12.202310301633" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.12.202310302130" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.12.202311061800" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.12.202309211735" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.12.202310301633" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.12.202310302130" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.12.202311061800" // v3.13.x - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202401221600" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202402181900" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202402191140" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202402281158" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202403151855" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202404221100" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202405080955" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202407191507" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202408011044" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202408071435" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.13.202410091435" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202401221600" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202402181900" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202402191140" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202402281158" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202403151855" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202404221100" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202405080955" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202407191507" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202408011044" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202408071435" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.13.202410091435" // 3.14.x - _ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202404031701" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202405141035" - _ "configcenter/src/scene_server/admin_server/upgrader/y3.14.202410100930" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.14.202404031701" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.14.202405141035" + _ "configcenter/src/scene_server/admin_server/upgrader/history/y3.14.202410100930" + + // tenant + _ "configcenter/src/scene_server/admin_server/upgrader/y3.15.202411071530" ) diff --git a/src/scene_server/admin_server/logics/index.go b/src/scene_server/admin_server/logics/index.go index 932a558fa3..c572ab8188 100644 --- a/src/scene_server/admin_server/logics/index.go +++ b/src/scene_server/admin_server/logics/index.go @@ -29,7 +29,7 @@ import ( "configcenter/src/common/util" "configcenter/src/common/version" "configcenter/src/scene_server/admin_server/app/options" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/mongo/sharding" "configcenter/src/storage/dal/types" @@ -87,7 +87,7 @@ func RunSyncDBTableIndex(ctx context.Context, e *backbone.Engine, db dal.Dal, op for dbReady := false; !dbReady; { // 等待数据库初始化 var err error - dbReady, err = upgrader.DBReady(ctx, db) + dbReady, err = history.DBReady(ctx, db) if err != nil { blog.Errorf("check whether the db initialization is complete failed, err: %v, rid: %s", err, rid) } @@ -167,7 +167,7 @@ func RunSyncDBIndex(ctx context.Context, e *backbone.Engine) error { return ccErr.CCError(common.CCErrCommDBSelectFailed) } // defaultDBTable DBSync 负责在启动时候初始化 - dbReady, err := upgrader.DBReady(ctx, defaultDBTable) + dbReady, err := history.DBReady(ctx, defaultDBTable) if err != nil { blog.Errorf("check whether the db initialization is complete failed, err: %v, rid: %s", err, rid) return ccErr.CCError(common.CCErrCommDBSelectFailed) @@ -662,7 +662,7 @@ func (dt *dbTable) findObjUniques(ctx context.Context, objID string) ([]types.In uniqueIdxs := make([]metadata.ObjectUnique, 0) if err := dt.db.Table(common.BKTableNameObjUnique).Find(filter).All(ctx, &uniqueIdxs); err != nil { newErr := fmt.Errorf("get obj(%s) logic unique index error. err: %s", objID, err.Error()) - blog.ErrorJSON("%s, rid: %s", newErr.Error(), dt.rid) + blog.Errorf("%s, rid: %s", newErr.Error(), dt.rid) return nil, newErr } @@ -677,7 +677,7 @@ func (dt *dbTable) findObjUniques(ctx context.Context, objID string) ([]types.In newDBIndex, err := index.ToDBUniqueIndex(objID, idx.ID, idx.Keys, attrs) if err != nil { newErr := fmt.Errorf("obj(%s). %s", objID, err.Error()) - blog.ErrorJSON("%s, rid: %s", newErr.Error(), dt.rid) + blog.Errorf("%s, rid: %s", newErr.Error(), dt.rid) return nil, newErr } indexes = append(indexes, newDBIndex) diff --git a/src/scene_server/admin_server/service/migrate.go b/src/scene_server/admin_server/service/migrate.go index 0e75238eab..f62c4d80eb 100644 --- a/src/scene_server/admin_server/service/migrate.go +++ b/src/scene_server/admin_server/service/migrate.go @@ -29,7 +29,7 @@ import ( "configcenter/src/common/types" "configcenter/src/common/version" "configcenter/src/common/watch" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/source_controller/cacheservice/event" daltypes "configcenter/src/storage/dal/types" "configcenter/src/storage/driver/mongodb" @@ -44,7 +44,7 @@ func (s *Service) migrate(req *restful.Request, resp *restful.Response) { rid := httpheader.GetRid(rHeader) defErr := s.CCErr.CreateDefaultCCErrorIf(httpheader.GetLanguage(rHeader)) tenantID := common.BKDefaultTenantID - updateCfg := &upgrader.Config{ + updateCfg := &history.Config{ TenantID: tenantID, User: common.CCSystemOperatorUserName, } @@ -59,7 +59,7 @@ func (s *Service) migrate(req *restful.Request, resp *restful.Response) { return } - preVersion, finishedVersions, err := upgrader.Upgrade(s.ctx, s.db.Shard(kit.SysShardOpts()), s.cache, s.iam, + preVersion, finishedVersions, err := history.Upgrade(s.ctx, s.db.Shard(kit.SysShardOpts()), s.cache, s.iam, updateCfg) if err != nil { blog.Errorf("db upgrade failed, err: %v, rid: %s", err, rid) @@ -119,26 +119,27 @@ func (s *Service) createWatchDBChainCollections(kit *rest.Kit) error { } err = tenant.ExecForAllTenants(func(tenantID string) error { - kit.TenantID = tenantID - exists, err := s.watchDB.Shard(kit.ShardOpts()).HasTable(s.ctx, key.ChainCollection()) + newKit := kit.NewKit() + newKit.TenantID = tenantID + exists, err := s.watchDB.Shard(newKit.ShardOpts()).HasTable(s.ctx, key.ChainCollection()) if err != nil { - blog.Errorf("check if table %s exists failed, err: %v, rid: %s", key.ChainCollection(), err, kit.Rid) + blog.Errorf("check if table %s exists failed, err: %v, rid: %s", key.ChainCollection(), err, newKit.Rid) return err } if !exists { - err = s.watchDB.Shard(kit.ShardOpts()).CreateTable(s.ctx, key.ChainCollection()) + err = s.watchDB.Shard(newKit.ShardOpts()).CreateTable(s.ctx, key.ChainCollection()) if err != nil && !mongodb.IsDuplicatedError(err) { - blog.Errorf("create table %s failed, err: %v, rid: %s", key.ChainCollection(), err, kit.Rid) + blog.Errorf("create table %s failed, err: %v, rid: %s", key.ChainCollection(), err, newKit.Rid) return err } } - if err = s.createWatchIndexes(kit, tenantID, cursorType, key); err != nil { + if err = s.createWatchIndexes(newKit, tenantID, cursorType, key); err != nil { return err } - if err = s.createWatchToken(kit, tenantID, key); err != nil { + if err = s.createWatchToken(newKit, tenantID, key); err != nil { return err } return nil @@ -152,10 +153,12 @@ func (s *Service) createWatchDBChainCollections(kit *rest.Kit) error { func (s *Service) createWatchIndexes(kit *rest.Kit, tenantID string, cursorType watch.CursorType, key event.Key) error { indexes := []daltypes.Index{ - {Name: "index_id", Keys: bson.D{{common.BKFieldID, -1}}, Background: true, Unique: true}, - {Name: "index_cursor", Keys: bson.D{{common.BKCursorField, -1}}, Background: true, Unique: true}, - {Name: "index_cluster_time", Keys: bson.D{{common.BKClusterTimeField, -1}}, Background: true, - ExpireAfterSeconds: dbChainTTLTime}, + {Name: common.CCLogicUniqueIdxNamePrefix + "ID", Keys: bson.D{{common.BKFieldID, -1}}, Background: true, + Unique: true}, + {Name: common.CCLogicUniqueIdxNamePrefix + "cursor", Keys: bson.D{{common.BKCursorField, -1}}, Background: true, + Unique: true}, + {Name: common.CCLogicIndexNamePrefix + "clusterTime", Keys: bson.D{{common.BKClusterTimeField, -1}}, + Background: true, ExpireAfterSeconds: dbChainTTLTime}, } if cursorType == watch.ObjectBase || cursorType == watch.MainlineInstance || cursorType == watch.InstAsst { @@ -259,7 +262,7 @@ func (s *Service) migrateSpecifyVersion(req *restful.Request, resp *restful.Resp rid := httpheader.GetRid(rHeader) defErr := s.CCErr.CreateDefaultCCErrorIf(httpheader.GetLanguage(rHeader)) tenantID := common.BKDefaultTenantID - updateCfg := &upgrader.Config{ + updateCfg := &history.Config{ TenantID: tenantID, User: common.CCSystemOperatorUserName, } @@ -278,7 +281,7 @@ func (s *Service) migrateSpecifyVersion(req *restful.Request, resp *restful.Resp } kit := rest.NewKitFromHeader(rHeader, s.CCErr) - err := upgrader.UpgradeSpecifyVersion(s.ctx, s.db.Shard(kit.SysShardOpts()), s.cache, s.iam, updateCfg, + err := history.UpgradeSpecifyVersion(s.ctx, s.db.Shard(kit.SysShardOpts()), s.cache, s.iam, updateCfg, input.Version) if err != nil { blog.Errorf("db upgrade specify failed, err: %+v, rid: %s", err, rid) diff --git a/src/scene_server/admin_server/service/service.go b/src/scene_server/admin_server/service/service.go index 5b1baeaea1..a2f1adab04 100644 --- a/src/scene_server/admin_server/service/service.go +++ b/src/scene_server/admin_server/service/service.go @@ -70,6 +70,11 @@ func (s *Service) SetDB(db dal.Dal) { s.db = db } +// GetDB get db +func (s *Service) GetDB() dal.Dal { + return s.db +} + // SetWatchDB set watch db func (s *Service) SetWatchDB(watchDB dal.Dal) { s.watchDB = watchDB @@ -103,6 +108,7 @@ func (s *Service) WebService() *restful.Container { api.Route(api.POST("/authcenter/init").To(s.InitAuthCenter)) api.Route(api.POST("/authcenter/register").To(s.RegisterAuthAccount)) api.Route(api.POST("/migrate/{distribution}/{ownerID}").To(s.migrate)) + api.Route(api.POST("/migrate/tenantversion/database").To(s.migrateDatabase)) api.Route(api.POST("/migrate/system/hostcrossbiz/{ownerID}").To(s.SetSystemConfiguration)) api.Route(api.POST("/migrate/system/user_config/{key}/{can}").To(s.UserConfigSwitch)) api.Route(api.GET("/find/system/config_admin").To(s.SearchConfigAdmin)) diff --git a/src/scene_server/admin_server/service/tenant_upgrader.go b/src/scene_server/admin_server/service/tenant_upgrader.go new file mode 100644 index 0000000000..ba30b0c881 --- /dev/null +++ b/src/scene_server/admin_server/service/tenant_upgrader.go @@ -0,0 +1,64 @@ +package service + +import ( + "net/http" + + "configcenter/src/common" + "configcenter/src/common/blog" + httpheader "configcenter/src/common/http/header" + "configcenter/src/common/http/rest" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "github.com/emicklei/go-restful/v3" +) + +func (s *Service) migrateDatabase(req *restful.Request, resp *restful.Response) { + + rHeader := req.Request.Header + rid := httpheader.GetRid(rHeader) + defErr := s.CCErr.CreateDefaultCCErrorIf(httpheader.GetLanguage(rHeader)) + tenantID := common.BKDefaultTenantID + updateCfg := &upgrader.Config{ + TenantID: tenantID, + User: common.CCSystemOperatorUserName, + } + + kit := rest.NewKitFromHeader(rHeader, s.CCErr) + if err := s.createWatchDBChainCollections(kit); err != nil { + blog.Errorf("create watch db chain collections failed, err: %v, rid: %s", err, rid) + result := &metadata.RespError{ + Msg: defErr.Errorf(common.CCErrCommMigrateFailed, err.Error()), + } + resp.WriteError(http.StatusInternalServerError, result) + return + } + + preVersion, finishedVersions, err := upgrader.Upgrade(kit, s.db, updateCfg) + if err != nil { + blog.Errorf("db upgrade failed, err: %v, current version: %s, rid: %s", err, preVersion, rid) + result := &metadata.RespError{ + Msg: defErr.Errorf(common.CCErrCommMigrateFailed, err.Error()), + } + resp.WriteError(http.StatusInternalServerError, result) + return + } + + currentVersion := preVersion + if len(finishedVersions) > 0 { + currentVersion = finishedVersions[len(finishedVersions)-1] + } + + result := MigrationResponse{ + BaseResp: metadata.BaseResp{ + Result: true, + Code: 0, + ErrMsg: "", + Permissions: nil, + }, + Data: "migrate success", + PreVersion: preVersion, + CurrentVersion: currentVersion, + FinishedVersions: finishedVersions, + } + resp.WriteEntity(result) +} diff --git a/src/scene_server/admin_server/upgrader/common.go b/src/scene_server/admin_server/upgrader/common.go new file mode 100644 index 0000000000..530333b4b5 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/common.go @@ -0,0 +1,52 @@ +package upgrader + +import ( + "regexp" + "sync" + + "configcenter/src/common/http/rest" + "configcenter/src/storage/dal" +) + +// SystemTypeVersion system type version +const SystemTypeVersion = "version" + +var ( + registerLock sync.Mutex + UpgraderPool = []Upgrader{} + validVersionRegx = regexp.MustCompile(`^y(\d+\.){2}\d{12}$`) // yx.xx.xxxxxxxxxxxx +) + +// Upgrader define a version upgrader +type Upgrader struct { + version string + do func(*rest.Kit, dal.Dal, *Config) error +} + +// Version version info +type Version struct { + System `bson:",inline"` + CurrentVersion string `bson:"current_version"` + Distro string `bson:"distro"` + DistroVersion string `bson:"distro_version"` + InitVersion string `bson:"init_version"` + InitDistroVersion string `bson:"init_distro_version"` +} + +// System system info +type System struct { + Type string `bson:"type"` +} + +// Config config for upgrader +type Config struct { + TenantID string + User string +} + +// 后续改为从tenant包获取 +func GetBlueKingKit() *rest.Kit { + blueKingKit := rest.NewKit() + blueKingKit.TenantID = "default" + return blueKingKit +} diff --git a/src/scene_server/admin_server/upgrader/compare.go b/src/scene_server/admin_server/upgrader/history/compare.go similarity index 99% rename from src/scene_server/admin_server/upgrader/compare.go rename to src/scene_server/admin_server/upgrader/history/compare.go index 4c23239cf6..d4fa2acc39 100644 --- a/src/scene_server/admin_server/upgrader/compare.go +++ b/src/scene_server/admin_server/upgrader/history/compare.go @@ -10,7 +10,7 @@ * limitations under the License. */ -package upgrader +package history import ( "fmt" diff --git a/src/scene_server/admin_server/upgrader/configadmin.go b/src/scene_server/admin_server/upgrader/history/configadmin.go similarity index 99% rename from src/scene_server/admin_server/upgrader/configadmin.go rename to src/scene_server/admin_server/upgrader/history/configadmin.go index 77d7356b93..99ade440a4 100644 --- a/src/scene_server/admin_server/upgrader/configadmin.go +++ b/src/scene_server/admin_server/upgrader/history/configadmin.go @@ -10,7 +10,7 @@ * limitations under the License. */ -package upgrader +package history import ( "context" diff --git a/src/scene_server/admin_server/upgrader/doc.go b/src/scene_server/admin_server/upgrader/history/doc.go similarity index 98% rename from src/scene_server/admin_server/upgrader/doc.go rename to src/scene_server/admin_server/upgrader/history/doc.go index b3198673c0..8bf5815b2b 100644 --- a/src/scene_server/admin_server/upgrader/doc.go +++ b/src/scene_server/admin_server/upgrader/history/doc.go @@ -16,4 +16,4 @@ // when use date instead of version, the date should add x prefix, cause x > v // example: x08.09.04.01 -package upgrader +package history diff --git a/src/scene_server/admin_server/upgrader/history/register.go b/src/scene_server/admin_server/upgrader/history/register.go new file mode 100644 index 0000000000..6cb9530a74 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/history/register.go @@ -0,0 +1,387 @@ +/* + * Tencent is pleased to support the open source community by making 蓝鲸 available. + * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved. + * Licensed under the MIT License (the "License"); you may not use this file except + * in compliance with the License. You may obtain a copy of the License at + * http://opensource.org/licenses/MIT + * Unless required by applicable law or agreed to in writing, software distributed under + * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific language governing permissions and + * limitations under the License. + */ + +package history + +import ( + "context" + "fmt" + "regexp" + "sort" + "strings" + "sync" + "time" + + "configcenter/src/ac/iam" + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/util" + ccversion "configcenter/src/common/version" + "configcenter/src/storage/dal" + "configcenter/src/storage/dal/mongo/sharding" + "configcenter/src/storage/dal/redis" +) + +// Config config for upgrader +type Config struct { + TenantID string + User string +} + +// Upgrader define a version upgrader +type Upgrader struct { + version string // v3.0.8-beta.11 + do func(context.Context, dal.RDB, redis.Client, *iam.IAM, *Config) error +} + +var upgraderPool = []Upgrader{} + +var registLock sync.Mutex + +/* + v3.5.x format: + x19_09_03_02 + v3.6.x format: + y3.6.201911081042 + legacy format: + v3.0.8 + v3.0.9-beta.1 + x18_12_13_02 + x08.09.04.01 + x18.09.30.01 + x19.01.18.01 + x19_09_03_02 +*/ + +// LegacyMigrationVersion TODO +var LegacyMigrationVersion = []string{ + "v3.0.8", + "v3.0.9-beta.1", + "v3.0.9-beta.3", + "v3.1.0-alpha.2", + "x08.09.04.01", + "x08.09.11.01", + "x08.09.13.01", + "x08.09.17.01", + "x08.09.18.01", + "x08.09.26.01", + "x18.09.30.01", + "x18.10.10.01", + "x18.10.30.01", + "x18.10.30.02", + "x18.11.19.01", + "x18.12.12.01", + "x18.12.12.02", + "x18.12.12.03", + "x18.12.12.04", + "x18.12.12.05", + "x18.12.12.06", + "x18.12.13.01", + "x18_12_13_02", + "x19.01.18.01", + "x19.02.15.10", + "x19.04.16.01", + "x19.04.16.02", + "x19.04.16.03", + "x19.05.16.01", + "x19_05_22_01", + "x19_08_19_01", + "x19_08_20_01", + "x19_08_26_02", + "x19_09_03_01", + "x19_09_03_02", + "x19_09_03_03", + "x19_09_03_04", + "x19_09_03_05", + "x19_09_03_06", + "x19_09_03_07", + "x19_09_03_08", + "x19_09_06_01", + "x19_09_27_01", + "x19_10_09_01", + "x19_10_22_01", +} + +// ValidMigrationVersionFormat TODO +var ValidMigrationVersionFormat = []*regexp.Regexp{ + // regexp.MustCompile(`^v(\d+\.){2}\d+$`), + // regexp.MustCompile(`^v(\d+\.){2}\d+\-beta\.\d+$`), + // regexp.MustCompile(`^v(\d+\.){2}\d+\-alpha\.\d+$`), + // regexp.MustCompile(`^x(\d+\.){3}\d+$`), + + // v3.5.x version format + regexp.MustCompile(`^x(\d+_){3}\d+$`), + // v3.6.x version format + regexp.MustCompile(`^y(\d+\.){2}\d{12}$`), +} + +// ValidateMigrationVersionFormat TODO +func ValidateMigrationVersionFormat(version string) error { + // only check newer add migration's version + if util.InStrArr(LegacyMigrationVersion, version) { + return nil + } + match := false + for _, re := range ValidMigrationVersionFormat { + if re.MatchString(version) { + match = true + break + } + } + if !match { + err := fmt.Errorf(` + invalid migration version: %s, + please use a valid format: + x19_09_03_02(v3.5.x) + y3.6.201911081042(>=v3.6.x) + `, version) + return err + } + + // since v3.6.x migration version must + if strings.HasPrefix(version, VersionNgPrefix) { + ngVersion, err := ParseNgVersion(version) + if err != nil { + return err + } + + // third field in version split by `.` shouldn't greater than tomorrow + timeFormat := "200601021504" + maxMigrationTime := time.Now().AddDate(0, 0, 1) + maxVersionCurrently := maxMigrationTime.Format(timeFormat) + if ngVersion.Patch >= maxVersionCurrently { + err := fmt.Errorf(` + invalid time field of migration version: %s, + please use current time as part of migration version: + ex: y3.6.%s + `, version, time.Now().Format(timeFormat)) + return err + } + } + return nil +} + +// RegistUpgrader register upgrader +func RegistUpgrader(version string, handlerFunc func(context.Context, dal.RDB, *Config) error) { + if err := ValidateMigrationVersionFormat(version); err != nil { + blog.Fatalf("ValidateMigrationVersionFormat failed, err: %s", err.Error()) + } + registLock.Lock() + defer registLock.Unlock() + v := Upgrader{ + version: version, + do: func(ctx context.Context, rdb dal.RDB, cache redis.Client, iam *iam.IAM, config *Config) error { + return handlerFunc(ctx, rdb, config) + }, + } + upgraderPool = append(upgraderPool, v) +} + +// RegisterUpgraderWithRedis register upgrader with redis +func RegisterUpgraderWithRedis(version string, + handlerFunc func(context.Context, dal.RDB, redis.Client, *Config) error) { + if err := ValidateMigrationVersionFormat(version); err != nil { + blog.Fatalf("ValidateMigrationVersionFormat failed, err: %s", err.Error()) + } + registLock.Lock() + defer registLock.Unlock() + v := Upgrader{ + version: version, + do: func(ctx context.Context, rdb dal.RDB, cache redis.Client, iam *iam.IAM, config *Config) error { + return handlerFunc(ctx, rdb, cache, config) + }, + } + upgraderPool = append(upgraderPool, v) +} + +// RegisterUpgraderWithIAM register upgrader with iam +func RegisterUpgraderWithIAM(version string, + handlerFunc func(context.Context, dal.RDB, redis.Client, *iam.IAM, *Config) error) { + if err := ValidateMigrationVersionFormat(version); err != nil { + blog.Fatalf("validate migration version format failed, err: %s", err.Error()) + } + registLock.Lock() + defer registLock.Unlock() + v := Upgrader{ + version: version, + do: func(ctx context.Context, rdb dal.RDB, cache redis.Client, iam *iam.IAM, config *Config) error { + return handlerFunc(ctx, rdb, cache, iam, config) + }, + } + upgraderPool = append(upgraderPool, v) +} + +// Upgrade upgrade the db data to newest version +// we use date instead of version later since 2018.09.04, because the version wasn't manage by the developer +// ps: when use date instead of version, the date should add x prefix cause x > v +func Upgrade(ctx context.Context, db dal.RDB, cache redis.Client, iam *iam.IAM, conf *Config) ( + currentVersion string, finishedMigrations []string, err error) { + + sort.Slice(upgraderPool, func(i, j int) bool { + return VersionCmp(upgraderPool[i].version, upgraderPool[j].version) < 0 + }) + + cmdbVersion, err := getVersion(ctx, db) + if err != nil { + return "", nil, fmt.Errorf("getVersion failed, err: %s", err.Error()) + } + cmdbVersion.Distro = ccversion.CCDistro + cmdbVersion.DistroVersion = ccversion.CCDistroVersion + + currentVersion = remapVersion(cmdbVersion.CurrentVersion) + lastVersion := "" + finishedMigrations = make([]string, 0) + for _, v := range upgraderPool { + lastVersion = remapVersion(v.version) + if VersionCmp(v.version, currentVersion) <= 0 { + blog.Infof(`currentVision is "%s" skip upgrade "%s"`, currentVersion, v.version) + continue + } + blog.Infof(`run migration: %s`, v.version) + err = v.do(ctx, db, cache, iam, conf) + if err != nil { + blog.Errorf("upgrade version %s error: %s", v.version, err.Error()) + return currentVersion, finishedMigrations, fmt.Errorf("run migration %s failed, err: %s", v.version, + err.Error()) + } + cmdbVersion.CurrentVersion = v.version + err = saveVersion(ctx, db, cmdbVersion) + if err != nil { + blog.Errorf("save version %s error: %s", v.version, err.Error()) + return currentVersion, finishedMigrations, fmt.Errorf("saveVersion failed, err: %s", err.Error()) + } + finishedMigrations = append(finishedMigrations, v.version) + blog.Infof("upgrade to version %s success", v.version) + } + + if "" == cmdbVersion.InitVersion { + cmdbVersion.InitVersion = lastVersion + cmdbVersion.InitDistroVersion = ccversion.CCDistroVersion + if err := saveVersion(ctx, db, cmdbVersion); err != nil { + return currentVersion, finishedMigrations, fmt.Errorf("saveVersion failed, err: %s", err.Error()) + } + } + return currentVersion, finishedMigrations, nil +} + +// DBReady 已经执行过init_db. 数据库初始化成功 +func DBReady(ctx context.Context, db dal.Dal) (bool, error) { + + sort.Slice(upgraderPool, func(i, j int) bool { + return VersionCmp(upgraderPool[i].version, upgraderPool[j].version) < 0 + }) + + cmdbVersion, err := getVersion(ctx, db.Shard(sharding.NewShardOpts().WithIgnoreTenant())) + if err != nil { + return false, fmt.Errorf("getVersion failed, err: %s", err.Error()) + } + + currentVersion := "" + for _, v := range upgraderPool { + if VersionCmp(v.version, currentVersion) <= 0 { + blog.Infof(`currentVision is "%s" skip upgrade "%s"`, currentVersion, v.version) + continue + } + currentVersion = v.version + } + if currentVersion == cmdbVersion.CurrentVersion { + return true, nil + } + return false, nil +} + +// UpgradeSpecifyVersion 强制执行version版本的migrate, 不会修改数据库cc_System表中migrate 版本 +func UpgradeSpecifyVersion(ctx context.Context, db dal.RDB, cache redis.Client, iam *iam.IAM, conf *Config, + version string) (err error) { + + sort.Slice(upgraderPool, func(i, j int) bool { + return VersionCmp(upgraderPool[i].version, upgraderPool[j].version) < 0 + }) + + hasCurrent := false + for _, v := range upgraderPool { + if v.version != version { + continue + } + blog.Infof(`run specify migration: %s`, v.version) + err = v.do(ctx, db, cache, iam, conf) + if err != nil { + blog.Errorf("upgrade specify version %s error: %s", v.version, err.Error()) + return fmt.Errorf("run specify migration %s failed, err: %s", v.version, err.Error()) + } + hasCurrent = true + } + if !hasCurrent { + return fmt.Errorf("run specify migration %s failed, err: not found", version) + } + + return nil +} +func remapVersion(v string) string { + if correct, ok := wrongVersion[v]; ok { + return correct + } + return v +} + +var wrongVersion = map[string]string{ + "x18_10_10_01": "x18.10.10.01", +} + +func getVersion(ctx context.Context, db dal.RDB) (*Version, error) { + data := new(Version) + condition := map[string]interface{}{ + "type": SystemTypeVersion, + } + err := db.Table(common.BKTableNameSystem).Find(condition).One(ctx, &data) + if db.IsNotFoundError(err) { + data = new(Version) + data.Type = SystemTypeVersion + + err = db.Table(common.BKTableNameSystem).Insert(ctx, data) + if err != nil { + return nil, err + } + return data, nil + } + if err != nil { + blog.Errorf("get system version error,err:%s", err.Error()) + return nil, err + } + + return data, nil +} + +func saveVersion(ctx context.Context, db dal.RDB, version *Version) error { + condition := map[string]interface{}{ + "type": SystemTypeVersion, + } + return db.Table(common.BKTableNameSystem).Update(ctx, condition, version) +} + +// System TODO +type System struct { + Type string `bson:"type"` +} + +// Version TODO +type Version struct { + System `bson:",inline"` + CurrentVersion string `bson:"current_version"` + Distro string `bson:"distro"` + DistroVersion string `bson:"distro_version"` + InitVersion string `bson:"init_version"` + InitDistroVersion string `bson:"init_distro_version"` +} + +// SystemTypeVersion TODO +const SystemTypeVersion = "version" diff --git a/src/scene_server/admin_server/upgrader/history/upgrader.go b/src/scene_server/admin_server/upgrader/history/upgrader.go new file mode 100644 index 0000000000..a0fe58ea71 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/history/upgrader.go @@ -0,0 +1,2 @@ +// Package upgrader TODO +package history diff --git a/src/scene_server/admin_server/upgrader/util.go b/src/scene_server/admin_server/upgrader/history/util.go similarity index 99% rename from src/scene_server/admin_server/upgrader/util.go rename to src/scene_server/admin_server/upgrader/history/util.go index 80c8b967c7..baf26ed85f 100644 --- a/src/scene_server/admin_server/upgrader/util.go +++ b/src/scene_server/admin_server/upgrader/history/util.go @@ -10,7 +10,7 @@ * limitations under the License. */ -package upgrader +package history import ( "context" diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.8/addDefauleApp.go b/src/scene_server/admin_server/upgrader/history/v3.0.8/addDefauleApp.go index f0b30bc638..20815aaca3 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.8/addDefauleApp.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.8/addDefauleApp.go @@ -20,14 +20,13 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) var admin = "admin" -func addDefaultBiz(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { - +func addDefaultBiz(ctx context.Context, db dal.RDB, conf *history.Config) error { if count, err := db.Table(common.BKTableNameBaseApp).Find(mapstr.MapStr{common.BKAppNameField: common.DefaultAppName}).Count(ctx); err != nil { return err } else if count >= 1 { @@ -47,7 +46,7 @@ func addDefaultBiz(ctx context.Context, db dal.RDB, conf *upgrader.Config) error defaultBiz[common.CreateTimeField] = time.Now() defaultBiz[common.LastTimeField] = time.Now() filled := fillEmptyFields(defaultBiz, AppRow()) - bizID, _, err := upgrader.Upsert(ctx, db, common.BKTableNameBaseApp, defaultBiz, common.BKAppIDField, + bizID, _, err := history.Upsert(ctx, db, common.BKTableNameBaseApp, defaultBiz, common.BKAppIDField, []string{"bk_supplier_account", common.BKAppNameField, common.BKDefaultField}, append(filled, common.BKAppIDField)) if err != nil { @@ -65,7 +64,7 @@ func addDefaultBiz(ctx context.Context, db dal.RDB, conf *upgrader.Config) error defaultSet[common.CreateTimeField] = time.Now() defaultSet[common.LastTimeField] = time.Now() filled = fillEmptyFields(defaultSet, SetRow()) - setID, _, err := upgrader.Upsert(ctx, db, common.BKTableNameBaseSet, defaultSet, common.BKSetIDField, + setID, _, err := history.Upsert(ctx, db, common.BKTableNameBaseSet, defaultSet, common.BKSetIDField, []string{"bk_supplier_account", common.BKSetNameField, common.BKAppIDField, common.BKDefaultField}, append(filled, common.BKSetIDField)) if err != nil { @@ -84,7 +83,7 @@ func addDefaultBiz(ctx context.Context, db dal.RDB, conf *upgrader.Config) error defaultResModule[common.CreateTimeField] = time.Now() defaultResModule[common.LastTimeField] = time.Now() filled = fillEmptyFields(defaultResModule, ModuleRow()) - _, _, err = upgrader.Upsert(ctx, db, common.BKTableNameBaseModule, defaultResModule, common.BKModuleIDField, + _, _, err = history.Upsert(ctx, db, common.BKTableNameBaseModule, defaultResModule, common.BKModuleIDField, []string{"bk_supplier_account", common.BKModuleNameField, common.BKAppIDField, common.BKSetIDField, common.BKDefaultField}, append(filled, common.BKModuleIDField)) if err != nil { @@ -101,7 +100,7 @@ func addDefaultBiz(ctx context.Context, db dal.RDB, conf *upgrader.Config) error defaultFaultModule[common.CreateTimeField] = time.Now() defaultFaultModule[common.LastTimeField] = time.Now() filled = fillEmptyFields(defaultFaultModule, ModuleRow()) - _, _, err = upgrader.Upsert(ctx, db, common.BKTableNameBaseModule, defaultFaultModule, common.BKModuleIDField, + _, _, err = history.Upsert(ctx, db, common.BKTableNameBaseModule, defaultFaultModule, common.BKModuleIDField, []string{"bk_supplier_account", common.BKModuleNameField, common.BKAppIDField, common.BKSetIDField, common.BKDefaultField}, append(filled, common.BKModuleIDField)) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.8/addPlatData.go b/src/scene_server/admin_server/upgrader/history/v3.0.8/addPlatData.go index 4d514e02a3..64564ac495 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.8/addPlatData.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.8/addPlatData.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addPlatData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addPlatData(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameBasePlat blog.Infof("add data for %s table ", tableName) row := map[string]interface{}{ @@ -39,7 +39,7 @@ func addPlatData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { return err } - _, _, err = upgrader.Upsert(ctx, db, tableName, row, "", []string{common.BKCloudNameField, "bk_supplier_account"}, + _, _, err = history.Upsert(ctx, db, tableName, row, "", []string{common.BKCloudNameField, "bk_supplier_account"}, []string{common.BKCloudIDField}) if nil != err { blog.Errorf("add data for %s table error %s", tableName, err) diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.8/addPresetObjects.go b/src/scene_server/admin_server/upgrader/history/v3.0.8/addPresetObjects.go index c89ae3c54a..451d994516 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.8/addPresetObjects.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.8/addPresetObjects.go @@ -20,11 +20,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addPresetObjects(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func addPresetObjects(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addClassifications(ctx, db, conf) if err != nil { return err @@ -51,13 +51,13 @@ func addPresetObjects(ctx context.Context, db dal.RDB, conf *upgrader.Config) (e return nil } -func addAsstData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addAsstData(ctx context.Context, db dal.RDB, conf *history.Config) error { tablename := common.BKTableNameObjAsst blog.Errorf("add data for %s table ", tablename) rows := getAddAsstData(conf.TenantID) for _, row := range rows { // topo mainline could be changed,so need to ignore bk_asst_obj_id - _, _, err := upgrader.Upsert(ctx, db, tablename, row, "id", + _, _, err := history.Upsert(ctx, db, tablename, row, "id", []string{common.BKObjIDField, common.BKObjAttIDField, "bk_supplier_account"}, []string{"id", "bk_asst_obj_id"}) if nil != err { @@ -70,12 +70,12 @@ func addAsstData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { return nil } -func addObjAttDescData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addObjAttDescData(ctx context.Context, db dal.RDB, conf *history.Config) error { tablename := common.BKTableNameObjAttDes blog.Infof("add data for %s table ", tablename) rows := getObjAttDescData(conf.TenantID) for _, row := range rows { - _, _, err := upgrader.Upsert(ctx, db, tablename, row, "id", + _, _, err := history.Upsert(ctx, db, tablename, row, "id", []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"}, []string{}) if nil != err { blog.Errorf("add data for %s table error %s", tablename, err) @@ -98,12 +98,12 @@ func addObjAttDescData(ctx context.Context, db dal.RDB, conf *upgrader.Config) e return nil } -func addObjDesData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addObjDesData(ctx context.Context, db dal.RDB, conf *history.Config) error { tablename := common.BKTableNameObjDes blog.Errorf("add data for %s table ", tablename) rows := getObjectDesData(conf.TenantID) for _, row := range rows { - if _, _, err := upgrader.Upsert(ctx, db, tablename, row, "id", + if _, _, err := history.Upsert(ctx, db, tablename, row, "id", []string{common.BKObjIDField, common.BKClassificationIDField, "bk_supplier_account"}, []string{"id"}); err != nil { blog.Errorf("add data for %s table error %s", tablename, err) @@ -114,11 +114,11 @@ func addObjDesData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error return nil } -func addClassifications(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func addClassifications(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { tablename := common.BKTableNameObjClassification blog.Infof("add %s rows", tablename) for _, row := range classificationRows { - if _, _, err = upgrader.Upsert(ctx, db, tablename, row, "id", []string{common.BKClassificationIDField}, + if _, _, err = history.Upsert(ctx, db, tablename, row, "id", []string{common.BKClassificationIDField}, []string{"id"}); err != nil { blog.Errorf("add data for %s table error %s", tablename, err) return err @@ -127,12 +127,12 @@ func addClassifications(ctx context.Context, db dal.RDB, conf *upgrader.Config) return } -func addPropertyGroupData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addPropertyGroupData(ctx context.Context, db dal.RDB, conf *history.Config) error { tablename := common.BKTableNamePropertyGroup blog.Infof("add data for %s table", tablename) rows := getPropertyGroupData(conf.TenantID) for _, row := range rows { - _, _, err := upgrader.Upsert(ctx, db, tablename, row, "id", + _, _, err := history.Upsert(ctx, db, tablename, row, "id", []string{common.BKObjIDField, "bk_group_id"}, []string{"id"}) if err != nil && !db.IsDuplicatedError(err) { blog.Errorf("add data for %s table error %s", tablename, err) diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.8/addSystemData.go b/src/scene_server/admin_server/upgrader/history/v3.0.8/addSystemData.go index 355026bc51..bd81c5931c 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.8/addSystemData.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.8/addSystemData.go @@ -17,11 +17,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addSystemData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSystemData(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameSystem blog.V(3).Infof("add data for %s table ", tableName) data := map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.8/createtable.go b/src/scene_server/admin_server/upgrader/history/v3.0.8/createtable.go index 1ca23b1669..b06da19e02 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.8/createtable.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.8/createtable.go @@ -16,7 +16,7 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -29,7 +29,7 @@ const ( subscriptionIDField = "subscription_id" ) -func createTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func createTable(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { for tableName, indexes := range tables { exists, err := db.HasTable(ctx, tableName) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.8/pkg.go b/src/scene_server/admin_server/upgrader/history/v3.0.8/pkg.go index dba89dfac0..08c22928f4 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.8/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.8/pkg.go @@ -15,15 +15,15 @@ package v3v0v8 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("v3.0.8", upgrade) + history.RegistUpgrader("v3.0.8", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = createTable(ctx, db, conf) if err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.8/upgradeBKBiz.go b/src/scene_server/admin_server/upgrader/history/v3.0.8/upgradeBKBiz.go index 2606fbafa0..3f6615c088 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.8/upgradeBKBiz.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.8/upgradeBKBiz.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addBKApp add bk app -func addBKApp(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addBKApp(ctx context.Context, db dal.RDB, conf *history.Config) error { if count, err := db.Table(common.BKTableNameBaseApp).Find(mapstr.MapStr{common.BKAppNameField: common.BKAppName}).Count(ctx); err != nil { return err } else if count >= 1 { @@ -42,7 +42,7 @@ func addBKApp(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { appModelData[common.BKDefaultField] = common.DefaultFlagDefaultValue filled := fillEmptyFields(appModelData, AppRow()) var preData map[string]interface{} - bizID, preData, err := upgrader.Upsert(ctx, db, common.BKTableNameBaseApp, appModelData, common.BKAppIDField, + bizID, preData, err := history.Upsert(ctx, db, common.BKTableNameBaseApp, appModelData, common.BKAppIDField, []string{common.BKAppNameField, "bk_supplier_account"}, append(filled, common.BKAppIDField)) if err != nil { blog.Error("add addBKApp error ", err.Error()) @@ -101,7 +101,7 @@ func addBKApp(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { inputSetInfo[common.BKDefaultField] = common.DefaultResSetFlag inputSetInfo["bk_supplier_account"] = conf.TenantID filled = fillEmptyFields(inputSetInfo, SetRow()) - setID, _, err := upgrader.Upsert(ctx, db, common.BKTableNameBaseSet, inputSetInfo, common.BKSetIDField, + setID, _, err := history.Upsert(ctx, db, common.BKTableNameBaseSet, inputSetInfo, common.BKSetIDField, []string{"bk_supplier_account", common.BKAppIDField, common.BKSetNameField}, append(filled, common.BKSetIDField)) if err != nil { @@ -118,7 +118,7 @@ func addBKApp(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { inputResModuleInfo[common.BKDefaultField] = common.DefaultResModuleFlag inputResModuleInfo["bk_supplier_account"] = conf.TenantID filled = fillEmptyFields(inputResModuleInfo, ModuleRow()) - _, _, err = upgrader.Upsert(ctx, db, common.BKTableNameBaseModule, inputResModuleInfo, common.BKModuleIDField, + _, _, err = history.Upsert(ctx, db, common.BKTableNameBaseModule, inputResModuleInfo, common.BKModuleIDField, []string{"bk_supplier_account", common.BKModuleNameField, common.BKAppIDField, common.BKSetIDField}, append(filled, common.BKModuleIDField)) if err != nil { @@ -134,7 +134,7 @@ func addBKApp(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { inputFaultModuleInfo[common.BKDefaultField] = common.DefaultFaultModuleFlag inputFaultModuleInfo["bk_supplier_account"] = conf.TenantID filled = fillEmptyFields(inputFaultModuleInfo, ModuleRow()) - _, _, err = upgrader.Upsert(ctx, db, common.BKTableNameBaseModule, inputFaultModuleInfo, common.BKModuleIDField, + _, _, err = history.Upsert(ctx, db, common.BKTableNameBaseModule, inputFaultModuleInfo, common.BKModuleIDField, []string{"bk_supplier_account", common.BKModuleNameField, common.BKAppIDField, common.BKSetIDField}, append(filled, common.BKModuleIDField)) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/fixes_supplier_account.go b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/fixes_supplier_account.go index 0414e3c82e..8272d963b5 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/fixes_supplier_account.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/fixes_supplier_account.go @@ -15,11 +15,11 @@ package v3v0v9beta1 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func fixesSupplierAccount(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func fixesSupplierAccount(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { for _, tablename := range shouldAddSupplierAccountFieldTables { condition := map[string]interface{}{ "bk_supplier_account": map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/pkg.go b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/pkg.go index 89aa01c776..f84266f0a9 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.1/pkg.go @@ -15,15 +15,15 @@ package v3v0v9beta1 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("v3.0.9-beta.1", upgrade) + history.RegistUpgrader("v3.0.9-beta.1", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = fixesSupplierAccount(ctx, db, conf) if err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/fixes_port_pattern.go b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/fixes_port_pattern.go index d054762193..ebc2913b80 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/fixes_port_pattern.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/fixes_port_pattern.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func fixesProcessPortPattern(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func fixesProcessPortPattern(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { condition := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: "port", @@ -38,7 +38,7 @@ func fixesProcessPortPattern(ctx context.Context, db dal.RDB, conf *upgrader.Con return nil } -func fixesProcessPriorityPattern(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func fixesProcessPriorityPattern(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { condition := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: "priority", diff --git a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/pkg.go b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/pkg.go index 2d8dcdc043..343d14a91d 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/v3.0.9-beta.3/pkg.go @@ -15,15 +15,15 @@ package v3v0v9beta3 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("v3.0.9-beta.3", upgrade) + history.RegistUpgrader("v3.0.9-beta.3", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = fixesProcessPortPattern(ctx, db, conf) if err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/addBkStartParamRegex.go b/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/addBkStartParamRegex.go index 63dd323c32..4435593029 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/addBkStartParamRegex.go +++ b/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/addBkStartParamRegex.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addBkStartParamRegex(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func addBkStartParamRegex(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { tablename := common.BKTableNameObjAttDes now := time.Now() @@ -70,7 +70,7 @@ func addBkStartParamRegex(ctx context.Context, db dal.RDB, conf *upgrader.Config LastTime: &now, Description: "通过进程启动参数唯一识别进程,比如kafka和zookeeper的二进制名称为java,通过启动参数包含kafka或zookeeper来区分", } - _, _, err = upgrader.Upsert(ctx, db, tablename, row, "id", + _, _, err = history.Upsert(ctx, db, tablename, row, "id", []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"}, []string{}) if nil != err { blog.Errorf("[upgrade v3.1.0-alpha.2] addBkStartParamRegex %s", err) @@ -80,7 +80,7 @@ func addBkStartParamRegex(ctx context.Context, db dal.RDB, conf *upgrader.Config return nil } -func updateLanguageField(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func updateLanguageField(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { condition := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDApp, common.BKPropertyIDField: "language", diff --git a/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/pkg.go b/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/pkg.go index ee52275c4c..7bc4723d14 100644 --- a/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/v3.1.0-alpha.2/pkg.go @@ -15,15 +15,15 @@ package v3v0v1alpha2 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("v3.1.0-alpha.2", upgrade) + history.RegistUpgrader("v3.1.0-alpha.2", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addBkStartParamRegex(ctx, db, conf) if err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.04.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x08.09.04.01/pkg.go index 7739b76fd3..3fb3911fd2 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.04.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.04.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x08.09.04.01", upgrade) + history.RegistUpgrader("x08.09.04.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = updateSystemProperty(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x08.09.04.01] updateSystemProperty error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.04.01/updateSystemProperty.go b/src/scene_server/admin_server/upgrader/history/x08.09.04.01/updateSystemProperty.go index 106b91a523..a3618c4026 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.04.01/updateSystemProperty.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.04.01/updateSystemProperty.go @@ -17,11 +17,11 @@ import ( "configcenter/src/common" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateSystemProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func updateSystemProperty(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { objs := []metadata.Object{} condition := map[string]interface{}{ "bk_classification_id": "bk_biz_topo", @@ -48,7 +48,7 @@ func updateSystemProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config return db.Table(tablename).Update(ctx, condition, data) } -func fixesProcess(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func fixesProcess(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { condition := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: map[string]interface{}{"$in": []string{"priority", "proc_num", "auto_time_gap", diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.17.01/create_table_netcollect.go b/src/scene_server/admin_server/upgrader/history/x08.09.17.01/create_table_netcollect.go index cc491d04d8..a6c321bed5 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.17.01/create_table_netcollect.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.17.01/create_table_netcollect.go @@ -15,14 +15,14 @@ package x08_09_17_01 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func createTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func createTable(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { for tablename, indexs := range tables { exists, err := db.HasTable(ctx, tablename) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.17.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x08.09.17.01/pkg.go index add2ebcb04..de1f351b6f 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.17.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.17.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x08.09.17.01", upgrade) + history.RegistUpgrader("x08.09.17.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = createTable(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x08.09.17.01] create table netcollect error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.18.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x08.09.18.01/pkg.go index 68954b60e8..3eb30299cf 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.18.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.18.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x08.09.18.01", upgrade) + history.RegistUpgrader("x08.09.18.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = fixedHostPlatAssocateRelation(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x08.09.18.01] fixedHostPlatAssocateRelation error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.18.01/upgrader.go b/src/scene_server/admin_server/upgrader/history/x08.09.18.01/upgrader.go index 5abec1e9e8..52c6ba7956 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.18.01/upgrader.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.18.01/upgrader.go @@ -20,14 +20,14 @@ import ( "configcenter/src/common" "configcenter/src/common/mapstr" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/mongo/local" "go.mongodb.org/mongo-driver/mongo/options" ) -func fixedHostPlatAssocateRelation(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func fixedHostPlatAssocateRelation(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { type instAsstStruct struct { ID int64 `bson:"id"` diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.26.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x08.09.26.01/pkg.go index 69d62c356d..4577bff1f6 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.26.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.26.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x08.09.26.01", upgrade) + history.RegistUpgrader("x08.09.26.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = updateProcessTooltips(ctx, db, conf) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/x08.09.26.01/upgrader.go b/src/scene_server/admin_server/upgrader/history/x08.09.26.01/upgrader.go index 92c4fbd874..99e4c18df5 100644 --- a/src/scene_server/admin_server/upgrader/history/x08.09.26.01/upgrader.go +++ b/src/scene_server/admin_server/upgrader/history/x08.09.26.01/upgrader.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -65,7 +65,7 @@ var dataWithCondition = []inputDatas{ }, } -func updateProcessTooltips(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func updateProcessTooltips(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { for _, input := range dataWithCondition { if err := db.Table(common.BKTableNameObjAttDes).Update(ctx, input.cond, input.data); nil != err { diff --git a/src/scene_server/admin_server/upgrader/history/x18.09.30.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.09.30.01/pkg.go index 5012b7781c..e76116d88f 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.09.30.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.09.30.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.09.30.01", upgrade) + history.RegistUpgrader("x18.09.30.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = cleanBKCloud(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.09.30.01] cleanBKCloud error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.09.30.01/upgrader.go b/src/scene_server/admin_server/upgrader/history/x18.09.30.01/upgrader.go index 45f60f7f3c..229ab0ae84 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.09.30.01/upgrader.go +++ b/src/scene_server/admin_server/upgrader/history/x18.09.30.01/upgrader.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func cleanBKCloud(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func cleanBKCloud(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { clouds := []map[string]interface{}{} diff --git a/src/scene_server/admin_server/upgrader/history/x18.10.10.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.10.10.01/pkg.go index efdbbae84e..0085b8bef2 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.10.10.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.10.10.01/pkg.go @@ -16,14 +16,14 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.10.10.01", upgrade) + history.RegistUpgrader("x18.10.10.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addProcOpTaskTable(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.10.10.01] addProcOpTaskTable error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.10.10.01/procsrv.go b/src/scene_server/admin_server/upgrader/history/x18.10.10.01/procsrv.go index e359a0bf3e..a16340717c 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.10.10.01/procsrv.go +++ b/src/scene_server/admin_server/upgrader/history/x18.10.10.01/procsrv.go @@ -16,7 +16,7 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -24,7 +24,7 @@ import ( "gopkg.in/mgo.v2" ) -func addProcOpTaskTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcOpTaskTable(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := "cc_ProcOpTask" exists, err := db.HasTable(ctx, tableName) if err != nil { @@ -48,7 +48,7 @@ func addProcOpTaskTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) } return nil } -func addProcInstanceModelTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcInstanceModelTable(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := "cc_ProcInstanceModel" exists, err := db.HasTable(ctx, tableName) if err != nil { @@ -75,7 +75,7 @@ func addProcInstanceModelTable(ctx context.Context, db dal.RDB, conf *upgrader.C } return nil } -func addProcInstanceDetailTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcInstanceDetailTable(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := "cc_ProcInstanceDetail" exists, err := db.HasTable(ctx, tableName) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/x18.10.30.01/association.go b/src/scene_server/admin_server/upgrader/history/x18.10.30.01/association.go index 7ae3961977..2dda326e88 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.10.30.01/association.go +++ b/src/scene_server/admin_server/upgrader/history/x18.10.30.01/association.go @@ -22,14 +22,14 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func createAssociationTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createAssociationTable(ctx context.Context, db dal.RDB, conf *history.Config) error { tablenames := []string{common.BKTableNameAsstDes, common.BKTableNameObjAsst, common.BKTableNameInstAsst} for _, tablename := range tablenames { exists, err := db.HasTable(ctx, tablename) @@ -45,7 +45,7 @@ func createAssociationTable(ctx context.Context, db dal.RDB, conf *upgrader.Conf return nil } -func createInstanceAssociationIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createInstanceAssociationIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { idxArr, err := db.Table(common.BKTableNameInstAsst).Indexes(ctx) if err != nil { @@ -82,7 +82,7 @@ func createInstanceAssociationIndex(ctx context.Context, db dal.RDB, conf *upgra } -func addPresetAssociationType(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addPresetAssociationType(ctx context.Context, db dal.RDB, conf *history.Config) error { tablename := common.BKTableNameAsstDes asstTypes := []metadata.AssociationKind{ @@ -143,7 +143,7 @@ func addPresetAssociationType(ctx context.Context, db dal.RDB, conf *upgrader.Co } for _, asstType := range asstTypes { - _, _, err := upgrader.Upsert(ctx, db, tablename, asstType, "id", []string{"bk_asst_id"}, []string{"id"}) + _, _, err := history.Upsert(ctx, db, tablename, asstType, "id", []string{"bk_asst_id"}, []string{"id"}) if err != nil { return err } @@ -157,7 +157,7 @@ type Association struct { ObjectAttID string `bson:"bk_object_att_id"` } -func reconcilAsstData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func reconcilAsstData(ctx context.Context, db dal.RDB, conf *history.Config) error { assts := []Association{} err := db.Table(common.BKTableNameObjAsst).Find(nil).All(ctx, &assts) @@ -343,7 +343,7 @@ func reconcilAsstData(ctx context.Context, db dal.RDB, conf *upgrader.Config) er return nil } -func dropFlagColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func dropFlagColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { flag := "updateflag" flagFilter := map[string]interface{}{ flag: map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/history/x18.10.30.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.10.30.01/pkg.go index c3de33a7f6..d3d85531ad 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.10.30.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.10.30.01/pkg.go @@ -16,14 +16,14 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.10.30.01", upgrade) + history.RegistUpgrader("x18.10.30.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = createAssociationTable(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.10.30.01] createAssociationTable error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.11.19.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.11.19.01/pkg.go index 1147e3147d..b3e07e1fcd 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.11.19.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.11.19.01/pkg.go @@ -16,14 +16,14 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.11.19.01", upgrade) + history.RegistUpgrader("x18.11.19.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = createObjectUnitTable(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.11.19.01] createObjectUnitTable error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.11.19.01/reconcil_unique.go b/src/scene_server/admin_server/upgrader/history/x18.11.19.01/reconcil_unique.go index e3d9f98de6..df3e9725e9 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.11.19.01/reconcil_unique.go +++ b/src/scene_server/admin_server/upgrader/history/x18.11.19.01/reconcil_unique.go @@ -22,11 +22,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func createObjectUnitTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createObjectUnitTable(ctx context.Context, db dal.RDB, conf *history.Config) error { tablenames := []string{common.BKTableNameObjUnique} for _, tablename := range tablenames { exists, err := db.HasTable(ctx, tablename) @@ -69,7 +69,7 @@ type Attribute struct { LastTime *time.Time `json:"last_time" bson:"last_time"` } -func reconcilUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func reconcilUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { oldAttributes := []Attribute{} err := db.Table(common.BKTableNameObjAttDes).Find(nil).All(ctx, &oldAttributes) @@ -298,7 +298,7 @@ func checkKeysShouldExists(m map[string]Attribute, shouldExistKeys []string) []s return notValidKeys } -func isUniqueExists(ctx context.Context, db dal.RDB, conf *upgrader.Config, unique objectUnique) (bool, error) { +func isUniqueExists(ctx context.Context, db dal.RDB, conf *history.Config, unique objectUnique) (bool, error) { keyhash := unique.KeysHash() uniqueCond := condition.CreateCondition() uniqueCond.Field(common.BKObjIDField).Eq(unique.ObjID) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/add_aix_property.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/add_aix_property.go index 6ca22d16f9..e9fb9f2000 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/add_aix_property.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/add_aix_property.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -51,7 +51,7 @@ type Attribute struct { LastTime *time.Time `json:"last_time" bson:"last_time"` } -func addAIXProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addAIXProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/pkg.go index d167372de5..b55430b5a0 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.12.12.01", upgrade) + history.RegistUpgrader("x18.12.12.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addAIXProperty(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.12.12.01] addAIXProperty error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/reconcil_unique.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/reconcil_unique.go index 30ae0520e2..2ed21ae54f 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/reconcil_unique.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/reconcil_unique.go @@ -22,11 +22,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func reconcilUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func reconcilUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { oldAttributes := []Attribute{} err := db.Table(common.BKTableNameObjAttDes).Find(mapstr.MapStr{common.BKObjIDField: common.BKInnerObjIDProc}).All(ctx, @@ -112,7 +112,7 @@ func checkKeysShouldExists(m map[string]Attribute, shouldExistKeys []string) []s return notValidKeys } -func isUniqueExists(ctx context.Context, db dal.RDB, conf *upgrader.Config, unique objectUnique) (bool, error) { +func isUniqueExists(ctx context.Context, db dal.RDB, conf *history.Config, unique objectUnique) (bool, error) { keyhash := unique.KeysHash() uniqueCond := condition.CreateCondition() uniqueCond.Field(common.BKObjIDField).Eq(unique.ObjID) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/set_tcp_default.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/set_tcp_default.go index 9c80f13ad1..00a93add4e 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.01/set_tcp_default.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.01/set_tcp_default.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func setTCPDefault(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func setTCPDefault(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.02/fix_module_name_property_group.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.02/fix_module_name_property_group.go index ca2b9ce895..c72b5e4e3f 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.02/fix_module_name_property_group.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.02/fix_module_name_property_group.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func fixModuleNamePropertyGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixModuleNamePropertyGroup(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.02/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.02/pkg.go index 9beec64712..2d1bf09ba2 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.02/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.02/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.12.12.02", upgrade) + history.RegistUpgrader("x18.12.12.02", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = fixModuleNamePropertyGroup(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.12.12.02] addAIXProperty error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixAssociationTypeName.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixAssociationTypeName.go index a94a372409..ec69390f88 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixAssociationTypeName.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixAssociationTypeName.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func fixAssociationTypeName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixAssociationTypeName(ctx context.Context, db dal.RDB, conf *history.Config) error { nameKV := map[string]string{ "run": "运行", diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixEventSubscribeLastTime.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixEventSubscribeLastTime.go index 3a4edba597..1b8f073df7 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixEventSubscribeLastTime.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.03/fixEventSubscribeLastTime.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -28,7 +28,7 @@ const ( subscriptionNameField = "subscription_name" ) -func fixEventSubscribeLastTime(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixEventSubscribeLastTime(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") cond.Field(subscriptionNameField).Like("process instance refresh") diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.03/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.03/pkg.go index 3d63e2a3bc..ecd967bb81 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.03/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.03/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.12.12.03", upgrade) + history.RegistUpgrader("x18.12.12.03", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = fixAssociationTypeName(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.12.12.03] fixAssociationTypeName error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.04/fix_bk_obj_asst_id.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.04/fix_bk_obj_asst_id.go index be835decff..52db6d4d13 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.04/fix_bk_obj_asst_id.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.04/fix_bk_obj_asst_id.go @@ -21,11 +21,11 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func fixBKObjAsstID(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixBKObjAsstID(ctx context.Context, db dal.RDB, conf *history.Config) error { findCond := condition.CreateCondition() findCond.Field(common.AssociationKindIDField).NotEq(common.AssociationKindMainline) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.04/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.04/pkg.go index b5e460d71c..8f0eec1c49 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.04/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.04/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.12.12.04", upgrade) + history.RegistUpgrader("x18.12.12.04", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = fixBKObjAsstID(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.12.12.04] fixBKObjAsstID error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.05/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.05/pkg.go index 61af9c9d1a..833fb4fd03 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.05/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.05/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.12.12.05", upgrade) + history.RegistUpgrader("x18.12.12.05", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err = createInstanceAssociationIndex(ctx, db, conf); err != nil { blog.Errorf("[upgrade x18.12.12.05] createInstanceAssociationIndex error %s", err.Error()) return err diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.05/remove_deleted_inst_asst.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.05/remove_deleted_inst_asst.go index 5823966654..420e69aa30 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.05/remove_deleted_inst_asst.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.05/remove_deleted_inst_asst.go @@ -23,7 +23,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/condition" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -35,7 +35,7 @@ var ( limit = uint64(2000) ) -func removeDeletedInstAsst(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeDeletedInstAsst(ctx context.Context, db dal.RDB, conf *history.Config) error { instAsstQueue := make(chan []metadata.InstAsst, 1000) assts := make([]*metadata.Association, 0) @@ -277,7 +277,7 @@ func getInstAsst(ctx context.Context, db dal.RDB, asstName string, maxID int64) } -func createInstanceAssociationIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createInstanceAssociationIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { idxArr, err := db.Table(bkTableNameInstAsst).Indexes(ctx) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.06/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.06/pkg.go index 73ddf469fb..2ef364e9e4 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.06/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.06/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.12.12.06", upgrade) + history.RegistUpgrader("x18.12.12.06", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = reconcilUnique(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x18.12.12.06] fixBKObjAsstID error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.12.06/reconcil_unique.go b/src/scene_server/admin_server/upgrader/history/x18.12.12.06/reconcil_unique.go index b0d7eddd49..349b7d314d 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.12.06/reconcil_unique.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.12.06/reconcil_unique.go @@ -22,13 +22,13 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func keyfunc(a, b string) string { return a + ":" + b } -func reconcilUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func reconcilUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { attrs := []metadata.Attribute{} attrCond := condition.CreateCondition() @@ -136,7 +136,7 @@ func checkKeysShouldExists(m map[string]metadata.Attribute, shouldExistKeys []st return notValidKeys } -func isUniqueExists(ctx context.Context, db dal.RDB, conf *upgrader.Config, unique objectUnique) (bool, error) { +func isUniqueExists(ctx context.Context, db dal.RDB, conf *history.Config, unique objectUnique) (bool, error) { keyhash := unique.KeysHash() uniqueCond := condition.CreateCondition() uniqueCond.Field(common.BKObjIDField).Eq(unique.ObjID) diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.13.01/addswitchAssociation.go b/src/scene_server/admin_server/upgrader/history/x18.12.13.01/addswitchAssociation.go index 77b3b5b128..f394b8c113 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.13.01/addswitchAssociation.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.13.01/addswitchAssociation.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addswitchAssociation(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addswitchAssociation(ctx context.Context, db dal.RDB, conf *history.Config) error { falseVar := false switchAsst := Association{ OwnerID: conf.TenantID, @@ -35,7 +35,7 @@ func addswitchAssociation(ctx context.Context, db dal.RDB, conf *upgrader.Config IsPre: &falseVar, } - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAsst, switchAsst, "id", + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAsst, switchAsst, "id", []string{"bk_obj_id", "bk_asst_obj_id"}, []string{"id"}) if err != nil { return err @@ -44,7 +44,7 @@ func addswitchAssociation(ctx context.Context, db dal.RDB, conf *upgrader.Config return nil } -func changeNetDeviceTableName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeNetDeviceTableName(ctx context.Context, db dal.RDB, conf *history.Config) error { err := db.DropTable(ctx, "cc_Netcollect_Device") if err != nil && !strings.Contains(err.Error(), "ns not found") { return err diff --git a/src/scene_server/admin_server/upgrader/history/x18.12.13.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x18.12.13.01/pkg.go index eae598ab62..4e61505e34 100644 --- a/src/scene_server/admin_server/upgrader/history/x18.12.13.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x18.12.13.01/pkg.go @@ -16,14 +16,14 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x18.12.13.01", upgrade) + history.RegistUpgrader("x18.12.13.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("from now on, the cmdb version will be v3.4.x") err = addswitchAssociation(ctx, db, conf) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/x19.01.18.01/drop_index.go b/src/scene_server/admin_server/upgrader/history/x19.01.18.01/drop_index.go index 89693e1cda..9ec652c284 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.01.18.01/drop_index.go +++ b/src/scene_server/admin_server/upgrader/history/x19.01.18.01/drop_index.go @@ -16,11 +16,11 @@ import ( "context" "strings" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func dropIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func dropIndex(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err = db.Table("cc_TopoGraphics"). DropIndex(ctx, "scope_id_1_node_type_1_bk_obj_id_1_bk_inst_id_1_scope_type_1"); err != nil && !strings.Contains(err.Error(), "not found") { diff --git a/src/scene_server/admin_server/upgrader/history/x19.01.18.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.01.18.01/pkg.go index a89ac7a4a4..eaab4e17ef 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.01.18.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.01.18.01/pkg.go @@ -15,15 +15,15 @@ package x19_01_18_01 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19.01.18.01", upgrade) + history.RegistUpgrader("x19.01.18.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = dropIndex(ctx, db, conf) if err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixAssociationTypeName.go b/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixAssociationTypeName.go index 3cb6ec9dac..984be1e5e7 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixAssociationTypeName.go +++ b/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixAssociationTypeName.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func fixAssociationTypeName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixAssociationTypeName(ctx context.Context, db dal.RDB, conf *history.Config) error { nameKV := map[string]string{ "run": "运行", diff --git a/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixEventSubscribeLastTime.go b/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixEventSubscribeLastTime.go index 165cb5e8a7..02cedb557c 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixEventSubscribeLastTime.go +++ b/src/scene_server/admin_server/upgrader/history/x19.02.15.10/fixEventSubscribeLastTime.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -28,7 +28,7 @@ const ( subscriptionNameField = "subscription_name" ) -func fixEventSubscribeLastTime(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixEventSubscribeLastTime(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") cond.Field(subscriptionNameField).Like("process instance refresh") diff --git a/src/scene_server/admin_server/upgrader/history/x19.02.15.10/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.02.15.10/pkg.go index 5b8e6780b2..867ba60b51 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.02.15.10/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.02.15.10/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19.02.15.10", upgrade) + history.RegistUpgrader("x19.02.15.10", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = fixAssociationTypeName(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x19.02.15.10] fixAssociationTypeName error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x19.04.16.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.04.16.01/pkg.go index c20b45015b..4f6bc914df 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.04.16.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.04.16.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19.04.16.01", upgrade) + history.RegistUpgrader("x19.04.16.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = removeDescriptionField(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x19.04.16.01] fixAssociationTypeName error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x19.04.16.01/removeDescriptionField.go b/src/scene_server/admin_server/upgrader/history/x19.04.16.01/removeDescriptionField.go index 984a6bb4d7..caa10009b9 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.04.16.01/removeDescriptionField.go +++ b/src/scene_server/admin_server/upgrader/history/x19.04.16.01/removeDescriptionField.go @@ -16,11 +16,11 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func removeDescriptionField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeDescriptionField(ctx context.Context, db dal.RDB, conf *history.Config) error { err := db.Table(common.BKTableNameObjAttDes).DropColumn(ctx, "description") if err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.04.16.02/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.04.16.02/pkg.go index ead6aab3aa..85d7b06924 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.04.16.02/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.04.16.02/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19.04.16.02", upgrade) + history.RegistUpgrader("x19.04.16.02", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = updateFranceName(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x19.04.16.02] updateFranceName error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x19.04.16.02/updateFranceName.go b/src/scene_server/admin_server/upgrader/history/x19.04.16.02/updateFranceName.go index f81c990c4c..320adf624b 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.04.16.02/updateFranceName.go +++ b/src/scene_server/admin_server/upgrader/history/x19.04.16.02/updateFranceName.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" ) -func updateFranceName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateFranceName(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field(common.BKObjIDField).Eq(common.BKInnerObjIDHost) cond.Field(common.BKPropertyIDField).Eq("bk_state_name") diff --git a/src/scene_server/admin_server/upgrader/history/x19.04.16.03/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.04.16.03/pkg.go index 2b05930deb..65daeee50a 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.04.16.03/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.04.16.03/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19.04.16.03", upgrade) + history.RegistUpgrader("x19.04.16.03", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = updateAttributeCreateTime(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x19.04.16.03] fixAssociationTypeName error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x19.04.16.03/updateAttributeCreateTime.go b/src/scene_server/admin_server/upgrader/history/x19.04.16.03/updateAttributeCreateTime.go index fe365a15d3..25d5c4cb14 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.04.16.03/updateAttributeCreateTime.go +++ b/src/scene_server/admin_server/upgrader/history/x19.04.16.03/updateAttributeCreateTime.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateAttributeCreateTime(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateAttributeCreateTime(ctx context.Context, db dal.RDB, conf *history.Config) error { var start uint64 type Attribute struct { diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_default_category.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_default_category.go index 46fc4bfff9..33584fe1b4 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_default_category.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_default_category.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -37,7 +37,7 @@ type ServiceCategory struct { IsBuiltIn bool `field:"is_built_in" json:"is_built_in" bson:"is_built_in"` } -func addDefaultCategory(ctx context.Context, db dal.RDB, conf *upgrader.Config) (int64, error) { +func addDefaultCategory(ctx context.Context, db dal.RDB, conf *history.Config) (int64, error) { firstCategory := ServiceCategory{} // insert first category diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_inner_category.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_inner_category.go index 31bb35ee0d..0a106a4451 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_inner_category.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_inner_category.go @@ -20,11 +20,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addInnerCategory(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addInnerCategory(ctx context.Context, db dal.RDB, conf *history.Config) error { innerCategories := []struct { Name string `field:"name" json:"name,omitempty" bson:"name"` ParentName string `field:"bk_parent_id" json:"bk_parent_id,omitempty" bson:"bk_parent_id"` diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_module_property.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_module_property.go index d740658dd1..fc2f4c2009 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_module_property.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/add_module_property.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addModuleProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addModuleProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -77,7 +77,7 @@ func addModuleProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) e } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceCategoryIDProperty, "id", uniqueFields, + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceCategoryIDProperty, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] addModuleProperty service_category_id failed, err: %+v", err) @@ -110,7 +110,7 @@ func addModuleProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) e LastTime: &now, } - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceTemplateIDProperty, "id", uniqueFields, + if _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceTemplateIDProperty, "id", uniqueFields, []string{}); err != nil { blog.Errorf("[upgrade v19.05.16.01] addModuleProperty service_template_id failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/change_process_name.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/change_process_name.go index 1477038892..3d1a31f218 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/change_process_name.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/change_process_name.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func changeProcessName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeProcessName(ctx context.Context, db dal.RDB, conf *history.Config) error { mapping := map[string]string{ common.BKProcessNameField: "进程别名", diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/create_table.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/create_table.go index 6db080f27c..1d938acf3e 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/create_table.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/create_table.go @@ -16,11 +16,11 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func createServiceTemplateTables(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createServiceTemplateTables(ctx context.Context, db dal.RDB, conf *history.Config) error { tables := []string{ common.BKTableNameServiceCategory, common.BKTableNameServiceTemplate, diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/pkg.go index 6b7cf13538..d1573468da 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19.05.16.01", upgrade) + history.RegistUpgrader("x19.05.16.01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("from now on, the cmdb version will be v3.5.x") err = changeProcessName(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/update_process_property.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/update_process_property.go index 96c0aff1ae..6f3f878343 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/update_process_property.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/update_process_property.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateProcessBindIPProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcessBindIPProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type BindOption struct { Name string `json:"name" bson:"name"` Type string `json:"type" bson:"type"` @@ -103,7 +103,7 @@ func updateProcessBindIPProperty(ctx context.Context, db dal.RDB, conf *upgrader } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, bindIPProperty, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, bindIPProperty, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] updateProcessBindIPProperty bind_ip failed, err: %+v", err) return err @@ -112,7 +112,7 @@ func updateProcessBindIPProperty(ctx context.Context, db dal.RDB, conf *upgrader return nil } -func updateProcessNameProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcessNameProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -164,7 +164,7 @@ func updateProcessNameProperty(ctx context.Context, db dal.RDB, conf *upgrader.C } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, ProcNameProperty, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, ProcNameProperty, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] updateProcessNameProperty bind_ip failed, err: %+v", err) return err @@ -173,7 +173,7 @@ func updateProcessNameProperty(ctx context.Context, db dal.RDB, conf *upgrader.C return nil } -func updateAutoTimeGapProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateAutoTimeGapProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -228,7 +228,7 @@ func updateAutoTimeGapProperty(ctx context.Context, db dal.RDB, conf *upgrader.C } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] updateAutoTimeGapProperty bind_ip failed, err: %+v", err) return err @@ -237,7 +237,7 @@ func updateAutoTimeGapProperty(ctx context.Context, db dal.RDB, conf *upgrader.C return nil } -func updateProcNumProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcNumProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -292,7 +292,7 @@ func updateProcNumProperty(ctx context.Context, db dal.RDB, conf *upgrader.Confi } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] updateProcNumProperty bind_ip failed, err: %+v", err) return err @@ -301,7 +301,7 @@ func updateProcNumProperty(ctx context.Context, db dal.RDB, conf *upgrader.Confi return nil } -func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -356,7 +356,7 @@ func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *upgrader.Conf } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] updatePriorityProperty bind_ip failed, err: %+v", err) return err @@ -365,7 +365,7 @@ func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *upgrader.Conf return nil } -func updateTimeoutProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateTimeoutProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -420,7 +420,7 @@ func updateTimeoutProperty(ctx context.Context, db dal.RDB, conf *upgrader.Confi } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] updateTimeoutProperty bind_ip failed, err: %+v", err) return err @@ -429,7 +429,7 @@ func updateTimeoutProperty(ctx context.Context, db dal.RDB, conf *upgrader.Confi return nil } -func updateProcessNamePropertyIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcessNamePropertyIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { processNameFilter := map[string]interface{}{ common.BKPropertyIDField: "bk_process_name", } @@ -443,7 +443,7 @@ func updateProcessNamePropertyIndex(ctx context.Context, db dal.RDB, conf *upgra return nil } -func updateFuncNamePropertyIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateFuncNamePropertyIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { funcNameFilter := map[string]interface{}{ common.BKPropertyIDField: "bk_func_name", } @@ -457,7 +457,7 @@ func updateFuncNamePropertyIndex(ctx context.Context, db dal.RDB, conf *upgrader return nil } -func deleteProcessUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func deleteProcessUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, } @@ -468,7 +468,7 @@ func deleteProcessUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) return nil } -func updateFuncIDProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateFuncIDProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -520,7 +520,7 @@ func updateFuncIDProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, property, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.05.16.01] updateFuncIDProperty bk_func_id failed, err: %+v", err) return err @@ -530,7 +530,7 @@ func updateFuncIDProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config } // UpdateProcPortPropertyGroupName TODO -func UpdateProcPortPropertyGroupName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func UpdateProcPortPropertyGroupName(ctx context.Context, db dal.RDB, conf *history.Config) error { // update proc_port group name row := &Group{ ObjectID: common.BKInnerObjIDProc, @@ -540,7 +540,7 @@ func UpdateProcPortPropertyGroupName(ctx context.Context, db dal.RDB, conf *upgr OwnerID: conf.TenantID, IsDefault: true, } - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNamePropertyGroup, row, "id", + if _, _, err := history.Upsert(ctx, db, common.BKTableNamePropertyGroup, row, "id", []string{common.BKObjIDField, "bk_group_id"}, []string{"id"}); err != nil { blog.Errorf("add data for %s table error %s", common.BKTableNamePropertyGroup, err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/upgrade_service_template.go b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/upgrade_service_template.go index 6d2d402288..a1b6ba0fd1 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.05.16.01/upgrade_service_template.go +++ b/src/scene_server/admin_server/upgrader/history/x19.05.16.01/upgrade_service_template.go @@ -25,7 +25,7 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/metadata" "configcenter/src/common/selector" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/mongo/local" @@ -140,7 +140,7 @@ type Process struct { StartParamRegex *string `field:"bk_start_param_regex" json:"bk_start_param_regex,omitempty" bson:"bk_start_param_regex,omitempty" structs:"bk_start_param_regex"` } -func upgradeServiceTemplate(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgradeServiceTemplate(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { mongo, ok := db.(*local.Mongo) if !ok { return fmt.Errorf("db is not *local.Mongo type") @@ -428,7 +428,7 @@ func upgradeServiceTemplate(ctx context.Context, db dal.RDB, conf *upgrader.Conf return db.Table(common.BKTableNameBaseProcess).Delete(ctx, mapstr.MapStr{"old_flag": true}) } -func backupProcessBase(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func backupProcessBase(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { start := uint64(0) limit := uint64(100) for { diff --git a/src/scene_server/admin_server/upgrader/history/x19.08.19.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.08.19.01/pkg.go index fa1704e60e..131f8ecfce 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.08.19.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.08.19.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_08_19_01", upgrade) + history.RegistUpgrader("x19_08_19_01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = removeProcFreshInstance(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x19.08.19.01] removeProcFreshInstance failed, err: %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x19.08.19.01/remove_proc_fresh_instance.go b/src/scene_server/admin_server/upgrader/history/x19.08.19.01/remove_proc_fresh_instance.go index d38e9987de..e918d51cb5 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.08.19.01/remove_proc_fresh_instance.go +++ b/src/scene_server/admin_server/upgrader/history/x19.08.19.01/remove_proc_fresh_instance.go @@ -16,7 +16,7 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -25,7 +25,7 @@ const ( subscriptionNameField = "subscription_name" ) -func removeProcFreshInstance(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeProcFreshInstance(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := tableNameSubscription SubscriptionName := "process instance refresh [Do not remove it]" filter := map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/history/x19.08.19.01/update_ip_regex.go b/src/scene_server/admin_server/upgrader/history/x19.08.19.01/update_ip_regex.go index 761872ea1a..682b45ef20 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.08.19.01/update_ip_regex.go +++ b/src/scene_server/admin_server/upgrader/history/x19.08.19.01/update_ip_regex.go @@ -16,14 +16,14 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // IPRegex TODO var IPRegex = `^((1?\d{1,2}|2[0-4]\d|25[0-5])[.]){3}(1?\d{1,2}|2[0-4]\d|25[0-5])(,((1?\d{1,2}|2[0-4]\d|25[0-5])[.]){3}(1?\d{1,2}|2[0-4]\d|25[0-5]))*$` -func updateIPRegex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateIPRegex(ctx context.Context, db dal.RDB, conf *history.Config) error { // host filter := map[string]interface{}{ common.BKPropertyIDField: map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/history/x19.08.20.01/delete_host_plat_association.go b/src/scene_server/admin_server/upgrader/history/x19.08.20.01/delete_host_plat_association.go index 5ad321f433..06c7d30ef7 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.08.20.01/delete_host_plat_association.go +++ b/src/scene_server/admin_server/upgrader/history/x19.08.20.01/delete_host_plat_association.go @@ -17,11 +17,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func upgradeDeleteHostPlatAssociation(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgradeDeleteHostPlatAssociation(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { cond := map[string]interface{}{ "bk_obj_id": common.BKInnerObjIDPlat, diff --git a/src/scene_server/admin_server/upgrader/history/x19.08.20.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.08.20.01/pkg.go index e84413a885..afd887b12f 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.08.20.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.08.20.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_08_20_01", upgrade) + history.RegistUpgrader("x19_08_20_01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("from now on, the cmdb version will be v3.5.x") if err := upgradeDeleteHostPlatAssociation(ctx, db, conf); err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.08.26.02/fix_service_instance_max_id.go b/src/scene_server/admin_server/upgrader/history/x19.08.26.02/fix_service_instance_max_id.go index 6f0d55b980..ec69d2e385 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.08.26.02/fix_service_instance_max_id.go +++ b/src/scene_server/admin_server/upgrader/history/x19.08.26.02/fix_service_instance_max_id.go @@ -17,7 +17,7 @@ import ( "fmt" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -28,7 +28,7 @@ type Idgen struct { } // FixServiceInstanceMaxID 将 cc_idgenerator 中 cc_ProcessTemplate 和 cc_ServiceInstance 两个key的值升级到他们的最大值 -func FixServiceInstanceMaxID(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func FixServiceInstanceMaxID(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ "_id": common.BKTableNameServiceInstance, } diff --git a/src/scene_server/admin_server/upgrader/history/x19.08.26.02/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.08.26.02/pkg.go index 720a68c6d8..eb75ab3776 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.08.26.02/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.08.26.02/pkg.go @@ -14,17 +14,18 @@ package x19_08_26_02 import ( "configcenter/src/common/blog" + "configcenter/src/scene_server/admin_server/upgrader/history" + "context" - "configcenter/src/scene_server/admin_server/upgrader" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_08_26_02", upgrade) + history.RegistUpgrader("x19_08_26_02", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := FixServiceInstanceMaxID(ctx, db, conf); err != nil { blog.Errorf("FixServiceInstanceMaxID failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.01/model_attr_group_collapse_flag.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.01/model_attr_group_collapse_flag.go index 427bc4d08b..fe7d95ebab 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.01/model_attr_group_collapse_flag.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.01/model_attr_group_collapse_flag.go @@ -17,11 +17,11 @@ import ( "fmt" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func setModelAttrGroupCollapseFlag(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func setModelAttrGroupCollapseFlag(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKIsCollapseField: map[string]interface{}{ common.BKDBExists: false, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.01/pkg.go index 0d82ff81bd..ea3bb94133 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.01/pkg.go @@ -14,17 +14,18 @@ package x19_09_03_01 import ( "configcenter/src/common/blog" + "configcenter/src/scene_server/admin_server/upgrader/history" + "context" - "configcenter/src/scene_server/admin_server/upgrader" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_01", upgrade) + history.RegistUpgrader("x19_09_03_01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := setModelAttrGroupCollapseFlag(ctx, db, conf); err != nil { blog.Errorf("upgrade x19_09_03_01 failed, setModelAttrGroupCollapseFlag failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.01/update_set_description_property.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.01/update_set_description_property.go index 7cb55d0ee1..60e9601997 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.01/update_set_description_property.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.01/update_set_description_property.go @@ -17,11 +17,11 @@ import ( "fmt" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateSetDescriptionProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateSetDescriptionProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDSet, common.BKPropertyIDField: common.BKSetDescField, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.02/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.02/pkg.go index 52953720a5..642e7b72fb 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.02/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.02/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_02", upgrade) + history.RegistUpgrader("x19_09_03_02", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := SetModuleServiceTemplateFieldUneditable(ctx, db, conf); err != nil { blog.Errorf("SetModuleServiceTemplateFieldUneditable failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.02/set_module_set_template_field_uneditable.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.02/set_module_set_template_field_uneditable.go index 943486783f..bfeb7b2f5f 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.02/set_module_set_template_field_uneditable.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.02/set_module_set_template_field_uneditable.go @@ -17,7 +17,7 @@ import ( "fmt" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -28,7 +28,7 @@ type Idgen struct { } // SetModuleServiceTemplateFieldUneditable TODO -func SetModuleServiceTemplateFieldUneditable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func SetModuleServiceTemplateFieldUneditable(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDModule, common.BKPropertyIDField: common.BKServiceTemplateIDField, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.03/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.03/pkg.go index bb656826b4..e691ec7978 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.03/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.03/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_03", upgrade) + history.RegistUpgrader("x19_09_03_03", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := AddProcAttrGroup(ctx, db, conf); err != nil { blog.Errorf("AddProcAttrGroup failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.03/set_module_set_template_field_uneditable.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.03/set_module_set_template_field_uneditable.go index d8a91cf4f0..e7426e3866 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.03/set_module_set_template_field_uneditable.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.03/set_module_set_template_field_uneditable.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -26,7 +26,7 @@ import ( var ProcMgrGroupID = "proc_mgr" // AddProcAttrGroup TODO -func AddProcAttrGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func AddProcAttrGroup(ctx context.Context, db dal.RDB, conf *history.Config) error { doc := map[string]interface{}{ common.BKIsCollapseField: true, common.BKPropertyGroupNameField: "进程管理信息", @@ -41,7 +41,7 @@ func AddProcAttrGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) er "bk_supplier_account": conf.TenantID, } uniqueFields := []string{common.BKObjIDField, common.BKPropertyGroupIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNamePropertyGroup, doc, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNamePropertyGroup, doc, "id", uniqueFields, []string{}) if err != nil { if db.IsNotFoundError(err) == false { return fmt.Errorf("upgrade x19_09_03_03, AddProcAttrGroup failed, err: %v", err) @@ -51,7 +51,7 @@ func AddProcAttrGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) er } // ChangeProcFieldGroup TODO -func ChangeProcFieldGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func ChangeProcFieldGroup(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: map[string]interface{}{ common.BKDBIN: []string{"bk_func_id", "work_path", "user", "proc_num", "priority", "timeout", diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.04/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.04/pkg.go index 8268a029aa..a9cd05b131 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.04/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.04/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_04", upgrade) + history.RegistUpgrader("x19_09_03_04", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := ChangeSetPropertyName(ctx, db, conf); err != nil { blog.Errorf("ChangeSetPropertyName failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.04/set_module_set_template_field_uneditable.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.04/set_module_set_template_field_uneditable.go index d0821b5351..f420ffd182 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.04/set_module_set_template_field_uneditable.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.04/set_module_set_template_field_uneditable.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // ChangeSetPropertyName TODO -func ChangeSetPropertyName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func ChangeSetPropertyName(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: "bk_set_name", common.BKObjIDField: common.BKInnerObjIDSet, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_inst_name_index.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_inst_name_index.go index 873d3b1e13..55dc3d832d 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_inst_name_index.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_inst_name_index.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -26,7 +26,7 @@ import ( ) // CreateInstNameIndex TODO -func CreateInstNameIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateInstNameIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { idx := types.Index{ Keys: bson.D{ {common.BKInstNameField, 1}, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_object_id_index.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_object_id_index.go index 5a8023680c..b3729c6820 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_object_id_index.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.05/create_object_id_index.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -26,7 +26,7 @@ import ( ) // CreateObjectIDIndex TODO -func CreateObjectIDIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateObjectIDIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { idx := types.Index{ Keys: bson.D{ {common.BKObjIDField, 1}, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.05/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.05/pkg.go index 7a22516810..cfa8b0aabc 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.05/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.05/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_05", upgrade) + history.RegistUpgrader("x19_09_03_05", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := CreateInstNameIndex(ctx, db, conf); err != nil { blog.Errorf("ChangeSetPropertyName failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.06/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.06/pkg.go index 9651ffe25f..1bfab7455d 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.06/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.06/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_06", upgrade) + history.RegistUpgrader("x19_09_03_06", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := ChangeProcPlaceholder(ctx, db, conf); err != nil { blog.Errorf("ChangeProcPlaceholder failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_proc_start_param_placeholder.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_proc_start_param_placeholder.go index ad710d5077..e755c82f9f 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_proc_start_param_placeholder.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_proc_start_param_placeholder.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // ChangeProcPlaceholder TODO -func ChangeProcPlaceholder(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func ChangeProcPlaceholder(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: "bk_start_param_regex", common.BKObjIDField: common.BKInnerObjIDProc, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_set_description_field_type.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_set_description_field_type.go index 0a1df2bca4..63d9f4ce9f 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_set_description_field_type.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.06/update_set_description_field_type.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // UpdateSetDescriptionFieldType TODO -func UpdateSetDescriptionFieldType(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func UpdateSetDescriptionFieldType(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDSet, common.BKPropertyIDField: common.BKSetDescField, diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.07/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.07/pkg.go index b0a40cdf7f..4a6309ac9e 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.07/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.07/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_07", upgrade) + history.RegistUpgrader("x19_09_03_07", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := RemoveMetadata(ctx, db, conf); err != nil { blog.Errorf("RemoveMetadata failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.07/remove_metadata.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.07/remove_metadata.go index 541cbc08c4..d2ec3954f4 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.07/remove_metadata.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.07/remove_metadata.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -37,7 +37,7 @@ const PageSize = 200 // common.BKTableNameProcessInstanceRelation, // RemoveMetadata TODO -func RemoveMetadata(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func RemoveMetadata(ctx context.Context, db dal.RDB, conf *history.Config) error { for _, tableName := range tables { if err := removeMetadata(ctx, db, conf, tableName); err != nil { blog.Errorf("removeMetadata on table: %s failed, err: %+v", tableName, err) @@ -47,7 +47,7 @@ func RemoveMetadata(ctx context.Context, db dal.RDB, conf *upgrader.Config) erro return nil } -func removeMetadata(ctx context.Context, db dal.RDB, conf *upgrader.Config, tableName string) error { +func removeMetadata(ctx context.Context, db dal.RDB, conf *history.Config, tableName string) error { type MetaDataItem struct { ID int64 `bson:"id"` Metadata metadata.Metadata `bson:"metadata"` @@ -98,7 +98,7 @@ func removeMetadata(ctx context.Context, db dal.RDB, conf *upgrader.Config, tabl } // RemoveMetadataProcess TODO -func RemoveMetadataProcess(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func RemoveMetadataProcess(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameBaseProcess type MetaDataItem struct { ProcessID int64 `bson:"bk_process_id"` @@ -150,7 +150,7 @@ func RemoveMetadataProcess(ctx context.Context, db dal.RDB, conf *upgrader.Confi } // RemoveMetadataFromRelation TODO -func RemoveMetadataFromRelation(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func RemoveMetadataFromRelation(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameProcessInstanceRelation type MetaDataItem struct { BkProcessID int64 `bson:"bk_process_id"` diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.08/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.08/pkg.go index bfd31e9820..def6031035 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.08/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.08/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_09_03_08", upgrade) + history.RegistUpgrader("x19_09_03_08", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := updateProcessIntProperty(ctx, db, conf); err != nil { blog.Errorf("upgrade to version x19_09_03_08 failed, updateAutoTimeGapProperty failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.09.03.08/update_process_property.go b/src/scene_server/admin_server/upgrader/history/x19.09.03.08/update_process_property.go index 6cc118bce2..311eb6465b 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.09.03.08/update_process_property.go +++ b/src/scene_server/admin_server/upgrader/history/x19.09.03.08/update_process_property.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateProcessIntProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcessIntProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { for _, property := range []string{"priority", "auto_time_gap", "timeout"} { filter := map[string]interface{}{ common.BKObjIDField: "process", diff --git a/src/scene_server/admin_server/upgrader/history/x19.10.22.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.10.22.01/pkg.go index 9b28e27035..d18424a4ab 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.10.22.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.10.22.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_10_22_01", upgrade) + history.RegistUpgrader("x19_10_22_01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = UpdateCpuUnit(ctx, db, conf) if err != nil { blog.Errorf("[upgrade x19_10_22_01] UpdateCpuUnit error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/x19.10.22.01/update_cpu_unit.go b/src/scene_server/admin_server/upgrader/history/x19.10.22.01/update_cpu_unit.go index 3833fbda35..55ca5f087d 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.10.22.01/update_cpu_unit.go +++ b/src/scene_server/admin_server/upgrader/history/x19.10.22.01/update_cpu_unit.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // UpdateCpuUnit TODO -func UpdateCpuUnit(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func UpdateCpuUnit(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDHost, common.BKPropertyIDField: "bk_cpu_mhz", diff --git a/src/scene_server/admin_server/upgrader/history/x19.10.22.02/add_host_index.go b/src/scene_server/admin_server/upgrader/history/x19.10.22.02/add_host_index.go index 1e1facf62a..163218856f 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.10.22.02/add_host_index.go +++ b/src/scene_server/admin_server/upgrader/history/x19.10.22.02/add_host_index.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -38,7 +38,7 @@ func isIndexExist(ctx context.Context, db dal.RDB, indexName string) (bool, erro return false, nil } -func addHostIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { indexName := "innerIP_platID" exist, err := isIndexExist(ctx, db, indexName) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/x19.10.22.02/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.10.22.02/pkg.go index 50563b5d4b..8cdcd53bd4 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.10.22.02/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.10.22.02/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_10_22_02", upgrade) + history.RegistUpgrader("x19_10_22_02", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := addHostIndex(ctx, db, conf); err != nil { blog.Errorf("upgrade to version x19_10_22_02 failed, addHostIndex failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.10.22.03/pkg.go b/src/scene_server/admin_server/upgrader/history/x19.10.22.03/pkg.go index a8e7b8c963..f68197f1f6 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.10.22.03/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x19.10.22.03/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x19_10_22_03", upgrade) + history.RegistUpgrader("x19_10_22_03", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := removeMainlinePropertyRequired(ctx, db, conf); err != nil { blog.Errorf("upgrade to version x19_10_22_03 failed, removeMainlinePropertyRequired failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x19.10.22.03/remove_mainline_property_required.go b/src/scene_server/admin_server/upgrader/history/x19.10.22.03/remove_mainline_property_required.go index fd8d837275..7a82fe0cdd 100644 --- a/src/scene_server/admin_server/upgrader/history/x19.10.22.03/remove_mainline_property_required.go +++ b/src/scene_server/admin_server/upgrader/history/x19.10.22.03/remove_mainline_property_required.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func removeMainlinePropertyRequired(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeMainlinePropertyRequired(ctx context.Context, db dal.RDB, conf *history.Config) error { // find mainline model cond := map[string]interface{}{common.AssociationKindIDField: common.AssociationKindMainline} assts := make([]metadata.Association, 0) diff --git a/src/scene_server/admin_server/upgrader/history/x20.01.13.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x20.01.13.01/pkg.go index 8eeddf2807..c19d7074da 100644 --- a/src/scene_server/admin_server/upgrader/history/x20.01.13.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x20.01.13.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x20_01_13_01", upgrade) + history.RegistUpgrader("x20_01_13_01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := updateNonePropertyGroup(ctx, db, conf); err != nil { blog.Errorf("upgrade to version x20_01_13_01 failed, updateNonePropertyGroup failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/x20.01.13.01/update_none_property_group.go b/src/scene_server/admin_server/upgrader/history/x20.01.13.01/update_none_property_group.go index d4b7b3e4e9..c3a9abdcad 100644 --- a/src/scene_server/admin_server/upgrader/history/x20.01.13.01/update_none_property_group.go +++ b/src/scene_server/admin_server/upgrader/history/x20.01.13.01/update_none_property_group.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateNonePropertyGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateNonePropertyGroup(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyGroupField: mCommon.GroupNone, } diff --git a/src/scene_server/admin_server/upgrader/history/x20.02.17.01/fix_proctemp_procname.go b/src/scene_server/admin_server/upgrader/history/x20.02.17.01/fix_proctemp_procname.go index 9dc0f51cbb..80991bf9c1 100644 --- a/src/scene_server/admin_server/upgrader/history/x20.02.17.01/fix_proctemp_procname.go +++ b/src/scene_server/admin_server/upgrader/history/x20.02.17.01/fix_proctemp_procname.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -44,7 +44,7 @@ type ProcessTemplate struct { SupplierAccount string `field:"bk_supplier_account" json:"bk_supplier_account,omitempty" bson:"bk_supplier_account"` } -func fixProcTemplateProcName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixProcTemplateProcName(ctx context.Context, db dal.RDB, conf *history.Config) error { conds := map[string]interface{}{ "$or": []interface{}{ diff --git a/src/scene_server/admin_server/upgrader/history/x20.02.17.01/pkg.go b/src/scene_server/admin_server/upgrader/history/x20.02.17.01/pkg.go index c0f56d1e9d..bc4dd6c27e 100644 --- a/src/scene_server/admin_server/upgrader/history/x20.02.17.01/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/x20.02.17.01/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("x20_02_17_01", upgrade) + history.RegistUpgrader("x20_02_17_01", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := fixProcTemplateProcName(ctx, db, conf); err != nil { blog.Errorf("upgrade to version x20_02_17_01 failed, updateNonePropertyGroup failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.10.202104221702/drop_plat_vpcid_index.go b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/drop_plat_vpcid_index.go similarity index 92% rename from src/scene_server/admin_server/upgrader/y3.10.202104221702/drop_plat_vpcid_index.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202104221702/drop_plat_vpcid_index.go index 714822ffc0..04b9fc069d 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202104221702/drop_plat_vpcid_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/drop_plat_vpcid_index.go @@ -16,11 +16,11 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func dropPlatVpcIDIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func dropPlatVpcIDIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ "bk_obj_id": "plat", "bk_property_id": "bk_vpc_id", diff --git a/src/scene_server/admin_server/upgrader/y3.10.202104221702/inner_object_index.go b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/inner_object_index.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.10.202104221702/inner_object_index.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202104221702/inner_object_index.go index f9b4685996..1d15aadcb7 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202104221702/inner_object_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/inner_object_index.go @@ -17,11 +17,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/index" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func syncInnerObjectIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func syncInnerObjectIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { allIndexes := index.TableIndexes() for tableName, indexes := range allIndexes { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202104221702/mapping.go b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/mapping.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.10.202104221702/mapping.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202104221702/mapping.go index b1ddb384bf..18919f4d92 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202104221702/mapping.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/mapping.go @@ -17,14 +17,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func instanceObjectIDMapping(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func instanceObjectIDMapping(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { exists, err := db.HasTable(ctx, objectBaseMapping) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202104221702/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202104221702/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202104221702/pkg.go index 73a879e70b..b7d150404f 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202104221702/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202104221702", upgrade) + history.RegistUpgrader("y3.10.202104221702", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Info("y3.10.202104221702") if err := dropPlatVpcIDIndex(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202104221702/split_inst_table.go b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/split_inst_table.go similarity index 99% rename from src/scene_server/admin_server/upgrader/y3.10.202104221702/split_inst_table.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202104221702/split_inst_table.go index 0710f9d59d..a1d9904c91 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202104221702/split_inst_table.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202104221702/split_inst_table.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" commIdx "configcenter/src/common/index" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -37,7 +37,7 @@ var ( pageSize = uint64(5000) ) -func splitTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func splitTable(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { objs := make([]object, 0) if err = db.Table(common.BKTableNameObjDes).Find(nil).Fields(common.BKObjIDField, common.BKIsPre, "bk_supplier_account").All(ctx, &objs); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202105251041/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202105251041/pkg.go similarity index 81% rename from src/scene_server/admin_server/upgrader/y3.10.202105251041/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202105251041/pkg.go index 7f16c73b46..d5b76274e9 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202105251041/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202105251041/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202105251041", upgrade) + history.RegistUpgrader("y3.10.202105251041", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Info("y3.10.202105251041") return deleteMustCheck(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202105251041/unqiue_index_delete_must_check.go b/src/scene_server/admin_server/upgrader/history/y3.10.202105251041/unqiue_index_delete_must_check.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.10.202105251041/unqiue_index_delete_must_check.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202105251041/unqiue_index_delete_must_check.go index 6730878be0..edae207a2e 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202105251041/unqiue_index_delete_must_check.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202105251041/unqiue_index_delete_must_check.go @@ -16,11 +16,11 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func deleteMustCheck(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func deleteMustCheck(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := db.Table("cc_ObjectUnique").DropColumn(ctx, "must_check"); err != nil { blog.Errorf("delete field(must_check) from table(cc_ObjectUnique) error. err: %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202105261459/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202105261459/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.10.202105261459/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202105261459/pkg.go index 592eaa0f5e..1e27b9d0ea 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202105261459/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202105261459/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202105261459", upgrade) + history.RegistUpgrader("y3.10.202105261459", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3.10.202105261459") err := updateConfigAdmin(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202105261459/update_config_admin.go b/src/scene_server/admin_server/upgrader/history/y3.10.202105261459/update_config_admin.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202105261459/update_config_admin.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202105261459/update_config_admin.go index 93e3a6a0d6..a5ea1eeda2 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202105261459/update_config_admin.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202105261459/update_config_admin.go @@ -10,16 +10,16 @@ * limitations under the License. */ -package y3_9_202105261459 +package y3_10_202105261459 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *history.Config) error { config := ` { "backend": { @@ -142,6 +142,6 @@ func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) e } } ` - upgrader.AddConfigAdminChangeItem("y3.9.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) - return upgrader.UpgradeConfigAdmin(ctx, db, "y3.9.202105261459") + history.AddConfigAdminChangeItem("y3.10.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) + return history.UpgradeConfigAdmin(ctx, db, "y3.10.202105261459") } diff --git a/src/scene_server/admin_server/upgrader/y3.10.202106031151/add_unix_property.go b/src/scene_server/admin_server/upgrader/history/y3.10.202106031151/add_unix_property.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.10.202106031151/add_unix_property.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202106031151/add_unix_property.go index 5fded967ce..430acf1a18 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202106031151/add_unix_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202106031151/add_unix_property.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -50,7 +50,7 @@ type attribute struct { LastTime *time.Time `json:"last_time" bson:"last_time"` } -func addUNIXProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addUNIXProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") diff --git a/src/scene_server/admin_server/upgrader/y3.10.202106031151/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202106031151/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.10.202106031151/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202106031151/pkg.go index 2492f24f99..feb8c77df3 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202106031151/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202106031151/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202106031151", upgrade) + history.RegistUpgrader("y3.10.202106031151", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addUNIXProperty(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.10.202106031151] addUnixProperty error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202106031151/update_process_pri_range.go b/src/scene_server/admin_server/upgrader/history/y3.10.202106031151/update_process_pri_range.go similarity index 90% rename from src/scene_server/admin_server/upgrader/y3.10.202106031151/update_process_pri_range.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202106031151/update_process_pri_range.go index 40fad05d1d..b95f4484a1 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202106031151/update_process_pri_range.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202106031151/update_process_pri_range.go @@ -5,11 +5,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107011735/drop_set_template_version_column.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107011735/drop_set_template_version_column.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.10.202107011735/drop_set_template_version_column.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107011735/drop_set_template_version_column.go index 39b4d31f06..4d4fd4e8ec 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107011735/drop_set_template_version_column.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107011735/drop_set_template_version_column.go @@ -6,13 +6,13 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) const step = 5000 -func dropVersionColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func dropVersionColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { existsVersionFilter := map[string]interface{}{ "version": map[string]interface{}{ common.BKDBExists: true, @@ -60,7 +60,7 @@ func dropVersionColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) e return nil } -func dropSetTplVersionColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func dropSetTplVersionColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { existsVersionFilter := map[string]interface{}{ "set_template_version": map[string]interface{}{ common.BKDBExists: true, diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107011735/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107011735/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.10.202107011735/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107011735/pkg.go index 4274ad264d..74e68618ec 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107011735/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107011735/pkg.go @@ -16,16 +16,16 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202107011735", upgrade) + history.RegistUpgrader("y3.10.202107011735", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = dropVersionColumn(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.10.202107011735] drop set template table version column error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107021056/change_host_attr_editable.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107021056/change_host_attr_editable.go similarity index 92% rename from src/scene_server/admin_server/upgrader/y3.10.202107021056/change_host_attr_editable.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107021056/change_host_attr_editable.go index 98c4948c97..623a4845ee 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107021056/change_host_attr_editable.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107021056/change_host_attr_editable.go @@ -15,12 +15,12 @@ package y3_10_202107021056 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // changeHostAttrEditable change host attributes that has the property group of auto to editable -func changeHostAttrEditable(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func changeHostAttrEditable(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { filter := map[string]interface{}{ "bk_property_group": "auto", "bk_obj_id": "host", diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107021056/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107021056/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.10.202107021056/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107021056/pkg.go index dbb9de3e32..778a4577f5 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107021056/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107021056/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202107021056", upgrade) + history.RegistUpgrader("y3.10.202107021056", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = changeHostAttrEditable(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.10.202107021056] change host auto attributes to editable err: %v", err) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107161611/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107161611/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.10.202107161611/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107161611/pkg.go index c22e661e80..9023d0e1eb 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107161611/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107161611/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202107161611", upgrade) + history.RegistUpgrader("y3.10.202107161611", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202107161611") // 更新 procBindInfo diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107161611/proc_bind_change.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107161611/proc_bind_change.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.10.202107161611/proc_bind_change.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107161611/proc_bind_change.go index 4f79092e90..a672686da7 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107161611/proc_bind_change.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107161611/proc_bind_change.go @@ -17,12 +17,12 @@ import ( "configcenter/src/common" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // updateProcBindInfo 更新绑定进程port提示信息 -func updateProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { bindIPAttrFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: "bind_info", diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107271945/delete_history_task.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107271945/delete_history_task.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.10.202107271945/delete_history_task.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107271945/delete_history_task.go index d2db758594..265b522fd3 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107271945/delete_history_task.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107271945/delete_history_task.go @@ -9,14 +9,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) const step uint64 = 10000 // deleteTaskInvalidHistory delete task which settemplate or set has been removed -func deleteTaskInvalidHistory(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func deleteTaskInvalidHistory(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := mapstr.New() cond.Set(common.BKSetTemplateIDField, map[string]interface{}{common.BKDBNE: 0}) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107271945/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107271945/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.10.202107271945/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107271945/pkg.go index 661bc16e0e..5240f965d6 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107271945/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107271945/pkg.go @@ -16,16 +16,16 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202107271945", upgrade) + history.RegistUpgrader("y3.10.202107271945", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = deleteTaskInvalidHistory(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.10.202107271945] remove task invalid history failed, error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107301510/add_solaris_property.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107301510/add_solaris_property.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.10.202107301510/add_solaris_property.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107301510/add_solaris_property.go index c22fa07323..5be745e7e6 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107301510/add_solaris_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107301510/add_solaris_property.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -50,7 +50,7 @@ type attribute struct { LastTime *time.Time `json:"last_time" bson:"last_time"` } -func addSolarisProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSolarisProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107301510/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107301510/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.10.202107301510/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107301510/pkg.go index 299484c194..0cd7e4bca9 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107301510/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107301510/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202107301510", upgrade) + history.RegistUpgrader("y3.10.202107301510", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addSolarisProperty(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.10.202107301510] addSolarisProperty error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107311844/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107311844/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.10.202107311844/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107311844/pkg.go index e97daee03d..bd9762d064 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107311844/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107311844/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202107311844", upgrade) + history.RegistUpgrader("y3.10.202107311844", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202107311844") if err = setProcBindIPNotRequired(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202107311844/set_proc_bind_ip_not_reuqired.go b/src/scene_server/admin_server/upgrader/history/y3.10.202107311844/set_proc_bind_ip_not_reuqired.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.10.202107311844/set_proc_bind_ip_not_reuqired.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202107311844/set_proc_bind_ip_not_reuqired.go index 82f9bb835b..4194304f52 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202107311844/set_proc_bind_ip_not_reuqired.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202107311844/set_proc_bind_ip_not_reuqired.go @@ -17,12 +17,12 @@ import ( "configcenter/src/common" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // setProcBindIPNotRequired update process bind info attribute, set bind ip not required and allows empty value -func setProcBindIPNotRequired(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func setProcBindIPNotRequired(ctx context.Context, db dal.RDB, conf *history.Config) error { bindIPFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: common.BKProcBindInfo, diff --git a/src/scene_server/admin_server/upgrader/y3.10.202109131607/migrate_iam_sysinstances.go b/src/scene_server/admin_server/upgrader/history/y3.10.202109131607/migrate_iam_sysinstances.go similarity index 99% rename from src/scene_server/admin_server/upgrader/y3.10.202109131607/migrate_iam_sysinstances.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202109131607/migrate_iam_sysinstances.go index d8e5f500ec..9efefcfe1f 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202109131607/migrate_iam_sysinstances.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202109131607/migrate_iam_sysinstances.go @@ -26,7 +26,7 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/metadata" "configcenter/src/common/resource/esb" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/redis" "configcenter/src/storage/driver/mongodb/instancemapping" @@ -34,7 +34,7 @@ import ( // migrateIAMSysInstances migrate iam system instances func migrateIAMSysInstances(ctx context.Context, db dal.RDB, cache redis.Client, iam *iamtype.IAM, - conf *upgrader.Config) error { + conf *history.Config) error { if !auth.EnableAuthorize() { return nil } diff --git a/src/scene_server/admin_server/upgrader/y3.10.202109131607/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202109131607/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.10.202109131607/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202109131607/pkg.go index c34f0a5344..098de74bb7 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202109131607/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202109131607/pkg.go @@ -17,16 +17,16 @@ import ( "configcenter/src/ac/iam" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/redis" ) func init() { - upgrader.RegisterUpgraderWithIAM("y3.10.202109131607", upgrade) + history.RegisterUpgraderWithIAM("y3.10.202109131607", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, cache redis.Client, iam *iam.IAM, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, cache redis.Client, iam *iam.IAM, conf *history.Config) (err error) { blog.Info("y3.10.202109131607, migrate iam system instances") if err := migrateIAMSysInstances(ctx, db, cache, iam, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202109131607/util.go b/src/scene_server/admin_server/upgrader/history/y3.10.202109131607/util.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202109131607/util.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202109131607/util.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202109181134/migrate_svc_inst_id_to_proc.go b/src/scene_server/admin_server/upgrader/history/y3.10.202109181134/migrate_svc_inst_id_to_proc.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.10.202109181134/migrate_svc_inst_id_to_proc.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202109181134/migrate_svc_inst_id_to_proc.go index 02b9850e45..ae2dfd758b 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202109181134/migrate_svc_inst_id_to_proc.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202109181134/migrate_svc_inst_id_to_proc.go @@ -21,7 +21,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -56,7 +56,7 @@ type attribute struct { } // addSvcInstIDAttrInProc copy the service_instance_id from process relation table to process table -func addSvcInstIDAttrInProc(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSvcInstIDAttrInProc(ctx context.Context, db dal.RDB, conf *history.Config) error { svcInstIDFilter := mapstr.MapStr{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: common.BKServiceInstanceIDField, @@ -113,7 +113,7 @@ func addSvcInstIDAttrInProc(ctx context.Context, db dal.RDB, conf *upgrader.Conf } // migrateSvcInstIDToProc copy the service_instance_id from process relation table to process table -func migrateSvcInstIDToProc(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateSvcInstIDToProc(ctx context.Context, db dal.RDB, conf *history.Config) error { for { // get processes that has no service instance id in one page procFilter := mapstr.MapStr{ @@ -171,7 +171,7 @@ func migrateSvcInstIDToProc(ctx context.Context, db dal.RDB, conf *upgrader.Conf } // addProcUniqueIndex add process unique indexes -func addProcUniqueIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcUniqueIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { processUniqueIndexes := []types.Index{ { Name: common.CCLogicUniqueIdxNamePrefix + "svcInstID_bkProcName", diff --git a/src/scene_server/admin_server/upgrader/y3.10.202109181134/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202109181134/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202109181134/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202109181134/pkg.go index db4916ee26..cef4190d52 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202109181134/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202109181134/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202109181134", upgrade) + history.RegistUpgrader("y3.10.202109181134", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202109181134, migrate service instance id & related unique index to process table") if err = addSvcInstIDAttrInProc(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202112071130/migrate_api_task.go b/src/scene_server/admin_server/upgrader/history/y3.10.202112071130/migrate_api_task.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.10.202112071130/migrate_api_task.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202112071130/migrate_api_task.go index 39a0db3577..9feab43b46 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202112071130/migrate_api_task.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202112071130/migrate_api_task.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -40,7 +40,7 @@ type subTaskInfo struct { } // migrateApiTask migrate api task table to common api task sync status table -func migrateApiTask(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateApiTask(ctx context.Context, db dal.RDB, conf *history.Config) error { indexes := map[string]types.Index{ "idx_taskID": {Name: "idx_taskID", Keys: bson.D{{"task_id", 1}}, Background: true}, "idx_flag_status_createTime": {Name: "idx_flag_status_createTime", Keys: bson.D{{"flag", 1}, @@ -167,7 +167,7 @@ func updateApiTaskStatus(ctx context.Context, db dal.RDB, task apiTaskInfo) erro } // migrateAPITaskSyncStatus migrate set template sync status table to common api task sync status table -func migrateAPITaskSyncStatus(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateAPITaskSyncStatus(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := db.DropTable(ctx, "cc_SetTemplateSyncStatus"); err != nil { blog.Errorf("drop cc_SetTemplateSyncStatus table failed, err: %v", err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.10.202112071130/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202112071130/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.10.202112071130/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202112071130/pkg.go index 7fa793da56..548fd73bd7 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202112071130/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202112071130/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202112071130", upgrade) + history.RegistUpgrader("y3.10.202112071130", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202112071130") if err = migrateApiTask(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202112071431/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202112071431/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.10.202112071431/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202112071431/pkg.go index a984102a72..3dca27fc37 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202112071431/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202112071431/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202112071431", upgrade) + history.RegistUpgrader("y3.10.202112071431", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202112071431, update platform config") err = updatePlatformConfigAdmin(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202112071431/updateAdminConfigc.go b/src/scene_server/admin_server/upgrader/history/y3.10.202112071431/updateAdminConfigc.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202112071431/updateAdminConfigc.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202112071431/updateAdminConfigc.go index d31b10f50c..82bd150c5b 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202112071431/updateAdminConfigc.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202112071431/updateAdminConfigc.go @@ -10,13 +10,13 @@ * limitations under the License. */ -package y3_9_202112071431 +package y3_10_202112071431 import ( "context" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -194,13 +194,13 @@ var config = ` } ` -func updatePlatformConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updatePlatformConfigAdmin(ctx context.Context, db dal.RDB, conf *history.Config) error { // 将上一份配置文件写入到history中 - upgrader.AddConfigAdminChangeItem("y3.9.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) + history.AddConfigAdminChangeItem("y3.10.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) // 将本次平台管理配置文件写入history中 - upgrader.AddConfigAdminChangeItem("y3.9.202112071431", "调整平台管理配置", metadata.InitAdminConfig) + history.AddConfigAdminChangeItem("y3.10.202112071431", "调整平台管理配置", metadata.InitAdminConfig) - return upgrader.UpgradePlatConfigAdmin(ctx, db, "y3.9.202112071431") + return history.UpgradePlatConfigAdmin(ctx, db, "y3.10.202112071431") } diff --git a/src/scene_server/admin_server/upgrader/y3.10.202112171521/add_bind_info_option.go b/src/scene_server/admin_server/upgrader/history/y3.10.202112171521/add_bind_info_option.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.10.202112171521/add_bind_info_option.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202112171521/add_bind_info_option.go index 0c5a3c99de..e6df42399c 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202112171521/add_bind_info_option.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202112171521/add_bind_info_option.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addProcessBindInfoOption update process bind info attribute -func addProcessBindInfoOption(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcessBindInfoOption(ctx context.Context, db dal.RDB, conf *history.Config) error { procAttr := make([]metadata.Attribute, 0) bindInfoCond := map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/y3.10.202112171521/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202112171521/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.10.202112171521/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202112171521/pkg.go index 4e1c461ff5..8f4eab7049 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202112171521/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202112171521/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202112171521", upgrade) + history.RegistUpgrader("y3.10.202112171521", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202112171521") if err = addProcessBindInfoOption(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202203011516/add_biz_set.go b/src/scene_server/admin_server/upgrader/history/y3.10.202203011516/add_biz_set.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.10.202203011516/add_biz_set.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202203011516/add_biz_set.go index c11fee46d7..ce6ade211d 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202203011516/add_biz_set.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202203011516/add_biz_set.go @@ -23,7 +23,7 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -137,7 +137,7 @@ func addBizSetObjectRow(ctx context.Context, db dal.RDB, ownerID string) error { Modifier: "", } uniqueKeys := []string{common.BKObjIDField} - _, _, err = upgrader.Upsert(ctx, db, common.BKTableNameObjDes, dataRows, "id", uniqueKeys, []string{"id"}) + _, _, err = history.Upsert(ctx, db, common.BKTableNameObjDes, dataRows, "id", uniqueKeys, []string{"id"}) if err != nil { blog.Errorf("add data for %s table error %s", common.BKTableNameObjDes, err) return err @@ -145,7 +145,7 @@ func addBizSetObjectRow(ctx context.Context, db dal.RDB, ownerID string) error { return nil } -func addObjectUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addObjectUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { attrs := make([]metadata.Attribute, 0) cond := mapstr.MapStr{ @@ -306,7 +306,7 @@ func addBizSetPropertyGroup(ctx context.Context, db dal.RDB, ownerID string) err } for _, row := range rows { - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNamePropertyGroup, row, "id", + if _, _, err := history.Upsert(ctx, db, common.BKTableNamePropertyGroup, row, "id", []string{common.BKObjIDField, common.BKPropertyGroupIDField}, []string{"id"}); err != nil { blog.Errorf("add data for %s table error %s", common.BKTableNamePropertyGroup, err) return err @@ -358,7 +358,7 @@ func addBizSetObjectAttrRow(ctx context.Context, db dal.RDB, ownerID string) err row.CreateTime = &nowTime row.LastTime = &nowTime row.Description = "" - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields, []string{}) if err != nil { blog.Errorf("add biz set attr failed, attribute: %v, err: %v", row, err) return err @@ -427,7 +427,7 @@ func addBizSetTableIndexes(ctx context.Context, db dal.RDB) error { return nil } -func addBizSetPropertyOption(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addBizSetPropertyOption(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := addBizSetObjectRow(ctx, db, conf.TenantID); err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/y3.10.202203011516/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202203011516/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.10.202203011516/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202203011516/pkg.go index 8218c241fc..f61c21072a 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202203011516/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202203011516/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202203011516", upgrade) + history.RegistUpgrader("y3.10.202203011516", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202203011516") if err = addBizSetPropertyOption(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202203021455/add_classification.go b/src/scene_server/admin_server/upgrader/history/y3.10.202203021455/add_classification.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.10.202203021455/add_classification.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202203021455/add_classification.go index 023b54c80b..f941bb3eb0 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202203021455/add_classification.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202203021455/add_classification.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -69,7 +69,7 @@ func changeClassificationType(ctx context.Context, db dal.RDB) error { return nil } -func addUncategorizedClassification(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addUncategorizedClassification(ctx context.Context, db dal.RDB, conf *history.Config) error { defaultClassificationRow := Classification{ ClassificationID: metadata.ClassificationUncategorizedID, @@ -116,7 +116,7 @@ func addUncategorizedClassification(ctx context.Context, db dal.RDB, conf *upgra } table := common.BKTableNameObjClassification - if _, _, err := upgrader.Upsert(ctx, db, table, &defaultClassificationRow, "id", + if _, _, err := history.Upsert(ctx, db, table, &defaultClassificationRow, "id", []string{common.BKClassificationIDField}, []string{"id"}); err != nil { blog.Errorf("add default classification failed for %s table, err: %v", table, err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.10.202203021455/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202203021455/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202203021455/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202203021455/pkg.go index 9a789810b9..f91a36912c 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202203021455/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202203021455/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202203021455", upgrade) + history.RegistUpgrader("y3.10.202203021455", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202203021455") if err = addUncategorizedClassification(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202203031512/add_agent_id_and_ipv6_attr.go b/src/scene_server/admin_server/upgrader/history/y3.10.202203031512/add_agent_id_and_ipv6_attr.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.10.202203031512/add_agent_id_and_ipv6_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202203031512/add_agent_id_and_ipv6_attr.go index aa03697afe..137556472b 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202203031512/add_agent_id_and_ipv6_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202203031512/add_agent_id_and_ipv6_attr.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -27,7 +27,7 @@ import ( ) // addHostAgentIDAndIPv6Attr add host agent id and ipv6 attributes -func addHostAgentIDAndIPv6Attr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostAgentIDAndIPv6Attr(ctx context.Context, db dal.RDB, conf *history.Config) error { // NOCC:tosa/linelength(IPv6正则表达式的长度超过限制,忽略该检查) const ipv6Regex = `(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))` multiIpv6Regex := fmt.Sprintf(`^%s(,%s)*$`, ipv6Regex, ipv6Regex) @@ -136,7 +136,7 @@ func insertHostAgentIDAndIPv6Attr(ctx context.Context, db dal.RDB, attrIDs []str } // addHostAgentIDAndIPv6Unique add host agent id and ipv6 attributes related unique rule -func addHostAgentIDAndIPv6Unique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostAgentIDAndIPv6Unique(ctx context.Context, db dal.RDB, conf *history.Config) error { // find inner ipv6 and cloud id attribute ids attrCond := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDHost, @@ -216,7 +216,7 @@ func addHostAgentIDAndIPv6Unique(ctx context.Context, db dal.RDB, conf *upgrader } // addHostAgentIDAndIPv6Index add host agent id and ipv6 attributes db index -func addHostAgentIDAndIPv6Index(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostAgentIDAndIPv6Index(ctx context.Context, db dal.RDB, conf *history.Config) error { agentIDAndIPv6Indexes := []types.Index{ { Name: common.CCLogicUniqueIdxNamePrefix + "bkHostInnerIPv6_bkCloudID", diff --git a/src/scene_server/admin_server/upgrader/y3.10.202203031512/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202203031512/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.10.202203031512/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202203031512/pkg.go index 48e1170044..48b20d35f7 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202203031512/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202203031512/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202203031512", upgrade) + history.RegistUpgrader("y3.10.202203031512", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202203031512") if err = addHostAgentIDAndIPv6Attr(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202204181447/add_business_set.go b/src/scene_server/admin_server/upgrader/history/y3.10.202204181447/add_business_set.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.10.202204181447/add_business_set.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202204181447/add_business_set.go index 7c79fe2921..c2b74625c7 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202204181447/add_business_set.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202204181447/add_business_set.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -30,7 +30,7 @@ const ( bizSetMaintainer = "admin" ) -func addDefaultBusinessSet(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addDefaultBusinessSet(ctx context.Context, db dal.RDB, conf *history.Config) error { now := metadata.Time{ Time: time.Now(), } diff --git a/src/scene_server/admin_server/upgrader/y3.10.202204181447/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202204181447/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.10.202204181447/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202204181447/pkg.go index 868d62fb2c..b998c3e9a4 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202204181447/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202204181447/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202204181447", upgrade) + history.RegistUpgrader("y3.10.202204181447", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202204181447, add default business set") if err = addDefaultBusinessSet(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202204271725/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202204271725/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.10.202204271725/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202204271725/pkg.go index b8640e2c81..bcfb82a564 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202204271725/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202204271725/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202204271725", upgrade) + history.RegistUpgrader("y3.10.202204271725", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202204271725") if err = addServiceTemplateTableColumn(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202204271725/service_template_host_apply.go b/src/scene_server/admin_server/upgrader/history/y3.10.202204271725/service_template_host_apply.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.10.202204271725/service_template_host_apply.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202204271725/service_template_host_apply.go index ce8b206869..4414426b36 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202204271725/service_template_host_apply.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202204271725/service_template_host_apply.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -26,7 +26,7 @@ import ( ) // addServiceTemplateTableColumn add host_apply_enabled field to service template table. -func addServiceTemplateTableColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addServiceTemplateTableColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { err := db.Table(common.BKTableNameServiceTemplate).AddColumn(ctx, common.HostApplyEnabledField, false) if err != nil { @@ -37,7 +37,7 @@ func addServiceTemplateTableColumn(ctx context.Context, db dal.RDB, conf *upgrad } // addHostApplyRuleTableColumn the host automatic application table adds the service_template_id field. -func addHostApplyRuleTableColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostApplyRuleTableColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { err := db.Table(common.BKTableNameHostApplyRule).AddColumn(ctx, common.BKServiceTemplateIDField, 0) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202205182148/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202205182148/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.10.202205182148/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202205182148/pkg.go index d5e4c6d367..64f58f434a 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202205182148/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202205182148/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202205182148", upgrade) + history.RegistUpgrader("y3.10.202205182148", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202205182148, update default business set field name") if err = updateDefaultBusinessSetFieldName(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202205182148/update_business_set.go b/src/scene_server/admin_server/upgrader/history/y3.10.202205182148/update_business_set.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.10.202205182148/update_business_set.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202205182148/update_business_set.go index 09818c6e62..6f1e33d68c 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202205182148/update_business_set.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202205182148/update_business_set.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -28,7 +28,7 @@ const ( newName = "bk_biz_maintainer" ) -func updateDefaultBusinessSetFieldName(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateDefaultBusinessSetFieldName(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := map[string]interface{}{ common.BKBizSetIDField: bizSetID, newName: mapstr.MapStr{"$exists": true}, diff --git a/src/scene_server/admin_server/upgrader/y3.10.202206081408/init_template_attribute.go b/src/scene_server/admin_server/upgrader/history/y3.10.202206081408/init_template_attribute.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202206081408/init_template_attribute.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202206081408/init_template_attribute.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202206081408/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202206081408/pkg.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.10.202206081408/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202206081408/pkg.go index 9a8777802f..81efbc714e 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202206081408/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202206081408/pkg.go @@ -22,15 +22,15 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202206081408", upgrade) + history.RegistUpgrader("y3.10.202206081408", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202206081408, init template attribute") if err = initTemplateAttribute(ctx, db, "cc_SetTemplateAttr", common.BKSetTemplateIDField); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202208032125/add_host_favourite_type_column.go b/src/scene_server/admin_server/upgrader/history/y3.10.202208032125/add_host_favourite_type_column.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.10.202208032125/add_host_favourite_type_column.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202208032125/add_host_favourite_type_column.go index 9dec2133d4..e5c8fb8e96 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202208032125/add_host_favourite_type_column.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202208032125/add_host_favourite_type_column.go @@ -23,12 +23,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addHostFavouriteColumn add type column to cc_HostFavourite table. -func addHostFavouriteColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostFavouriteColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { err := db.Table(common.BKTableNameHostFavorite).AddColumn(ctx, common.HostFavoriteType, metadata.Tradition) if err != nil { blog.Errorf("add type column to cc_HostFavourite failed, err: %v", err) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202208032125/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202208032125/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.10.202208032125/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202208032125/pkg.go index 990052eee0..2644e3bc94 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202208032125/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202208032125/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202208032125", upgrade) + history.RegistUpgrader("y3.10.202208032125", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202208032125") if err = addHostFavouriteColumn(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202209231617/add_cloud_host_related_attr.go b/src/scene_server/admin_server/upgrader/history/y3.10.202209231617/add_cloud_host_related_attr.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.10.202209231617/add_cloud_host_related_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202209231617/add_cloud_host_related_attr.go index b8b83cf0f6..5bbb076b02 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202209231617/add_cloud_host_related_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202209231617/add_cloud_host_related_attr.go @@ -26,12 +26,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" comm "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addCloudHostIdentifierAttr add cloud host identifier attribute, hosts with the cloud host identifier attribute set cannot be transferred across biz -func addCloudHostIdentifierAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addCloudHostIdentifierAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { identifierAttr := &attribute{ OwnerID: conf.TenantID, ObjectID: common.BKInnerObjIDHost, @@ -99,7 +99,7 @@ func addCloudHostIdentifierAttr(ctx context.Context, db dal.RDB, conf *upgrader. } // updateCloudVendorAttr update cloud vendor attribute, add other nodeman cloud vendor option -func updateCloudVendorAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateCloudVendorAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { // get the cloud host identifier and cloud vendor attribute cloudVendors := []string{"AWS", "腾讯云", "GCP", "Azure", "企业私有云", "SalesForce", "Oracle Cloud", "IBM Cloud", "阿里云", "中国电信", "UCloud", "美团云", "金山云", "百度云", "华为云", "首都云"} diff --git a/src/scene_server/admin_server/upgrader/y3.10.202209231617/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202209231617/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202209231617/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202209231617/pkg.go index aa2c946bf0..5c80163729 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202209231617/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202209231617/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202209231617", upgrade) + history.RegistUpgrader("y3.10.202209231617", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202209231617, add cloud host related attribute") if err = addCloudHostIdentifierAttr(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202209281408/init_kube_collection.go b/src/scene_server/admin_server/upgrader/history/y3.10.202209281408/init_kube_collection.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202209281408/init_kube_collection.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202209281408/init_kube_collection.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202209281408/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202209281408/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202209281408/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202209281408/pkg.go index 968c154811..ff0b2ba04b 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202209281408/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202209281408/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202209281408", upgrade) + history.RegistUpgrader("y3.10.202209281408", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202209281408, init container collection and index") if err = addKubeCollection(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202302031117/objattrdes_ismultichoice.go b/src/scene_server/admin_server/upgrader/history/y3.10.202302031117/objattrdes_ismultichoice.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.10.202302031117/objattrdes_ismultichoice.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202302031117/objattrdes_ismultichoice.go index f9f9f9603c..4064b9a5c3 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202302031117/objattrdes_ismultichoice.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202302031117/objattrdes_ismultichoice.go @@ -22,12 +22,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addObjAttrDesIsMultipleColumn add is multiple field to objAttrDes table. -func addObjAttrDesIsMultipleColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addObjAttrDesIsMultipleColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { err := db.Table(common.BKTableNameObjAttDes).AddColumn(ctx, common.BKIsMultipleField, false) if err != nil { @@ -39,7 +39,7 @@ func addObjAttrDesIsMultipleColumn(ctx context.Context, db dal.RDB, conf *upgrad } // updateUserFieldTypeObjAttrIsMultiple update the default value of user type field is multiple to true -func updateUserFieldTypeObjAttrIsMultiple(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateUserFieldTypeObjAttrIsMultiple(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKDBOR: []map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/y3.10.202302031117/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202302031117/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202302031117/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202302031117/pkg.go index a643d68483..784095e93c 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202302031117/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202302031117/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202302031117", upgrade) + history.RegistUpgrader("y3.10.202302031117", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202302031117") if err = addObjAttrDesIsMultipleColumn(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202302062350/add_project.go b/src/scene_server/admin_server/upgrader/history/y3.10.202302062350/add_project.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.10.202302062350/add_project.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202302062350/add_project.go index b60f4573c4..256b4cf2e6 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202302062350/add_project.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202302062350/add_project.go @@ -27,7 +27,7 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -219,7 +219,7 @@ func addProjectObjectRow(ctx context.Context, db dal.RDB, ownerID string) error Modifier: "", } uniqueKeys := []string{common.BKObjIDField} - _, _, err = upgrader.Upsert(ctx, db, common.BKTableNameObjDes, dataRows, "id", uniqueKeys, []string{"id"}) + _, _, err = history.Upsert(ctx, db, common.BKTableNameObjDes, dataRows, "id", uniqueKeys, []string{"id"}) if err != nil { blog.Errorf("add data for %s table failed, err: %v", common.BKTableNameObjDes, err) return err @@ -227,7 +227,7 @@ func addProjectObjectRow(ctx context.Context, db dal.RDB, ownerID string) error return nil } -func addObjectUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addObjectUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { attrs := make([]metadata.Attribute, 0) cond := mapstr.MapStr{ common.BKObjIDField: common.BKInnerObjIDProject, @@ -330,7 +330,7 @@ func addProjectPropertyGroup(ctx context.Context, db dal.RDB, ownerID string) er } for _, row := range rows { - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNamePropertyGroup, row, "id", + if _, _, err := history.Upsert(ctx, db, common.BKTableNamePropertyGroup, row, "id", []string{common.BKObjIDField, common.BKPropertyGroupIDField}, []string{"id"}); err != nil { blog.Errorf("add data for %s table failed, err: %v", common.BKTableNamePropertyGroup, err) return err @@ -378,7 +378,7 @@ func addProjectObjectAttrRow(ctx context.Context, db dal.RDB, ownerID string) er row.CreateTime = &nowTime row.LastTime = &nowTime row.Description = "" - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields, []string{}) if err != nil { blog.Errorf("add project attr failed, attribute: %v, err: %v", row, err) return err @@ -453,7 +453,7 @@ func addProjectTableIndexes(ctx context.Context, db dal.RDB) error { return nil } -func addProjectPropertyOption(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProjectPropertyOption(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := addProjectObjectRow(ctx, db, conf.TenantID); err != nil { return err } diff --git a/src/scene_server/admin_server/upgrader/y3.10.202302062350/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202302062350/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.10.202302062350/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202302062350/pkg.go index 2a4ed6b59e..1b34cda876 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202302062350/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202302062350/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202302062350", upgrade) + history.RegistUpgrader("y3.10.202302062350", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202302062350") if err = addProjectPropertyOption(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202303072103/add_freebsd_property.go b/src/scene_server/admin_server/upgrader/history/y3.10.202303072103/add_freebsd_property.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202303072103/add_freebsd_property.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202303072103/add_freebsd_property.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202303072103/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202303072103/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.10.202303072103/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202303072103/pkg.go index da7e114d05..c3c13b9240 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202303072103/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202303072103/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202303072103", upgrade) + history.RegistUpgrader("y3.10.202303072103", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202303072103") if err = addFreeBSDProperty(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202303301611/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202303301611/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202303301611/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202303301611/pkg.go index 2ef4717e31..904b4a675a 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202303301611/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202303301611/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202303301611", upgrade) + history.RegistUpgrader("y3.10.202303301611", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202303301611") if err = updateProcessIpv6AttrOption(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202303301611/update_host_outeripv6_option.go b/src/scene_server/admin_server/upgrader/history/y3.10.202303301611/update_host_outeripv6_option.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202303301611/update_host_outeripv6_option.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202303301611/update_host_outeripv6_option.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202303301611/update_process_ipv6attr_option.go b/src/scene_server/admin_server/upgrader/history/y3.10.202303301611/update_process_ipv6attr_option.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202303301611/update_process_ipv6attr_option.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202303301611/update_process_ipv6attr_option.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202303301718/objattrdes_default.go b/src/scene_server/admin_server/upgrader/history/y3.10.202303301718/objattrdes_default.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.10.202303301718/objattrdes_default.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202303301718/objattrdes_default.go index e1cbe28408..9c9350d932 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202303301718/objattrdes_default.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202303301718/objattrdes_default.go @@ -22,12 +22,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addObjAttrDesDefaultColumn add is default field to objAttrDes table. -func addObjAttrDesDefaultColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addObjAttrDesDefaultColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { err := db.Table(common.BKTableNameObjAttDes).AddColumn(ctx, common.BKDefaultFiled, nil) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202303301718/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202303301718/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.10.202303301718/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202303301718/pkg.go index c1475d3ff0..5a99c80858 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202303301718/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202303301718/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202303301718", upgrade) + history.RegistUpgrader("y3.10.202303301718", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202303301718") if err = addObjAttrDesDefaultColumn(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202304012150/add_model_quote_relation.go b/src/scene_server/admin_server/upgrader/history/y3.10.202304012150/add_model_quote_relation.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.10.202304012150/add_model_quote_relation.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202304012150/add_model_quote_relation.go index 903fe48788..a600d21f4e 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202304012150/add_model_quote_relation.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202304012150/add_model_quote_relation.go @@ -24,7 +24,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -50,7 +50,7 @@ func addModelQuoteRelationCollection(ctx context.Context, db dal.RDB) error { return nil } -func addHiddenClassification(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHiddenClassification(ctx context.Context, db dal.RDB, conf *history.Config) error { result := make([]metadata.Classification, 0) filter := map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/y3.10.202304012150/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202304012150/pkg.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.10.202304012150/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202304012150/pkg.go index fed7a76126..5df5f9e0c2 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202304012150/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202304012150/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202304012150", upgrade) + history.RegistUpgrader("y3.10.202304012150", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202304012150") if err = addModelQuoteRelationCollection(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202305110949/add_agent_id_related_attr.go b/src/scene_server/admin_server/upgrader/history/y3.10.202305110949/add_agent_id_related_attr.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.10.202305110949/add_agent_id_related_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202305110949/add_agent_id_related_attr.go index d0d46b00a6..660161f58d 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202305110949/add_agent_id_related_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202305110949/add_agent_id_related_attr.go @@ -22,7 +22,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -71,7 +71,7 @@ func changeHostIpv4RequireAttr(ctx context.Context, db dal.RDB) error { } // addHostAddressingAttr add host addressing attribute -func addHostAddressingAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostAddressingAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { now := time.Now() addressingAttr := attribute{ OwnerID: conf.TenantID, @@ -147,7 +147,7 @@ func addHostAddressingAttr(ctx context.Context, db dal.RDB, conf *upgrader.Confi } // addDefaultHostAddressingField update all hosts' addressing field to static if it does not have the field -func addDefaultHostAddressingField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addDefaultHostAddressingField(ctx context.Context, db dal.RDB, conf *history.Config) error { hostFilter := map[string]interface{}{ "bk_addressing": map[string]interface{}{common.BKDBExists: false}, } @@ -200,7 +200,7 @@ func addDefaultHostAddressingField(ctx context.Context, db dal.RDB, conf *upgrad } // addProcessIpv6AttrOption add process ipv6 options in bind info -func addProcessIpv6AttrOption(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcessIpv6AttrOption(ctx context.Context, db dal.RDB, conf *history.Config) error { bindInfoCond := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: common.BKProcBindInfo, @@ -245,7 +245,7 @@ func addProcessIpv6AttrOption(ctx context.Context, db dal.RDB, conf *upgrader.Co } // adjustHostUnique add agentID unique, do not adjust innerIP + cloudID unique since it can't specify the partial index -func adjustHostUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func adjustHostUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { // find agent id attribute id attrCond := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDHost, @@ -307,7 +307,7 @@ func adjustHostUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) er } // adjustHostUniqueIndex adjust host innerIP + cloudID unique index adding static condition, add agentID unique index -func adjustHostUniqueIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func adjustHostUniqueIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { existIndexArr, err := db.Table(common.BKTableNameBaseHost).Indexes(ctx) if err != nil { blog.Errorf("get exist index for host table failed, err: %v", err) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202305110949/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202305110949/pkg.go similarity index 90% rename from src/scene_server/admin_server/upgrader/y3.10.202305110949/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202305110949/pkg.go index f5fd66e2bc..23f431e47c 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202305110949/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202305110949/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202305110949", upgrade) + history.RegistUpgrader("y3.10.202305110949", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202305110949") if err = addHostAddressingAttr(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202305151505/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202305151505/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.10.202305151505/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202305151505/pkg.go index b469a40e81..dd0126c167 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202305151505/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202305151505/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202305151505", upgrade) + history.RegistUpgrader("y3.10.202305151505", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202305151505") if err = updateBKCloudWord(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.10.202305151505/update_bk_cloud_word.go b/src/scene_server/admin_server/upgrader/history/y3.10.202305151505/update_bk_cloud_word.go similarity index 92% rename from src/scene_server/admin_server/upgrader/y3.10.202305151505/update_bk_cloud_word.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202305151505/update_bk_cloud_word.go index 9c8d4c7f10..8a0aacbe05 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202305151505/update_bk_cloud_word.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202305151505/update_bk_cloud_word.go @@ -18,7 +18,8 @@ package y3_10_202305151505 import ( - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" + "context" "configcenter/src/common" @@ -40,7 +41,7 @@ func updateBKCloudWord(ctx context.Context, db dal.RDB) error { return nil } -func updateDefaultArea(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateDefaultArea(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := map[string]interface{}{ common.BKCloudNameField: "default area", diff --git a/src/scene_server/admin_server/upgrader/y3.10.202307171520/add_field_template.go b/src/scene_server/admin_server/upgrader/history/y3.10.202307171520/add_field_template.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202307171520/add_field_template.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202307171520/add_field_template.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202307171520/add_template_id_column.go b/src/scene_server/admin_server/upgrader/history/y3.10.202307171520/add_template_id_column.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.10.202307171520/add_template_id_column.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202307171520/add_template_id_column.go diff --git a/src/scene_server/admin_server/upgrader/y3.10.202307171520/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.10.202307171520/pkg.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.10.202307171520/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.10.202307171520/pkg.go index 7a542636a3..7954a08fec 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202307171520/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.10.202307171520/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.10.202307171520", upgrade) + history.RegistUpgrader("y3.10.202307171520", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.10.202307171520") if err = addFieldTemplateCollection(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.11.202309050900/delete_host_apply_rule.go b/src/scene_server/admin_server/upgrader/history/y3.11.202309050900/delete_host_apply_rule.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.11.202309050900/delete_host_apply_rule.go rename to src/scene_server/admin_server/upgrader/history/y3.11.202309050900/delete_host_apply_rule.go diff --git a/src/scene_server/admin_server/upgrader/y3.11.202309050900/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.11.202309050900/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.11.202309050900/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.11.202309050900/pkg.go index 3f283c43f1..e2c90a3daa 100644 --- a/src/scene_server/admin_server/upgrader/y3.11.202309050900/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.11.202309050900/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.11.202309050900", upgrade) + history.RegistUpgrader("y3.11.202309050900", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.11.202309050900") if err = deleteModuleHostApplyRule(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.12.202309211735/init_shared_cluster_table.go b/src/scene_server/admin_server/upgrader/history/y3.12.202309211735/init_shared_cluster_table.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.12.202309211735/init_shared_cluster_table.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202309211735/init_shared_cluster_table.go diff --git a/src/scene_server/admin_server/upgrader/y3.12.202309211735/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.12.202309211735/pkg.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.12.202309211735/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202309211735/pkg.go index a2a7bb86c1..1260addb40 100644 --- a/src/scene_server/admin_server/upgrader/y3.12.202309211735/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.12.202309211735/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.12.202309211735", upgrade) + history.RegistUpgrader("y3.12.202309211735", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.12.202309211735, init shared cluster table and index") if err = initSharedClusterTable(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.12.202310301633/add_recorded_fields.go b/src/scene_server/admin_server/upgrader/history/y3.12.202310301633/add_recorded_fields.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.12.202310301633/add_recorded_fields.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202310301633/add_recorded_fields.go index 57b17c0af4..a37519e813 100644 --- a/src/scene_server/admin_server/upgrader/y3.12.202310301633/add_recorded_fields.go +++ b/src/scene_server/admin_server/upgrader/history/y3.12.202310301633/add_recorded_fields.go @@ -24,7 +24,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -83,7 +83,7 @@ var recordedAttrs = []attribute{ }, } -func addRecordedFields(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addRecordedFields(ctx context.Context, db dal.RDB, conf *history.Config) error { objs := make([]metadata.Object, 0) if err := db.Table(common.BKTableNameObjDes).Find(nil).Fields(common.BKObjIDField).All(ctx, &objs); err != nil { blog.Errorf("get all objIDs failed, err: %v, rid: %s", err) @@ -99,7 +99,7 @@ func addRecordedFields(ctx context.Context, db dal.RDB, conf *upgrader.Config) e attr.CreateTime = &nowTime attr.LastTime = &nowTime - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, attr, "id", uniqueFields, []string{}) + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, attr, "id", uniqueFields, []string{}) if err != nil { blog.Errorf("add object attribute failed, attribute: %v, err: %v", attr, err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.12.202310301633/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.12.202310301633/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.12.202310301633/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202310301633/pkg.go index 1589d898ad..191e5b0213 100644 --- a/src/scene_server/admin_server/upgrader/y3.12.202310301633/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.12.202310301633/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.12.202310301633", upgrade) + history.RegistUpgrader("y3.12.202310301633", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.12.202310301633") if err = addRecordedFields(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.12.202310302130/add_business_set.go b/src/scene_server/admin_server/upgrader/history/y3.12.202310302130/add_business_set.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.12.202310302130/add_business_set.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202310302130/add_business_set.go index ec2ad8b46d..07172eac34 100644 --- a/src/scene_server/admin_server/upgrader/y3.12.202310302130/add_business_set.go +++ b/src/scene_server/admin_server/upgrader/history/y3.12.202310302130/add_business_set.go @@ -25,7 +25,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -34,7 +34,7 @@ const ( bizSetName = "全业务-蓝盾测试部署专用" ) -func addDefaultBusinessSet(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addDefaultBusinessSet(ctx context.Context, db dal.RDB, conf *history.Config) error { now := metadata.Time{ Time: time.Now(), } diff --git a/src/scene_server/admin_server/upgrader/y3.12.202310302130/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.12.202310302130/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.12.202310302130/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202310302130/pkg.go index edaa8c8be0..68a309634d 100644 --- a/src/scene_server/admin_server/upgrader/y3.12.202310302130/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.12.202310302130/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.12.202310302130", upgrade) + history.RegistUpgrader("y3.12.202310302130", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.12.202310302130, add default business set") if err = addDefaultBusinessSet(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.12.202311061800/add_sort_number_column.go b/src/scene_server/admin_server/upgrader/history/y3.12.202311061800/add_sort_number_column.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.12.202311061800/add_sort_number_column.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202311061800/add_sort_number_column.go diff --git a/src/scene_server/admin_server/upgrader/y3.12.202311061800/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.12.202311061800/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.12.202311061800/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.12.202311061800/pkg.go index bf02df6a32..2ae0cd2365 100644 --- a/src/scene_server/admin_server/upgrader/y3.12.202311061800/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.12.202311061800/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.12.202311061800", upgrade) + history.RegistUpgrader("y3.12.202311061800", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.12.202311061800") if err = addSortNumberColumnToObjDes(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202401221600/encode_pod_label.go b/src/scene_server/admin_server/upgrader/history/y3.13.202401221600/encode_pod_label.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.13.202401221600/encode_pod_label.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202401221600/encode_pod_label.go diff --git a/src/scene_server/admin_server/upgrader/y3.13.202401221600/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202401221600/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.13.202401221600/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202401221600/pkg.go index d8c182c93a..330e7f321f 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202401221600/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202401221600/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202401221600", upgrade) + history.RegistUpgrader("y3.13.202401221600", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202401221600") if err = encodePodLabel(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202402181900/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202402181900/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.13.202402181900/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202402181900/pkg.go index 3e67c7bb9b..636c89c454 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202402181900/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202402181900/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202402181900", upgrade) + history.RegistUpgrader("y3.13.202402181900", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202402181900") if err = updateBizSetDescField(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202402181900/update_biz_set_desc_field.go b/src/scene_server/admin_server/upgrader/history/y3.13.202402181900/update_biz_set_desc_field.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.13.202402181900/update_biz_set_desc_field.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202402181900/update_biz_set_desc_field.go diff --git a/src/scene_server/admin_server/upgrader/y3.13.202402191140/migrate_inner_classification.go b/src/scene_server/admin_server/upgrader/history/y3.13.202402191140/migrate_inner_classification.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.13.202402191140/migrate_inner_classification.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202402191140/migrate_inner_classification.go index 954e32dde4..2f7899a4ce 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202402191140/migrate_inner_classification.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202402191140/migrate_inner_classification.go @@ -24,11 +24,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func migrateInnerClassification(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateInnerClassification(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := mapstr.MapStr{ common.BKClassificationIDField: mapstr.MapStr{ common.BKDBIN: []string{metadata.ClassificationHostManageID, metadata.ClassificationBizTopoID, diff --git a/src/scene_server/admin_server/upgrader/y3.13.202402191140/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202402191140/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.13.202402191140/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202402191140/pkg.go index 7104928eda..68aed4e8d6 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202402191140/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202402191140/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202402191140", upgrade) + history.RegistUpgrader("y3.13.202402191140", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202402191140") if err = migrateInnerClassification(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202402281158/add_mac_os_type.go b/src/scene_server/admin_server/upgrader/history/y3.13.202402281158/add_mac_os_type.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.13.202402281158/add_mac_os_type.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202402281158/add_mac_os_type.go diff --git a/src/scene_server/admin_server/upgrader/y3.13.202402281158/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202402281158/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.13.202402281158/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202402281158/pkg.go index c79abe8e8f..5414dafffd 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202402281158/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202402281158/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202402281158", upgrade) + history.RegistUpgrader("y3.13.202402281158", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202402281158") if err = addMacOSType(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202403151855/migrate_host_message.go b/src/scene_server/admin_server/upgrader/history/y3.13.202403151855/migrate_host_message.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.13.202403151855/migrate_host_message.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202403151855/migrate_host_message.go index b69c61e746..ae74b3a218 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202403151855/migrate_host_message.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202403151855/migrate_host_message.go @@ -24,11 +24,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func migrateHostMsg(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateHostMsg(ctx context.Context, db dal.RDB, conf *history.Config) error { // change host auto group name cond := mapstr.MapStr{ common.BKObjIDField: common.BKInnerObjIDHost, diff --git a/src/scene_server/admin_server/upgrader/y3.13.202403151855/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202403151855/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.13.202403151855/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202403151855/pkg.go index 74be7545e9..77ad41afd4 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202403151855/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202403151855/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202403151855", upgrade) + history.RegistUpgrader("y3.13.202403151855", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202403151855") if err = migrateHostMsg(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202404221100/add_unassigned_cloud_area.go b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/add_unassigned_cloud_area.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.13.202404221100/add_unassigned_cloud_area.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202404221100/add_unassigned_cloud_area.go index 286357f0dd..c0976be191 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202404221100/add_unassigned_cloud_area.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/add_unassigned_cloud_area.go @@ -26,11 +26,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addUnassignedCloudArea(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addUnassignedCloudArea(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := mapstr.MapStr{ common.BKDBAND: []mapstr.MapStr{ {common.BKCloudIDField: mapstr.MapStr{common.BKDBGTE: common.ReservedCloudAreaStartID}}, diff --git a/src/scene_server/admin_server/upgrader/y3.13.202404221100/change_default_area_default_field.go b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/change_default_area_default_field.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.13.202404221100/change_default_area_default_field.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202404221100/change_default_area_default_field.go index 456f8d591a..7dcd424859 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202404221100/change_default_area_default_field.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/change_default_area_default_field.go @@ -23,11 +23,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func changeDefaultAreaDefaultField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeDefaultAreaDefaultField(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := mapstr.MapStr{ common.BKCloudIDField: common.BKDefaultDirSubArea, common.BKDefaultField: mapstr.MapStr{common.BKDBNE: int64(common.BuiltIn)}, diff --git a/src/scene_server/admin_server/upgrader/y3.13.202404221100/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/pkg.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.13.202404221100/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202404221100/pkg.go index 27e40a0a90..0842975573 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202404221100/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202404221100", upgrade) + history.RegistUpgrader("y3.13.202404221100", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202404221100") if err = addUnassignedCloudArea(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202404221100/update_host_field.go b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/update_host_field.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.13.202404221100/update_host_field.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202404221100/update_host_field.go index 28124ae977..e9fa5cc09e 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202404221100/update_host_field.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202404221100/update_host_field.go @@ -24,11 +24,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateHostField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateHostField(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := mapstr.MapStr{ common.BKObjIDField: common.BKInnerObjIDHost, common.BKPropertyIDField: common.BKCloudIDField, diff --git a/src/scene_server/admin_server/upgrader/y3.13.202405080955/add_cloud_region_zone_attr.go b/src/scene_server/admin_server/upgrader/history/y3.13.202405080955/add_cloud_region_zone_attr.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.13.202405080955/add_cloud_region_zone_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202405080955/add_cloud_region_zone_attr.go index 81876de958..2181fd21a4 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202405080955/add_cloud_region_zone_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202405080955/add_cloud_region_zone_attr.go @@ -26,7 +26,7 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -49,7 +49,7 @@ var attributes = []attribute{ }, } -func addAttribute(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addAttribute(ctx context.Context, db dal.RDB, conf *history.Config) error { attrFilter := mapstr.MapStr{ common.BKObjIDField: common.BKInnerObjIDHost, common.BKPropertyIDField: mapstr.MapStr{ diff --git a/src/scene_server/admin_server/upgrader/y3.13.202405080955/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202405080955/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.13.202405080955/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202405080955/pkg.go index eefdbf0d39..2f8735fa30 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202405080955/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202405080955/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202405080955", upgrade) + history.RegistUpgrader("y3.13.202405080955", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202405080955") if err = addAttribute(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202407191507/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202407191507/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.13.202407191507/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202407191507/pkg.go index 99783c83f1..748be4ccd0 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202407191507/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202407191507/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202407191507", upgrade) + history.RegistUpgrader("y3.13.202407191507", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202407191507") if err = upgradeContainer(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202407191507/upgrade_container.go b/src/scene_server/admin_server/upgrader/history/y3.13.202407191507/upgrade_container.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.13.202407191507/upgrade_container.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202407191507/upgrade_container.go index 5d4715beb6..38d15422bb 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202407191507/upgrade_container.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202407191507/upgrade_container.go @@ -26,14 +26,14 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/util" "configcenter/src/kube/types" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" dbtypes "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func upgradeContainer(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgradeContainer(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := addContainerIndex(ctx, db); err != nil { blog.Errorf("add container table index failed, err: %v", err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.13.202407191507/upgrade_del_archive.go b/src/scene_server/admin_server/upgrader/history/y3.13.202407191507/upgrade_del_archive.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.13.202407191507/upgrade_del_archive.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202407191507/upgrade_del_archive.go index dc7fe16b17..5eedfb36d5 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202407191507/upgrade_del_archive.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202407191507/upgrade_del_archive.go @@ -25,7 +25,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" kubetypes "configcenter/src/kube/types" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -33,7 +33,7 @@ import ( "go.mongodb.org/mongo-driver/bson/primitive" ) -func upgradeDelArchive(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgradeDelArchive(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := delExpiredData(ctx, db); err != nil { blog.Errorf("delete expired del archive data failed, err: %v", err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.13.202408011044/del_kube_audit.go b/src/scene_server/admin_server/upgrader/history/y3.13.202408011044/del_kube_audit.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.13.202408011044/del_kube_audit.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202408011044/del_kube_audit.go index b626c5a6d9..c2a1ebf433 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202408011044/del_kube_audit.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202408011044/del_kube_audit.go @@ -25,11 +25,11 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func deleteKubeAudit(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func deleteKubeAudit(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := mapstr.MapStr{ common.BKAuditTypeField: metadata.KubeType, } diff --git a/src/scene_server/admin_server/upgrader/y3.13.202408011044/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202408011044/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.13.202408011044/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202408011044/pkg.go index 1d0d355324..b1179ca86a 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202408011044/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202408011044/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202408011044", upgrade) + history.RegistUpgrader("y3.13.202408011044", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202408011044") if err = deleteKubeAudit(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.13.202408071435/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202408071435/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.13.202408071435/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202408071435/pkg.go index 2cda84ca47..2144508ed9 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202408071435/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202408071435/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202408071435", upgrade) + history.RegistUpgrader("y3.13.202408071435", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202408071435") err = updateConfigAdmin(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.13.202408071435/update_config_admin.go b/src/scene_server/admin_server/upgrader/history/y3.13.202408071435/update_config_admin.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.13.202408071435/update_config_admin.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202408071435/update_config_admin.go index fba12620f9..68b48e3256 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202408071435/update_config_admin.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202408071435/update_config_admin.go @@ -24,13 +24,13 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "github.com/tidwall/gjson" ) -func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := map[string]interface{}{ "_id": common.ConfigAdminID, } diff --git a/src/scene_server/admin_server/upgrader/y3.13.202410091435/add_pod_table_node_index.go b/src/scene_server/admin_server/upgrader/history/y3.13.202410091435/add_pod_table_node_index.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.13.202410091435/add_pod_table_node_index.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202410091435/add_pod_table_node_index.go diff --git a/src/scene_server/admin_server/upgrader/y3.13.202410091435/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.13.202410091435/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.13.202410091435/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.13.202410091435/pkg.go index 646c8c7cd3..2e12910214 100644 --- a/src/scene_server/admin_server/upgrader/y3.13.202410091435/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.13.202410091435/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.13.202410091435", upgrade) + history.RegistUpgrader("y3.13.202410091435", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.13.202410091435") if err = addPodTableNodeIDIndex(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.14.202404031701/init_full_sync_cond_table.go b/src/scene_server/admin_server/upgrader/history/y3.14.202404031701/init_full_sync_cond_table.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.14.202404031701/init_full_sync_cond_table.go rename to src/scene_server/admin_server/upgrader/history/y3.14.202404031701/init_full_sync_cond_table.go diff --git a/src/scene_server/admin_server/upgrader/y3.14.202404031701/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.14.202404031701/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.14.202404031701/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.14.202404031701/pkg.go index ace0a909a6..19ce2c1a5a 100644 --- a/src/scene_server/admin_server/upgrader/y3.14.202404031701/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.14.202404031701/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.14.202404031701", upgrade) + history.RegistUpgrader("y3.14.202404031701", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.14.202404031701") if err = initFullSyncCondTable(ctx, db); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.14.202405141035/add_self_incr_id.go b/src/scene_server/admin_server/upgrader/history/y3.14.202405141035/add_self_incr_id.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.14.202405141035/add_self_incr_id.go rename to src/scene_server/admin_server/upgrader/history/y3.14.202405141035/add_self_incr_id.go index 8cc43ed618..c9deee0d06 100644 --- a/src/scene_server/admin_server/upgrader/y3.14.202405141035/add_self_incr_id.go +++ b/src/scene_server/admin_server/upgrader/history/y3.14.202405141035/add_self_incr_id.go @@ -26,11 +26,11 @@ import ( "configcenter/src/common/mapstr" "configcenter/src/common/metadata" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addSelfIncrID(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSelfIncrID(ctx context.Context, db dal.RDB, conf *history.Config) error { objects := make([]metadata.Object, 0) err := db.Table(common.BKTableNameObjDes).Find(mapstr.MapStr{}).Fields(common.BKObjIDField).All(ctx, &objects) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.14.202405141035/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.14.202405141035/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.14.202405141035/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.14.202405141035/pkg.go index cd46c64b82..7af64733ce 100644 --- a/src/scene_server/admin_server/upgrader/y3.14.202405141035/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.14.202405141035/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.14.202405141035", upgrade) + history.RegistUpgrader("y3.14.202405141035", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.14.202405141035") if err = addSelfIncrID(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.14.202410100930/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.14.202410100930/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.14.202410100930/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.14.202410100930/pkg.go index 9f91c701d0..40be9ccb59 100644 --- a/src/scene_server/admin_server/upgrader/y3.14.202410100930/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.14.202410100930/pkg.go @@ -21,15 +21,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.14.202410100930", upgrade) + history.RegistUpgrader("y3.14.202410100930", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.14.202410100930") err = updatePlatformConfigAdmin(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.14.202410100930/updateAdminConfigc.go b/src/scene_server/admin_server/upgrader/history/y3.14.202410100930/updateAdminConfigc.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.14.202410100930/updateAdminConfigc.go rename to src/scene_server/admin_server/upgrader/history/y3.14.202410100930/updateAdminConfigc.go index 671c2133eb..90ca936eea 100644 --- a/src/scene_server/admin_server/upgrader/y3.14.202410100930/updateAdminConfigc.go +++ b/src/scene_server/admin_server/upgrader/history/y3.14.202410100930/updateAdminConfigc.go @@ -26,11 +26,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updatePlatformConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updatePlatformConfigAdmin(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := map[string]interface{}{ "_id": common.ConfigAdminID, } diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_module_property.go b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_module_property.go index 22a680042d..5c3bfc37ab 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_module_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_module_property.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addModuleProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addModuleProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -77,7 +77,7 @@ func addModuleProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) e } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceCategoryIDProperty, "id", uniqueFields, + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceCategoryIDProperty, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.08.24.01] addModuleProperty set_template_id failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_set_property.go b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_set_property.go index 5104520307..5d4c1ef97b 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_set_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/add_set_property.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addSetProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSetProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { type Attribute struct { ID int64 `field:"id" json:"id" bson:"id"` OwnerID string `field:"bk_supplier_account" json:"bk_supplier_account" bson:"bk_supplier_account"` @@ -77,7 +77,7 @@ func addSetProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) erro } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceCategoryIDProperty, "id", uniqueFields, + _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, serviceCategoryIDProperty, "id", uniqueFields, []string{}) if nil != err { blog.Errorf("[upgrade v19.08.24.01] addSetProperty set_template_id failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/create_table.go b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/create_table.go index 895251a2b9..45a4cbf183 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/create_table.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/create_table.go @@ -17,14 +17,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func createSetTemplateTables(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createSetTemplateTables(ctx context.Context, db dal.RDB, conf *history.Config) error { tables := []string{ common.BKTableNameSetTemplate, common.BKTableNameSetServiceTemplateRelation, diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/initialize_set_template_field.go b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/initialize_set_template_field.go index 188447d094..f39f2548ec 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/initialize_set_template_field.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/initialize_set_template_field.go @@ -17,11 +17,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func initializeSetTemplateField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func initializeSetTemplateField(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKSetTemplateIDField: map[string]interface{}{ common.BKDBExists: false, diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/pkg.go index bf0f9cdc65..2ff819a463 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201909062359/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201909062359", upgrade) + history.RegistUpgrader("y3.6.201909062359", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = createSetTemplateTables(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.6.201909062359] create tables failed, err: %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/pkg.go index 069fc6bf28..2d1a53a251 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201909272359", upgrade) + history.RegistUpgrader("y3.6.201909272359", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.6.201909272359") return taskMigrate(ctx, db, conf) } diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/task.go b/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/task.go index 6e877ef6bb..c9e07e2897 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/task.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201909272359/task.go @@ -17,14 +17,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func taskMigrate(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func taskMigrate(ctx context.Context, db dal.RDB, conf *history.Config) error { existTable, err := db.HasTable(ctx, common.BKTableNameAPITask) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/pkg.go index 5939e1e7b4..d1fc3c1d28 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201910091234", upgrade) + history.RegistUpgrader("y3.6.201910091234", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.6.201910091234") if err := SetTemplateSyncStatusMigrate(ctx, db, conf); err != nil { blog.Errorf("migrate y3.6.201910091234 failed, SetTemplateSyncStatusMigrate failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/settemplate_sync_status.go b/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/settemplate_sync_status.go index f2aad06e9d..fa85ce8fe7 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/settemplate_sync_status.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201910091234/settemplate_sync_status.go @@ -17,7 +17,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -25,7 +25,7 @@ import ( ) // SetTemplateSyncStatusMigrate TODO -func SetTemplateSyncStatusMigrate(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func SetTemplateSyncStatusMigrate(ctx context.Context, db dal.RDB, conf *history.Config) error { tableNames := []string{"cc_SetTemplateSyncStatus", "cc_SetTemplateSyncHistory"} for _, tableName := range tableNames { existTable, err := db.HasTable(ctx, tableName) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/add_recycle_module.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/add_recycle_module.go index e10950d428..048c0c8105 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/add_recycle_module.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/add_recycle_module.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -31,7 +31,7 @@ type BizSimplify struct { } // AddRecycleModule add recycle module for business -func AddRecycleModule(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func AddRecycleModule(ctx context.Context, db dal.RDB, conf *history.Config) error { defaultServiceCategoryID, err := getDefaultServiceCategoryID(ctx, db, conf) if err != nil { blog.Errorf("getDefaultServiceCategoryID failed, err: %v", err) @@ -69,7 +69,7 @@ func AddRecycleModule(ctx context.Context, db dal.RDB, conf *upgrader.Config) er return nil } -func getDefaultServiceCategoryID(ctx context.Context, db dal.RDB, conf *upgrader.Config) (int64, error) { +func getDefaultServiceCategoryID(ctx context.Context, db dal.RDB, conf *history.Config) (int64, error) { serviceCategory := metadata.ServiceCategory{} filter := map[string]interface{}{ "is_built_in": true, @@ -85,7 +85,7 @@ func getDefaultServiceCategoryID(ctx context.Context, db dal.RDB, conf *upgrader return serviceCategory.ID, nil } -func ensureRecycleModuleForBiz(ctx context.Context, db dal.RDB, conf *upgrader.Config, biz BizSimplify, +func ensureRecycleModuleForBiz(ctx context.Context, db dal.RDB, conf *history.Config, biz BizSimplify, defaultServiceCategoryID int64) error { moduleFilter := map[string]interface{}{ common.BKDefaultField: common.DefaultRecycleModuleFlag, @@ -139,7 +139,7 @@ func ensureRecycleModuleForBiz(ctx context.Context, db dal.RDB, conf *upgrader.C return nil } -func getResourceSetID(ctx context.Context, db dal.RDB, conf *upgrader.Config, biz BizSimplify) (int64, error) { +func getResourceSetID(ctx context.Context, db dal.RDB, conf *history.Config, biz BizSimplify) (int64, error) { setFilter := map[string]interface{}{ common.BKDefaultField: common.DefaultResSetFlag, common.BKAppIDField: biz.BKAppIDField, diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/pkg.go index 8414859ebc..f53aac04ad 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911121930/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201911121930", upgrade) + history.RegistUpgrader("y3.6.201911121930", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = AddRecycleModule(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.6.201911121930] AddRecycleModule failed, err: %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/pkg.go index ff0fd4262e..d5e9ad333c 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201911122106", upgrade) + history.RegistUpgrader("y3.6.201911122106", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.6.201911122106") if err := setProcessAutoStartAttribute(ctx, db, conf); err != nil { blog.Errorf("migrate y3.6.201911122106 failed, set process's attribute auto_start filed(bk_isapi) to true failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/set_process_auto_start.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/set_process_auto_start.go index d70b064d10..384f48837b 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/set_process_auto_start.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911122106/set_process_auto_start.go @@ -16,13 +16,13 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // setProcessAutoStartAttribute TODO // set process model's attribute auto_start's bk_isapi field value to true -func setProcessAutoStartAttribute(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func setProcessAutoStartAttribute(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := map[string]string{ "bk_obj_id": "process", "bk_property_id": "auto_start", diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/pkg.go index 25ba949eb4..16e95f072e 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201911141015", upgrade) + history.RegistUpgrader("y3.6.201911141015", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.6.201911141015") if err := removeMetadataOnMainlineInstance(ctx, db, conf); err != nil { blog.Errorf("migrate y3.6.201911141015 failed, setProcessAutoStartAttribute failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/remove_metadata.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/remove_metadata.go index 14dfb05cad..2bb0d22944 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/remove_metadata.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911141015/remove_metadata.go @@ -20,12 +20,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // removeMetadataOnMainlineInstance 当前仅移除Set和Module的metadata字段 -func removeMetadataOnMainlineInstance(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeMetadataOnMainlineInstance(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := fixBizIDFieldWithMetadataOnSet(ctx, db, conf); err != nil { blog.Errorf("removeMetadataOnMainlineInstance failed, fixBizIDFieldWithMetadataOnSet failed, err: %s", err.Error()) return fmt.Errorf("fixBizIDFieldWithMetadataOnSet failed, err: %s", err.Error()) @@ -67,7 +67,7 @@ func removeMetadataOnMainlineInstance(ctx context.Context, db dal.RDB, conf *upg return nil } -func getCustomMainlineModels(ctx context.Context, db dal.RDB, conf *upgrader.Config) ([]string, error) { +func getCustomMainlineModels(ctx context.Context, db dal.RDB, conf *history.Config) ([]string, error) { filter := map[string]interface{}{ common.AssociationKindIDField: common.AssociationKindMainline, } @@ -110,7 +110,7 @@ func getCustomMainlineModels(ctx context.Context, db dal.RDB, conf *upgrader.Con return customMainlineModels, nil } -func fixBizIDFieldWithMetadataOnSet(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixBizIDFieldWithMetadataOnSet(ctx context.Context, db dal.RDB, conf *history.Config) error { type Set struct { BizID int64 `bson:"bk_biz_id" json:"bk_biz_id" mapstructure:"bk_biz_id"` SetID int64 `bson:"bk_set_id" json:"bk_set_id" mapstructure:"bk_set_id"` @@ -158,7 +158,7 @@ func fixBizIDFieldWithMetadataOnSet(ctx context.Context, db dal.RDB, conf *upgra return nil } -func fixBizIDFieldWithMetadataOnModule(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixBizIDFieldWithMetadataOnModule(ctx context.Context, db dal.RDB, conf *history.Config) error { type Module struct { BizID int64 `bson:"bk_biz_id" json:"bk_biz_id" field:"bk_biz_id" mapstructure:"bk_biz_id"` ModuleID int64 `bson:"bk_module_id" json:"bk_module_id" field:"bk_module_id" mapstructure:"bk_module_id"` @@ -206,7 +206,7 @@ func fixBizIDFieldWithMetadataOnModule(ctx context.Context, db dal.RDB, conf *up return nil } -func fixBizIDFieldWithMetadataOnCustomMainline(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixBizIDFieldWithMetadataOnCustomMainline(ctx context.Context, db dal.RDB, conf *history.Config) error { type MainlineInstance struct { BizID int64 `bson:"bk_biz_id" json:"bk_biz_id" field:"bk_biz_id" mapstructure:"bk_biz_id"` InstID int64 `bson:"bk_inst_id" json:"bk_inst_id" field:"bk_inst_id" mapstructure:"bk_inst_id"` diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/obj_host_add_field_type_list.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/obj_host_add_field_type_list.go index 420c00cd9d..6b5c5965c7 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/obj_host_add_field_type_list.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/obj_host_add_field_type_list.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" com "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -50,7 +50,7 @@ type Attribute struct { LastTime time.Time `json:"last_time" bson:"last_time"` } -func addHostFieldTypeList(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostFieldTypeList(ctx context.Context, db dal.RDB, conf *history.Config) error { optionVal := []string{ "运营中[需告警]", "运营中[无告警]", @@ -83,7 +83,7 @@ func addHostFieldTypeList(ctx context.Context, db dal.RDB, conf *upgrader.Config } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - if err := upgrader.Insert(ctx, db, common.BKTableNameObjAttDes, hostListTypeField, "id", uniqueFields); err != nil { + if err := history.Insert(ctx, db, common.BKTableNameObjAttDes, hostListTypeField, "id", uniqueFields); err != nil { blog.ErrorJSON("addHostFieldTypeList failed, Insert err: %s, attribute: %#v, ", err, hostListTypeField) return err } diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/pkg.go index a12b29ea8d..1eeee8a980 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911141516/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201911141516", upgrade) + history.RegistUpgrader("y3.6.201911141516", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.6.201911141516") if err := addHostFieldTypeList(ctx, db, conf); err != nil { blog.Errorf("migrate y3.6.201911141516 failed, new add field type list failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/create_table.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/create_table.go index 20d2b0ba68..69b68805f1 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/create_table.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/create_table.go @@ -17,7 +17,7 @@ import ( "fmt" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -55,7 +55,7 @@ var CreateTableOptions = []struct { }, } -func upsertTable(ctx context.Context, db dal.RDB, conf *upgrader.Config, tableName string, indices []types.Index) error { +func upsertTable(ctx context.Context, db dal.RDB, conf *history.Config, tableName string, indices []types.Index) error { exists, err := db.HasTable(ctx, tableName) if err != nil { return fmt.Errorf("check HasTable failed, tableName: %s, err: %+v", tableName, err) @@ -86,7 +86,7 @@ func upsertTable(ctx context.Context, db dal.RDB, conf *upgrader.Config, tableNa } // CreateTables TODO -func CreateTables(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateTables(ctx context.Context, db dal.RDB, conf *history.Config) error { for _, item := range CreateTableOptions { err := upsertTable(ctx, db, conf, item.TableName, item.TableIndex) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/init_chart.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/init_chart.go index 8b7c19abe0..18e5a5abf9 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/init_chart.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/init_chart.go @@ -18,11 +18,11 @@ import ( "time" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func initInnerChart(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func initInnerChart(ctx context.Context, db dal.RDB, conf *history.Config) error { idArr := make([]uint64, 0) idArr, err := db.NextSequences(ctx, BKTableNameChartConfig, len(InnerChartsArr)) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/pkg.go index 965c753a2b..4af9fb777a 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201911261109/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201911261109", upgrade) + history.RegistUpgrader("y3.6.201911261109", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = CreateTables(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3_6_201911261109] addChartDataTable error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/pkg.go index 698a2230d9..7eb5ccb53c 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.6.201912241627", upgrade) + history.RegistUpgrader("y3.6.201912241627", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.6.201912241627") if err := sortBkPropertyIndex(ctx, db, conf); err != nil { blog.Errorf("migrate y3.6.201912241627 failed, new add field type list failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/sort_bk_property_index.go b/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/sort_bk_property_index.go index c45c6445b6..7d928ebea7 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/sort_bk_property_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.6.201912241627/sort_bk_property_index.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func sortBkPropertyIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func sortBkPropertyIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := make(map[string]interface{}) objects := make([]metadata.Object, 0) if err := db.Table(common.BKTableNameObjDes).Find(cond).All(ctx, &objects); err != nil { @@ -53,7 +53,7 @@ func sortBkPropertyIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) return nil } -func updateSortedPropertyIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config, attrGroups []metadata.Group, attributes []metadata.Attribute) error { +func updateSortedPropertyIndex(ctx context.Context, db dal.RDB, conf *history.Config, attrGroups []metadata.Group, attributes []metadata.Attribute) error { for _, group := range attrGroups { var index int64 for _, attr := range attributes { diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/init_host_property_apply.go b/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/init_host_property_apply.go index 454ef35ba4..4528366c51 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/init_host_property_apply.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/init_host_property_apply.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -27,7 +27,7 @@ import ( ) // InitHostPropertyApplyDataModel init host property apply data model -func InitHostPropertyApplyDataModel(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func InitHostPropertyApplyDataModel(ctx context.Context, db dal.RDB, conf *history.Config) error { // check attribute exist moduleAttributeFilter := map[string]interface{}{ "bk_obj_id": common.BKInnerObjIDModule, diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/pkg.go index c1c74c92f6..5f78b44215 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.201911141719/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.7.201911141719", upgrade) + history.RegistUpgrader("y3.7.201911141719", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = InitHostPropertyApplyDataModel(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.7.201911141719] InitHostPropertyApplyDataModel error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/add_host_outer_ip_unique.go b/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/add_host_outer_ip_unique.go index 05d26aef34..30ea25e116 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/add_host_outer_ip_unique.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/add_host_outer_ip_unique.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addHostOuterIPUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostOuterIPUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { // find host outer ip property's id attrCond := condition.CreateCondition() attrCond.Field(common.BKObjIDField).Eq(common.BKInnerObjIDHost) diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/pkg.go index abf2a036c6..a057d69b71 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.201912121117/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.7.201912121117", upgrade) + history.RegistUpgrader("y3.7.201912121117", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3.7.201912121117") err := addHostOuterIPUnique(ctx, db, conf) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/add_set_template_version.go b/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/add_set_template_version.go index a99e2f0449..815be6e16c 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/add_set_template_version.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/add_set_template_version.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addSetTemplateDefaultVersion(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSetTemplateDefaultVersion(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ "version": map[string]interface{}{ common.BKDBExists: false, @@ -38,7 +38,7 @@ func addSetTemplateDefaultVersion(ctx context.Context, db dal.RDB, conf *upgrade return nil } -func addSetDefaultVersion(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSetDefaultVersion(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ "set_template_version": map[string]interface{}{ common.BKDBExists: false, @@ -53,7 +53,7 @@ func addSetDefaultVersion(ctx context.Context, db dal.RDB, conf *upgrader.Config return nil } -func addSetVersionField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSetVersionField(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDSet, common.BKPropertyIDField: "set_template_version", @@ -100,7 +100,7 @@ func addSetVersionField(ctx context.Context, db dal.RDB, conf *upgrader.Config) LastTime: &now, } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, attribute, "id", uniqueFields, + if _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, attribute, "id", uniqueFields, []string{}); err != nil { blog.Errorf("addSetVersionField failed, add set_template_version attribute failed, err: %+v", err) return fmt.Errorf("add set_template_version attribute failed, err: %+v", err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/pkg.go index 8f219606cd..528f56c44f 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.201912171427/pkg.go @@ -17,7 +17,7 @@ import ( "fmt" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -29,10 +29,10 @@ import ( 如果不通过扩展数据结构支持,新的diff需求将需要大量的数据查询才能实现 */ func init() { - upgrader.RegistUpgrader("y3.7.201912171427", upgrade) + history.RegistUpgrader("y3.7.201912171427", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3.7.201912171427") if err := addSetVersionField(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/add_bk_port_enable_property.go b/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/add_bk_port_enable_property.go index 8410c94f15..2af0ebefcb 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/add_bk_port_enable_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/add_bk_port_enable_property.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addProcEnablePortProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcEnablePortProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3_7_202002231026") @@ -64,7 +64,7 @@ func addProcEnablePortProperty(ctx context.Context, db dal.RDB, conf *upgrader.C } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - if err := upgrader.Insert(ctx, db, common.BKTableNameObjAttDes, addPortEnable, "id", uniqueFields); err != nil { + if err := history.Insert(ctx, db, common.BKTableNameObjAttDes, addPortEnable, "id", uniqueFields); err != nil { blog.Errorf("Insert err: %v, attribute: %#v", err, addPortEnable) return err } @@ -72,7 +72,7 @@ func addProcEnablePortProperty(ctx context.Context, db dal.RDB, conf *upgrader.C return nil } -func addProcTemplatePortEnableProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcTemplatePortEnableProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { docPrefix := "property." + common.BKProcPortEnable doc := map[string]interface{}{ docPrefix + ".value": true, @@ -97,7 +97,7 @@ func addProcTemplatePortEnableProperty(ctx context.Context, db dal.RDB, conf *up return nil } -func setProcInfoProtEnableDefaultValue(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func setProcInfoProtEnableDefaultValue(ctx context.Context, db dal.RDB, conf *history.Config) error { doc := map[string]interface{}{ common.BKProcPortEnable: true, diff --git a/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/pkg.go index 4929201a69..5aaa87e6b7 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.7.202002231026/pkg.go @@ -17,7 +17,7 @@ import ( "fmt" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -29,10 +29,10 @@ import ( 如果不通过扩展数据结构支持,新的diff需求将需要大量的数据查询才能实现 */ func init() { - upgrader.RegistUpgrader("y3.7.202002231026", upgrade) + history.RegistUpgrader("y3.7.202002231026", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3.7.202002231026") if err := addProcEnablePortProperty(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/create_audit_log_table.go b/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/create_audit_log_table.go index bc17726094..333dec5cdd 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/create_audit_log_table.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/create_audit_log_table.go @@ -17,14 +17,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func createAuditLogTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createAuditLogTable(ctx context.Context, db dal.RDB, conf *history.Config) error { exists, err := db.HasTable(ctx, common.BKTableNameAuditLog) if err != nil { blog.Errorf("search audit log table error, err: %v", err) @@ -39,7 +39,7 @@ func createAuditLogTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) return nil } -func addAuditLogTableIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addAuditLogTableIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { idxArr, err := db.Table(common.BKTableNameAuditLog).Indexes(ctx) if err != nil { blog.Errorf("get table %s index error, err: %v", common.BKTableNameAuditLog, err) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/pkg.go index d377b5e13a..ff8889070a 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202001172032/pkg.go @@ -17,15 +17,15 @@ import ( "fmt" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202001172032", upgrade) + history.RegistUpgrader("y3.8.202001172032", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3.8.202001172032") if err := createAuditLogTable(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/migrate_event_id.go b/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/migrate_event_id.go index 8034a811e4..0b71abcd4e 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/migrate_event_id.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/migrate_event_id.go @@ -17,12 +17,12 @@ import ( "strconv" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/redis" ) -func migrateEventIDToMongo(ctx context.Context, db dal.RDB, cache redis.Client, conf *upgrader.Config) error { +func migrateEventIDToMongo(ctx context.Context, db dal.RDB, cache redis.Client, conf *history.Config) error { sid, err := cache.Get(ctx, common.EventCacheEventIDKey).Result() if redis.IsNilErr(err) { return nil diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/pkg.go index 911e81ab85..5d99fa9f77 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202002101113/pkg.go @@ -17,16 +17,16 @@ import ( "fmt" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/redis" ) func init() { - upgrader.RegisterUpgraderWithRedis("y3.8.202002101113", upgrade) + history.RegisterUpgraderWithRedis("y3.8.202002101113", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, cache redis.Client, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, cache redis.Client, conf *history.Config) error { blog.Infof("start execute y3.8.202002101113") if err := migrateEventIDToMongo(ctx, db, cache, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/add_bk_port_enable_property.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/add_bk_port_enable_property.go index cd83dd3c1d..33b6df5e8b 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/add_bk_port_enable_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/add_bk_port_enable_property.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateEnablePortAttribute(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateEnablePortAttribute(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: "bk_port_enable", common.BKObjIDField: common.BKInnerObjIDProc, @@ -36,7 +36,7 @@ func updateEnablePortAttribute(ctx context.Context, db dal.RDB, conf *upgrader.C return nil } -func updateProcessAndProcTemplateEnablePortAttribute(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcessAndProcTemplateEnablePortAttribute(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := db.Table(common.BKTableNameBaseProcess).RenameColumn(ctx, nil, "bk_port_enable", common.BKProcPortEnable); err != nil { blog.Errorf("update process bk_port_enable field to %s failed, err: %s, %s", common.BKProcPortEnable, err.Error()) return fmt.Errorf("update process bk_port_enable field to %s failed, err: %s", common.BKProcPortEnable, err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/pkg.go index 878ae04d5b..aaf687a085 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004141131/pkg.go @@ -17,7 +17,7 @@ import ( "fmt" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -26,10 +26,10 @@ import ( bk_port_enable字段重命名为bk_enable_port */ func init() { - upgrader.RegistUpgrader("y3.7.202004141131", upgrade) + history.RegistUpgrader("y3.7.202004141131", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3.7.202004141131") if err := updateEnablePortAttribute(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/add_proc_gateway_attr.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/add_proc_gateway_attr.go index eb836b0a28..5d3840ae33 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/add_proc_gateway_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/add_proc_gateway_attr.go @@ -20,12 +20,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addProcNetworkProxyGroup 添加外网代理信息分组 -func addProcNetworkProxyGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcNetworkProxyGroup(ctx context.Context, db dal.RDB, conf *history.Config) error { group := Group{ ObjectID: common.BKInnerObjIDProc, GroupID: mCommon.ProcNetworkProxyInfo, @@ -38,7 +38,7 @@ func addProcNetworkProxyGroup(ctx context.Context, db dal.RDB, conf *upgrader.Co } uniqueFields := []string{common.BKObjIDField, common.BKPropertyGroupIDField, "bk_supplier_account"} - err := upgrader.Insert(ctx, db, common.BKTableNamePropertyGroup, group, "id", uniqueFields) + err := history.Insert(ctx, db, common.BKTableNamePropertyGroup, group, "id", uniqueFields) if err != nil { if db.IsNotFoundError(err) == false { blog.ErrorJSON("addProcNetworkProxyGroup failed, Insert err: %s, group: %#v, ", err, group) @@ -51,7 +51,7 @@ func addProcNetworkProxyGroup(ctx context.Context, db dal.RDB, conf *upgrader.Co } // addProcNetworkProxyAttrs 添加外网代理信息相关字段 -func addProcNetworkProxyAttrs(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcNetworkProxyAttrs(ctx context.Context, db dal.RDB, conf *history.Config) error { objID := common.BKInnerObjIDProc dataRows := []*Attribute{ {ObjectID: objID, PropertyID: "bk_gateway_ip", PropertyName: "网关IP", IsRequired: false, IsOnly: false, @@ -81,7 +81,7 @@ func addProcNetworkProxyAttrs(ctx context.Context, db dal.RDB, conf *upgrader.Co r.LastEditor = common.CCSystemOperatorUserName r.Description = "" - if err := upgrader.Insert(ctx, db, common.BKTableNameObjAttDes, r, "id", uniqueFields); err != nil { + if err := history.Insert(ctx, db, common.BKTableNameObjAttDes, r, "id", uniqueFields); err != nil { blog.ErrorJSON("addProcNetworkProxyAttrs failed, Upsert err: %s, attribute: %#v, ", err, r) return err } diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/pkg.go index 4a2e42554c..de0efb9a06 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004151435/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202004151435", upgrade) + history.RegistUpgrader("y3.8.202004151435", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202004151435") err = addProcNetworkProxyGroup(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/fix_set_template_version_time_empty.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/fix_set_template_version_time_empty.go index 186819d8e3..63dad99be1 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/fix_set_template_version_time_empty.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/fix_set_template_version_time_empty.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // fixSetTemplateVersionTimeEmpty fix time type field value empty for set template version attribute -func fixSetTemplateVersionTimeEmpty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func fixSetTemplateVersionTimeEmpty(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: "set_template_version", "bk_supplier_account": conf.TenantID, diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/pkg.go index 18bd0b20ab..d7c5dfdb27 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004241035/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202004241035", upgrade) + history.RegistUpgrader("y3.8.202004241035", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202004241035") err = fixSetTemplateVersionTimeEmpty(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/add_index.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/add_index.go index 92957cbaaf..0d8cab9aa7 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/add_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/add_index.go @@ -17,7 +17,7 @@ import ( "fmt" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -46,7 +46,7 @@ func createIndex(ctx context.Context, db dal.RDB, tableName string, createIndexA } // CreateServiceTemplateIndex create service template table index -func CreateServiceTemplateIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateServiceTemplateIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { createIndexArr := []types.Index{ { Keys: bson.D{{common.BKFieldID, 1}}, @@ -63,7 +63,7 @@ func CreateServiceTemplateIndex(ctx context.Context, db dal.RDB, conf *upgrader. } // CreateProcessTemplateIndex create process template table index -func CreateProcessTemplateIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateProcessTemplateIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { createIndexArr := []types.Index{ { Keys: bson.D{{common.BKServiceTemplateIDField, 1}}, @@ -85,7 +85,7 @@ func CreateProcessTemplateIndex(ctx context.Context, db dal.RDB, conf *upgrader. } // CreateServiceInstanceIndex create service instance table index -func CreateServiceInstanceIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateServiceInstanceIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { createIndexArr := []types.Index{ { Keys: bson.D{{common.BKFieldID, 1}}, @@ -107,7 +107,7 @@ func CreateServiceInstanceIndex(ctx context.Context, db dal.RDB, conf *upgrader. } // CreateProcessInstanceRelationIndex create process instance relation table index -func CreateProcessInstanceRelationIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateProcessInstanceRelationIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { createIndexArr := []types.Index{ { Keys: bson.D{{common.BKServiceInstanceIDField, 1}}, diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/pkg.go index 1954e2d3e6..3cbd5e4569 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202004291536/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202004291536", upgrade) + history.RegistUpgrader("y3.8.202004291536", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202004291536") err = CreateServiceTemplateIndex(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/add_service_instance_index.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/add_service_instance_index.go index 8c554d6587..18993f9700 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/add_service_instance_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/add_service_instance_index.go @@ -18,14 +18,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func addServiceInstanceIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addServiceInstanceIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameServiceInstance index := types.Index{ Keys: bson.D{{"bk_module_id", 1}}, diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/pkg.go index 37fa437f4c..dba71c9c6d 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006021120/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202006021120", upgrade) + history.RegistUpgrader("y3.8.202006021120", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202006021120") err = addServiceInstanceIndex(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/init_config_admin.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/init_config_admin.go index 386b3a7fa2..abbfc81f89 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/init_config_admin.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/init_config_admin.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func initConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func initConfigAdmin(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := map[string]interface{}{ "_id": common.ConfigAdminID, @@ -46,5 +46,5 @@ func initConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) err } } - return upgrader.UpgradeConfigAdmin(ctx, db, "y3.8.202006092135") + return history.UpgradeConfigAdmin(ctx, db, "y3.8.202006092135") } diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/pkg.go index b1395ccea6..8bd7281b5f 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006092135/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202006092135", upgrade) + history.RegistUpgrader("y3.8.202006092135", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202006092135") err = initConfigAdmin(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/create_table_del_archive.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/create_table_del_archive.go index 469f655d8c..4d07789333 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/create_table_del_archive.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/create_table_del_archive.go @@ -16,11 +16,11 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func createTableDelArchive(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func createTableDelArchive(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameDelArchive exists, err := db.HasTable(ctx, tableName) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/pkg.go index cbaeebc3cb..0abdb96c2c 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006231730/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202006231730", upgrade) + history.RegistUpgrader("y3.8.202006231730", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202006231730") err = createTableDelArchive(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/change_host_ip_user_to_array.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/change_host_ip_user_to_array.go index 7c08609bdb..77c3c11e45 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/change_host_ip_user_to_array.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/change_host_ip_user_to_array.go @@ -19,7 +19,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/mongo/local" @@ -29,7 +29,7 @@ import ( // changeHostIPAndUserToArray TODO // change host inner ip and outer ip and operator and bak operator value from string split by comma to array -func changeHostIPAndUserToArray(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeHostIPAndUserToArray(ctx context.Context, db dal.RDB, conf *history.Config) error { count, err := db.Table(common.BKTableNameBaseHost).Find(nil).Count(ctx) if err != nil { blog.Errorf("count hosts failed, err: %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/pkg.go index 507a99f11d..380c5db558 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006241144/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202006241144", upgrade) + history.RegistUpgrader("y3.8.202006241144", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202006241144") err = changeHostIPAndUserToArray(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/change_attr_sla_editable.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/change_attr_sla_editable.go index 9b7729b894..46c257c515 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/change_attr_sla_editable.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/change_attr_sla_editable.go @@ -16,11 +16,11 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func changeAttrSlaEditable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeAttrSlaEditable(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: "bk_sla", } diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/pkg.go index a4e249b064..9ae7e5a7b5 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202006281530/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202006281530", upgrade) + history.RegistUpgrader("y3.8.202006281530", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202006281530") err = changeAttrSlaEditable(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/change_bk_mainlin_set_biz_asst.go b/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/change_bk_mainlin_set_biz_asst.go index 59ce2e72c5..acd7eeab3a 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/change_bk_mainlin_set_biz_asst.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/change_bk_mainlin_set_biz_asst.go @@ -16,11 +16,11 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func changeSetBizBkMainlinPre(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeSetBizBkMainlinPre(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDSet, diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/pkg.go index b7e44d57cf..64bd7ae767 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202007011748/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202007011748", upgrade) + history.RegistUpgrader("y3.8.202007011748", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.y3.8.202007011748") err = changeSetBizBkMainlinPre(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/add_module_attr.go b/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/add_module_attr.go index 97b0b791f9..aa96ca4d23 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/add_module_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/add_module_attr.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addModuleAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addModuleAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { objID := common.BKInnerObjIDModule now := time.Now() row := attribute{ @@ -48,7 +48,7 @@ func addModuleAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error Description: "", } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - if err := upgrader.Insert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields); err != nil { + if err := history.Insert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields); err != nil { blog.ErrorJSON("add module field bk_parent_id failed, Insert err: %s, attribute: %#v, ", err, row) return err } diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/pkg.go index 7ea05f2bf2..618cdd9cfe 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202008051650/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202008051650", upgrade) + history.RegistUpgrader("y3.8.202008051650", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202008051650") err = addModuleAttr(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/pkg.go index bf20e789d7..956e6bf967 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202008111026", upgrade) + history.RegistUpgrader("y3.8.202008111026", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := removeBkSupplierIDField(ctx, db, conf); err != nil { blog.Errorf("upgrade to version y3.8.202008111026 failed, removeBkSupplierIDField failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/remove_bk_supplier_id.go b/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/remove_bk_supplier_id.go index 377d6a8ffe..c05d3cd868 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/remove_bk_supplier_id.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202008111026/remove_bk_supplier_id.go @@ -17,11 +17,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func removeBkSupplierIDField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeBkSupplierIDField(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: "bk_supplier_id", common.BKObjIDField: common.BKInnerObjIDApp, diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/addCpuMemDiskUnit.go b/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/addCpuMemDiskUnit.go index 1b350b3845..3355392a10 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/addCpuMemDiskUnit.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/addCpuMemDiskUnit.go @@ -18,13 +18,13 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addCpuMemDiskUnit TODO // add unit to bk_property_name. -func addCpuMemDiskUnit(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addCpuMemDiskUnit(ctx context.Context, db dal.RDB, conf *history.Config) error { var err error // cpu diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/pkg.go index d637ba4c17..e6e0147e91 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202008241747/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202008241747", upgrade) + history.RegistUpgrader("y3.8.202008241747", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := addCpuMemDiskUnit(ctx, db, conf); err != nil { blog.Errorf("upgrade to version y3.8.202008241747 failed, addCpuMemDiskUnit failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/pkg.go index 49a3c388f4..78aa759d4b 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.8.202009101702", upgrade) + history.RegistUpgrader("y3.8.202009101702", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.8.202009101702") if err = addProcBindInfo(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/proc_bind_change.go b/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/proc_bind_change.go index e2e306538e..8507e0f5ff 100644 --- a/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/proc_bind_change.go +++ b/src/scene_server/admin_server/upgrader/history/y3.8.202009101702/proc_bind_change.go @@ -21,11 +21,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { bindIPAttrFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, @@ -81,7 +81,7 @@ func addProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) err return db.Table(common.BKTableNameObjAttDes).Insert(ctx, procBindIPAttr) } -func migrateProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateProcBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { // 已经处理过最大的进程id maxProcID := int64(0) @@ -142,7 +142,7 @@ func migrateProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) return nil } -func migrateProcTempBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateProcTempBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { // 已经处理过最大的id maxID := int64(0) @@ -216,7 +216,7 @@ func migrateProcTempBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Con return nil } -func clearProcAttrAndGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func clearProcAttrAndGroup(ctx context.Context, db dal.RDB, conf *history.Config) error { delPropertyID := []string{common.BKProcGatewayIP, common.BKProcGatewayPort, common.BKProcGatewayProtocol, common.BKProcGatewayCity, common.BKBindIP, common.BKPort, common.BKProtocol, common.BKProcPortEnable} diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_attr.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_attr.go similarity index 90% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_attr.go index 6ba3c3126d..215619f645 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_attr.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addCloudHostAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addCloudHostAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { objID := common.BKInnerObjIDHost dataRows := []*Attribute{ {ObjectID: objID, PropertyID: "bk_cloud_inst_id", PropertyName: "云主机实例ID", IsRequired: false, @@ -49,8 +49,7 @@ func addCloudHostAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) er r.LastEditor = common.CCSystemOperatorUserName r.Description = "" - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, r, "id", uniqueFields, - []string{}); err != nil { + if _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, r, "id", uniqueFields, []string{}); err != nil { blog.ErrorJSON("addCloudHostAttr failed, Upsert err: %s, attribute: %#v, ", err, r) return err } diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_index.go similarity index 91% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_index.go index 221c25bb06..f49860643f 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_index.go @@ -18,14 +18,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func addCloudHostIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addCloudHostIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameBaseHost index := types.Index{ Keys: bson.D{{"bk_cloud_inst_id", 1}}, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_unique.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_unique.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_unique.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_unique.go index b36fb1899c..8fd9ae949c 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_host_unique.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_host_unique.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addCloudHostUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addCloudHostUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { // find bk_cloud_inst_id property's id attrCond := condition.CreateCondition() attrCond.Field(common.BKObjIDField).Eq(common.BKInnerObjIDHost) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_sync_tables.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_sync_tables.go similarity index 90% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_sync_tables.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_sync_tables.go index b004142799..1f37ac58d6 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_cloud_sync_tables.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_cloud_sync_tables.go @@ -16,7 +16,7 @@ import ( "context" "fmt" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -48,7 +48,7 @@ var CreateTableOptions = []struct { }, } -func upsertTable(ctx context.Context, db dal.RDB, conf *upgrader.Config, tableName string, indices []types.Index) error { +func upsertTable(ctx context.Context, db dal.RDB, conf *history.Config, tableName string, indices []types.Index) error { exists, err := db.HasTable(ctx, tableName) if err != nil { return fmt.Errorf("check HasTable failed, tableName: %s, err: %+v", tableName, err) @@ -79,7 +79,7 @@ func upsertTable(ctx context.Context, db dal.RDB, conf *upgrader.Config, tableNa } // CreateTables TODO -func CreateTables(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func CreateTables(ctx context.Context, db dal.RDB, conf *history.Config) error { for _, item := range CreateTableOptions { err := upsertTable(ctx, db, conf, item.TableName, item.TableIndex) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_plat_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_plat_index.go similarity index 92% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/add_plat_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_plat_index.go index 29f96221c9..812545b218 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_plat_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_plat_index.go @@ -18,14 +18,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func addPlatIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addPlatIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameBasePlat index := types.Index{ Keys: bson.D{{"bk_vpc_id", 1}}, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_plat_unique_key.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_plat_unique_key.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/add_plat_unique_key.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_plat_unique_key.go index a01716dd00..6ed1c77295 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/add_plat_unique_key.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/add_plat_unique_key.go @@ -18,11 +18,11 @@ import ( "configcenter/src/common" "configcenter/src/common/condition" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addPlatUnique(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addPlatUnique(ctx context.Context, db dal.RDB, conf *history.Config) error { // find bk_vpc_id property's id attrCond := condition.CreateCondition() attrCond.Field(common.BKObjIDField).Eq(common.BKInnerObjIDPlat) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/init_plat_attr.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/init_plat_attr.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/init_plat_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/init_plat_attr.go index 92e9895ea5..0d3a3bc726 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/init_plat_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/init_plat_attr.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -28,7 +28,7 @@ var ( groupBaseInfo = mCommon.BaseInfo ) -func initPlatAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func initPlatAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { objID := common.BKInnerObjIDPlat dataRows := []*Attribute{ {ObjectID: objID, PropertyID: "bk_status", PropertyName: "状态", IsRequired: false, IsOnly: false, @@ -64,7 +64,7 @@ func initPlatAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error r.LastEditor = common.CCSystemOperatorUserName r.Description = "" - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, r, "id", uniqueFields, + if _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, r, "id", uniqueFields, []string{}); err != nil { blog.ErrorJSON("initPlatAttr failed, Upsert err: %s, attribute: %#v, ", err, r) return err diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/pkg.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/pkg.go index 7df5d40782..38547aab84 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202002131522", upgrade) + history.RegistUpgrader("y3.9.202002131522", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202002131522") shouldRemoveTables := []string{"cc_CloudResourceConfirm", "cc_CloudSyncHistory", "cc_CloudTask", "cc_ResourceConfirmHistory"} diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/remove_old_tables.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/remove_old_tables.go similarity index 100% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/remove_old_tables.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/remove_old_tables.go diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/remove_resource_fault_recycle.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/remove_resource_fault_recycle.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/remove_resource_fault_recycle.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/remove_resource_fault_recycle.go index d93c447bdd..37fe910cae 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/remove_resource_fault_recycle.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/remove_resource_fault_recycle.go @@ -14,16 +14,17 @@ package y3_9_202002131522 import ( "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader/history" + "context" "configcenter/src/common" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" "configcenter/src/storage/dal" ) // removeResourceFaultRecycle 资源池目录不需要"故障机"和"待回收" -func removeResourceFaultRecycle(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeResourceFaultRecycle(ctx context.Context, db dal.RDB, conf *history.Config) error { bizInfo := &metadata.BizInst{} cond := mapstr.MapStr{common.BKDefaultField: 1} if err := db.Table(common.BKTableNameBaseApp).Find(cond).One(ctx, bizInfo); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202002131522/upgrade_cloud_area.go b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/upgrade_cloud_area.go similarity index 92% rename from src/scene_server/admin_server/upgrader/y3.9.202002131522/upgrade_cloud_area.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202002131522/upgrade_cloud_area.go index 2e508279b7..1681a622aa 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202002131522/upgrade_cloud_area.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202002131522/upgrade_cloud_area.go @@ -19,11 +19,11 @@ import ( "configcenter/src/common" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func upgradeCloudArea(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgradeCloudArea(ctx context.Context, db dal.RDB, conf *history.Config) error { opt := mapstr.MapStr{} cloudMapping := make([]metadata.CloudMapping, 0) if err := db.Table(common.BKTableNameBasePlat).Find(opt).All(ctx, &cloudMapping); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202008101530/change_metadata_to_bizid.go b/src/scene_server/admin_server/upgrader/history/y3.9.202008101530/change_metadata_to_bizid.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.9.202008101530/change_metadata_to_bizid.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202008101530/change_metadata_to_bizid.go index 00171f9f00..3a84b9908f 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202008101530/change_metadata_to_bizid.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202008101530/change_metadata_to_bizid.go @@ -20,13 +20,13 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/mongo/local" ) // changeMetadataToBizID transfer field metadata.label.bk_biz_id to bk_biz_id and delete unnecessary metadata -func changeMetadataToBizID(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeMetadataToBizID(ctx context.Context, db dal.RDB, conf *history.Config) error { mongo, ok := db.(*local.Mongo) if !ok { return fmt.Errorf("db is not *local.Mongo type") diff --git a/src/scene_server/admin_server/upgrader/y3.9.202008101530/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202008101530/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202008101530/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202008101530/pkg.go index e9528069a5..25ac2cc1fd 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202008101530/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202008101530/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202008101530", upgrade) + history.RegistUpgrader("y3.9.202008101530", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202008101530") err = changeMetadataToBizID(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202008121631/add_objectl_field_ishidden.go b/src/scene_server/admin_server/upgrader/history/y3.9.202008121631/add_objectl_field_ishidden.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202008121631/add_objectl_field_ishidden.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202008121631/add_objectl_field_ishidden.go index 5565f26caa..55fa246e1d 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202008121631/add_objectl_field_ishidden.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202008121631/add_objectl_field_ishidden.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addObjectFieldIsHidden add field 'bk_ishidden' to object process and plat, and the value is true -func addObjectFieldIsHidden(ctx context.Context, db dal.RDB, _ *upgrader.Config) (err error) { +func addObjectFieldIsHidden(ctx context.Context, db dal.RDB, _ *history.Config) (err error) { objIDs := []string{common.BKInnerObjIDProc, common.BKInnerObjIDPlat} cond := mapstr.MapStr{ diff --git a/src/scene_server/admin_server/upgrader/y3.9.202008121631/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202008121631/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.9.202008121631/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202008121631/pkg.go index c052b9a158..e4d05ce1d4 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202008121631/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202008121631/pkg.go @@ -17,18 +17,18 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) const currentPackageName = "y3.9.202008121631" func init() { - upgrader.RegistUpgrader(currentPackageName, upgrade) + history.RegistUpgrader(currentPackageName, upgrade) } // upgrade add field 'bk_ishidden' to object process and plat, and the value is true -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute %s", currentPackageName) if err := addObjectFieldIsHidden(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202008172134/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202008172134/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.9.202008172134/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202008172134/pkg.go index 29c2337bf2..0ca5ec5222 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202008172134/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202008172134/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202008172134", upgrade) + history.RegistUpgrader("y3.9.202008172134", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := reconcileAuditTableIndexes(ctx, db, conf); err != nil { blog.Errorf("upgrade to version y3.9.202008172134 failed, reconcileAuditTableIndexes failed, err: %+v", err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.9.202008172134/update_audit_table.go b/src/scene_server/admin_server/upgrader/history/y3.9.202008172134/update_audit_table.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202008172134/update_audit_table.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202008172134/update_audit_table.go index e45d2234a2..ac62757a45 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202008172134/update_audit_table.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202008172134/update_audit_table.go @@ -17,7 +17,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -25,7 +25,7 @@ import ( ) // reconcileAuditTableIndexes update indexes for common audit log query params -func reconcileAuditTableIndexes(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func reconcileAuditTableIndexes(ctx context.Context, db dal.RDB, conf *history.Config) error { indexes := []types.Index{ {Name: "index_id", Keys: bson.D{{common.BKFieldID, 1}}, Background: true}, {Name: "index_operationTime", Keys: bson.D{{common.BKOperationTimeField, 1}}, Background: true}, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010131456/create_table.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010131456/create_table.go similarity index 92% rename from src/scene_server/admin_server/upgrader/y3.9.202010131456/create_table.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010131456/create_table.go index 702faf670f..4cd8b8a4f2 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010131456/create_table.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010131456/create_table.go @@ -16,7 +16,7 @@ import ( "context" "configcenter/src/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -24,7 +24,7 @@ import ( "gopkg.in/mgo.v2" ) -func createTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func createTable(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { for tableName, indexes := range tables { exists, err := db.HasTable(ctx, tableName) if err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010131456/migrate_history.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010131456/migrate_history.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202010131456/migrate_history.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010131456/migrate_history.go index 8b8d155ce9..7c1693c2e2 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010131456/migrate_history.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010131456/migrate_history.go @@ -20,11 +20,11 @@ import ( "configcenter/src/common/json" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func migrateHistory(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateHistory(ctx context.Context, db dal.RDB, conf *history.Config) error { // query history dynamic group data that storaged in "UserAPI" mode. opt := mapstr.MapStr{} userConfigs := make([]UserConfig, 0) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010131456/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010131456/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.9.202010131456/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010131456/pkg.go index 5bb27ee278..6479f5337a 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010131456/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010131456/pkg.go @@ -16,7 +16,7 @@ import ( "context" "time" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -33,10 +33,10 @@ type UserConfig struct { } func init() { - upgrader.RegistUpgrader("y3.9.202010131456", upgrade) + history.RegistUpgrader("y3.9.202010131456", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = createTable(ctx, db, conf) if err != nil { return err diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010151455/add_bizid_on_common_attr.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010151455/add_bizid_on_common_attr.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202010151455/add_bizid_on_common_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010151455/add_bizid_on_common_attr.go index 6cb49f98bb..ba2884924f 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010151455/add_bizid_on_common_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010151455/add_bizid_on_common_attr.go @@ -17,12 +17,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addBizIDOnCommonAttr add bk_biz_id field with its value 0 to common attributes whose bk_biz_id field is not exist -func addBizIDOnCommonAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addBizIDOnCommonAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameObjAttDes diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010151455/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010151455/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202010151455/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010151455/pkg.go index 1002671c0c..83ce1afa07 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010151455/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010151455/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202010151455", upgrade) + history.RegistUpgrader("y3.9.202010151455", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202010151455") err = addBizIDOnCommonAttr(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010151650/add_cloudid_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010151650/add_cloudid_index.go similarity index 90% rename from src/scene_server/admin_server/upgrader/y3.9.202010151650/add_cloudid_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010151650/add_cloudid_index.go index c42680706d..491bec6a3d 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010151650/add_cloudid_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010151650/add_cloudid_index.go @@ -17,14 +17,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func addCloudIDIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addCloudIDIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { index := types.Index{ Keys: bson.D{{"bk_cloud_id", 1}}, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010151650/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010151650/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202010151650/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010151650/pkg.go index 71748f7816..a3b559fdfe 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010151650/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010151650/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202010151650", upgrade) + history.RegistUpgrader("y3.9.202010151650", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202010151650") err = addCloudIDIndex(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010211805/add_host_lock_table.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010211805/add_host_lock_table.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.9.202010211805/add_host_lock_table.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010211805/add_host_lock_table.go index 982609e87d..a6f306170b 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010211805/add_host_lock_table.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010211805/add_host_lock_table.go @@ -17,14 +17,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func addHostLockTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostLockTable(ctx context.Context, db dal.RDB, conf *history.Config) error { tableName := common.BKTableNameHostLock @@ -41,7 +41,7 @@ func addHostLockTable(ctx context.Context, db dal.RDB, conf *upgrader.Config) er return nil } -func addIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { index := types.Index{ Keys: bson.D{{"bk_host_id", 1}}, Name: "bk_host_id_1", diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010211805/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010211805/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.9.202010211805/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010211805/pkg.go index 5465d5fd66..47544750f0 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010211805/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010211805/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202010211805", upgrade) + history.RegistUpgrader("y3.9.202010211805", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202010211805") err = addHostLockTable(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010281615/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010281615/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.9.202010281615/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010281615/pkg.go index 2312bcb6dd..8001d8a732 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010281615/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010281615/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202010281615", upgrade) + history.RegistUpgrader("y3.9.202010281615", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { if err := updateInstTimeVal(ctx, db, conf); err != nil { blog.Errorf("[upgrade y3.9.202010281615] update instance time type field value error %s", err.Error()) return err diff --git a/src/scene_server/admin_server/upgrader/y3.9.202010281615/update_inst_time_val.go b/src/scene_server/admin_server/upgrader/history/y3.9.202010281615/update_inst_time_val.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.9.202010281615/update_inst_time_val.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202010281615/update_inst_time_val.go index 9346b29b5f..0b98dac10f 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202010281615/update_inst_time_val.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202010281615/update_inst_time_val.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/mapstr" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // updateInstTimeVal update the value of the instance time type -func updateInstTimeVal(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateInstTimeVal(ctx context.Context, db dal.RDB, conf *history.Config) error { objIDArray := make([]map[string]string, 0) if err := db.Table(bkTableNameObjDes).Find(nil).Fields(common.BKObjIDField).All(ctx, &objIDArray); err != nil { blog.ErrorJSON("find model %s field failed, err: %s", common.BKObjIDField, err) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011021415/create_unique_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011021415/create_unique_index.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.9.202011021415/create_unique_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011021415/create_unique_index.go index 41ac203b0c..13b7da4edb 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011021415/create_unique_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011021415/create_unique_index.go @@ -17,7 +17,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -40,7 +40,7 @@ var ( } ) -func createUniqueIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func createUniqueIndex(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { tableIndexes := make(map[string][]types.Index, 0) buildTopoIndex(tableIndexes) buildTopoTemplateIndex(tableIndexes) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011021415/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011021415/pkg.go similarity index 80% rename from src/scene_server/admin_server/upgrader/y3.9.202011021415/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011021415/pkg.go index 2a6ae1436f..3a78628080 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011021415/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011021415/pkg.go @@ -15,15 +15,15 @@ package y3_9_202011021415 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011021415", upgrade) + history.RegistUpgrader("y3.9.202011021415", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { return createUniqueIndex(ctx, db, conf) } diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011021501/change_attr_bkosType_editable.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011021501/change_attr_bkosType_editable.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.9.202011021501/change_attr_bkosType_editable.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011021501/change_attr_bkosType_editable.go index f3db9c4bf7..ba39059905 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011021501/change_attr_bkosType_editable.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011021501/change_attr_bkosType_editable.go @@ -17,11 +17,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func changeAttrBKOSTypeEditable(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeAttrBKOSTypeEditable(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKPropertyIDField: common.BKOSTypeField, common.BKObjIDField: common.BKInnerObjIDHost, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011021501/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011021501/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202011021501/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011021501/pkg.go index 6f733c3dc1..0dc27ce0e6 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011021501/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011021501/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011021501", upgrade) + history.RegistUpgrader("y3.9.202011021501", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202011021501") err = changeAttrBKOSTypeEditable(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011171550/change_process_attr.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011171550/change_process_attr.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202011171550/change_process_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011171550/change_process_attr.go index be33e7503a..9836db72c4 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011171550/change_process_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011171550/change_process_attr.go @@ -21,12 +21,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/mongo/local" ) -func changeProcessAttrs(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeProcessAttrs(ctx context.Context, db dal.RDB, conf *history.Config) error { // 【启动优先级】增加提示信息: 批量启动进程依据优先级从小到大排序操作,停止进程按反序操作 filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, @@ -89,7 +89,7 @@ func changeProcessAttrs(ctx context.Context, db dal.RDB, conf *upgrader.Config) return nil } -func addProcessAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcessAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { // 增加【启动等待时长】字段 now := time.Now() row := attribute{ @@ -119,7 +119,7 @@ func addProcessAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) erro LastTime: &now, } uniqueFields := []string{common.BKObjIDField, common.BKPropertyIDField, "bk_supplier_account"} - if _, _, err := upgrader.Upsert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields, + if _, _, err := history.Upsert(ctx, db, common.BKTableNameObjAttDes, row, "id", uniqueFields, []string{}); err != nil { blog.ErrorJSON("addCloudHostAttr failed, Upsert err: %s, attribute: %#v, ", err, row) return err @@ -128,7 +128,7 @@ func addProcessAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) erro } // deleteProcessInstsFields 删除进程实例中的"拉起间隔","功能ID"字段 -func deleteProcessInstsFields(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func deleteProcessInstsFields(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ "$or": []map[string]interface{}{ { @@ -185,7 +185,7 @@ func deleteProcessInstsFields(ctx context.Context, db dal.RDB, conf *upgrader.Co } // deleteProcessTemplateInstsFields 删除进程模版实例中的"拉起间隔","功能ID"字段 -func deleteProcessTemplateInstsFields(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func deleteProcessTemplateInstsFields(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ "$or": []map[string]interface{}{ { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011171550/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011171550/pkg.go similarity index 88% rename from src/scene_server/admin_server/upgrader/y3.9.202011171550/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011171550/pkg.go index b4c48e7c11..9312bb79ae 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011171550/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011171550/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011171550", upgrade) + history.RegistUpgrader("y3.9.202011171550", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202011171550") err = changeProcessAttrs(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011172152/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011172152/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202011172152/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011172152/pkg.go index b68c95f870..7191ffda01 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011172152/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011172152/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011172152", upgrade) + history.RegistUpgrader("y3.9.202011172152", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202011172152") err = removeField(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011172152/remove_field.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011172152/remove_field.go similarity index 97% rename from src/scene_server/admin_server/upgrader/y3.9.202011172152/remove_field.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011172152/remove_field.go index 7441ecdbf3..ea09d3073f 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011172152/remove_field.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011172152/remove_field.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // removeField remove redundant bk_childid and bk_parentid fields -func removeField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeField(ctx context.Context, db dal.RDB, conf *history.Config) error { toBeRemovedFields := []string{"bk_childid", "bk_parentid"} // get all mainline objects diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011192014/change_unique_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011192014/change_unique_index.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202011192014/change_unique_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011192014/change_unique_index.go index 694073e3e3..faadd9edb0 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011192014/change_unique_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011192014/change_unique_index.go @@ -17,7 +17,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -34,7 +34,7 @@ var ( } ) -func changeUniqueIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func changeUniqueIndex(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { idxUniqueObjIDGroupName := types.Index{ Keys: bson.D{{common.BKObjIDField, sortFlag}, {common.BKAppIDField, sortFlag}, {common.BKPropertyGroupNameField, sortFlag}}, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011192014/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011192014/pkg.go similarity index 80% rename from src/scene_server/admin_server/upgrader/y3.9.202011192014/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011192014/pkg.go index 0a8c6b0b12..8f9df1df8b 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011192014/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011192014/pkg.go @@ -15,15 +15,15 @@ package y3_9_202011192014 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011192014", upgrade) + history.RegistUpgrader("y3.9.202011192014", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { return changeUniqueIndex(ctx, db, conf) } diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011201146/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011201146/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202011201146/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011201146/pkg.go index c49872a3e5..d6f91f1f15 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011201146/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011201146/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011201146", upgrade) + history.RegistUpgrader("y3.9.202011201146", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202011201146") err = removeRedundantItems(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011201146/remove_redundant_items.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011201146/remove_redundant_items.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202011201146/remove_redundant_items.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011201146/remove_redundant_items.go index 09ec371ce8..7b234580eb 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011201146/remove_redundant_items.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011201146/remove_redundant_items.go @@ -16,7 +16,7 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -25,7 +25,7 @@ const ( subscriptionNameField = "subscription_name" ) -func removeRedundantItems(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeRedundantItems(ctx context.Context, db dal.RDB, conf *history.Config) error { subscriptionFilter := map[string]interface{}{ subscriptionNameField: "process instance refresh [Do not remove it]", "system_name": "cmdb", diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011241510/add_bizid_on_self_defined_node.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011241510/add_bizid_on_self_defined_node.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.9.202011241510/add_bizid_on_self_defined_node.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011241510/add_bizid_on_self_defined_node.go index dd1f5bac12..4e6615b418 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011241510/add_bizid_on_self_defined_node.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011241510/add_bizid_on_self_defined_node.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addBizIDOnSelfDefinedNode 补全自定义层级的bk_biz_id字段 -func addBizIDOnSelfDefinedNode(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addBizIDOnSelfDefinedNode(ctx context.Context, db dal.RDB, conf *history.Config) error { // 获取主线模型里的bk_asst_id->bk_obj_id的映射关系 filter := map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011241510/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011241510/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202011241510/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011241510/pkg.go index 7f2c632c63..aab943b952 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011241510/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011241510/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011241510", upgrade) + history.RegistUpgrader("y3.9.202011241510", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202011241510") err = addBizIDOnSelfDefinedNode(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011251014/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011251014/pkg.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.9.202011251014/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011251014/pkg.go index 84153363a9..eddc3c4742 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011251014/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011251014/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011251014", upgrade) + history.RegistUpgrader("y3.9.202011251014", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202011251014") if err = addProcBindInfo(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011251014/proc_bind_change.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011251014/proc_bind_change.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.9.202011251014/proc_bind_change.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011251014/proc_bind_change.go index 37dd7acd54..e4458e5181 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011251014/proc_bind_change.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011251014/proc_bind_change.go @@ -21,11 +21,11 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func addProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { bindIPAttrFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, @@ -81,7 +81,7 @@ func addProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) err return db.Table(common.BKTableNameObjAttDes).Insert(ctx, procBindIPAttr) } -func migrateProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateProcBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { // 已经处理过最大的进程id maxProcID := int64(0) @@ -142,7 +142,7 @@ func migrateProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) return nil } -func migrateProcTempBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateProcTempBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { // 已经处理过最大的id maxID := int64(0) @@ -217,7 +217,7 @@ func migrateProcTempBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Con return nil } -func clearProcAttrAndGroup(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func clearProcAttrAndGroup(ctx context.Context, db dal.RDB, conf *history.Config) error { delPropertyID := []string{common.BKProcGatewayIP, common.BKProcGatewayPort, common.BKProcGatewayProtocol, common.BKProcGatewayCity, common.BKBindIP, common.BKPort, common.BKProtocol, common.BKProcPortEnable} diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011301723/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011301723/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202011301723/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011301723/pkg.go index 8110a1588b..c77ebeb881 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011301723/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011301723/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202011301723", upgrade) + history.RegistUpgrader("y3.9.202011301723", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202011301723") if err = removeDefaultField(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202011301723/remove_default_field.go b/src/scene_server/admin_server/upgrader/history/y3.9.202011301723/remove_default_field.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202011301723/remove_default_field.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202011301723/remove_default_field.go index c705b1da4b..f0f6062db8 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202011301723/remove_default_field.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202011301723/remove_default_field.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // removeDefaultField remove custom layer instance default field -func removeDefaultField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeDefaultField(ctx context.Context, db dal.RDB, conf *history.Config) error { toBeRemovedFields := []string{common.BKDefaultField} // get all mainline objects diff --git a/src/scene_server/admin_server/upgrader/y3.9.202012011450/change_proc_attr_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202012011450/change_proc_attr_index.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202012011450/change_proc_attr_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202012011450/change_proc_attr_index.go index 4aa83c76f0..71e8d271a5 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202012011450/change_proc_attr_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202012011450/change_proc_attr_index.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // changeProcAttrIndex 调整进程属性index -func changeProcAttrIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeProcAttrIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { // 切片里的元素下标顺序代表调整后的前端展示顺序,其中auto_start属性的bk_isapi为true,在前端不会展示,放在最后 attrs := []string{ "work_path", @@ -62,7 +62,7 @@ func changeProcAttrIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) } // changeProcAttrOption 调整进程属性bk_start_check_secs的option -func changeProcAttrOption(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func changeProcAttrOption(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: "bk_start_check_secs", diff --git a/src/scene_server/admin_server/upgrader/y3.9.202012011450/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202012011450/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.9.202012011450/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202012011450/pkg.go index 260cd3255d..21d5bd8fa4 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202012011450/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202012011450/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202012011450", upgrade) + history.RegistUpgrader("y3.9.202012011450", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202012011450") err = changeProcAttrIndex(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202101061721/add_del_archive_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202101061721/add_del_archive_index.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202101061721/add_del_archive_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202101061721/add_del_archive_index.go index babfe673a0..7d3b47a25a 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202101061721/add_del_archive_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202101061721/add_del_archive_index.go @@ -18,7 +18,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -45,7 +45,7 @@ type archiveData struct { } // delPreviousDelArchiveData delete previous del archive data -func delPreviousDelArchiveData(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func delPreviousDelArchiveData(ctx context.Context, db dal.RDB, conf *history.Config) error { for { dataArr := make([]archiveData, 0) err := db.Table(common.BKTableNameDelArchive).Find(nil).Fields("_id").Start(0). @@ -79,7 +79,7 @@ func delPreviousDelArchiveData(ctx context.Context, db dal.RDB, conf *upgrader.C } // addDelArchiveIndex add unique index for coll and oid -func addDelArchiveIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addDelArchiveIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { existIndexes, err := db.Table(common.BKTableNameDelArchive).Indexes(ctx) if err != nil { blog.ErrorJSON("find indexes for del archive table failed. err: %v", err) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202101061721/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202101061721/pkg.go similarity index 86% rename from src/scene_server/admin_server/upgrader/y3.9.202101061721/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202101061721/pkg.go index c0c11a9359..01684a51a5 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202101061721/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202101061721/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202101061721", upgrade) + history.RegistUpgrader("y3.9.202101061721", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202101061721") err = delPreviousDelArchiveData(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202102011055/add_os_type_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202102011055/add_os_type_index.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.9.202102011055/add_os_type_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202102011055/add_os_type_index.go index 4539fdf4a4..554ac23e78 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202102011055/add_os_type_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202102011055/add_os_type_index.go @@ -17,14 +17,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func addOsTypeIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addOsTypeIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { index := types.Index{ Keys: bson.D{{"bk_os_type", 1}}, Name: "bk_os_type_1", diff --git a/src/scene_server/admin_server/upgrader/y3.9.202102011055/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202102011055/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202102011055/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202102011055/pkg.go index f843a24fa2..82e4f0bad4 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202102011055/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202102011055/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202102011055", upgrade) + history.RegistUpgrader("y3.9.202102011055", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202102011055") err = addOsTypeIndex(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202102261105/add_instass_proc_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202102261105/add_instass_proc_index.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202102261105/add_instass_proc_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202102261105/add_instass_proc_index.go index 6740489f02..3cb9806bc1 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202102261105/add_instass_proc_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202102261105/add_instass_proc_index.go @@ -17,7 +17,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -25,7 +25,7 @@ import ( ) // addInstassProcIndex add index for table cc_InstAsst and cc_ProcessTemplate -func addInstassProcIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addInstassProcIndex(ctx context.Context, db dal.RDB, conf *history.Config) error { index := types.Index{ Keys: bson.D{ diff --git a/src/scene_server/admin_server/upgrader/y3.9.202102261105/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202102261105/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202102261105/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202102261105/pkg.go index 97af9e7288..84b5312f1c 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202102261105/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202102261105/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202102261105", upgrade) + history.RegistUpgrader("y3.9.202102261105", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202102261105") err = addInstassProcIndex(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202103031533/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202103031533/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202103031533/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202103031533/pkg.go index bc052c4e29..40c772c1c9 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202103031533/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202103031533/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202103031533", upgrade) + history.RegistUpgrader("y3.9.202103031533", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202103031533") err = removeHostCPUMhzField(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202103031533/remove_bk_cpu_mhz_field.go b/src/scene_server/admin_server/upgrader/history/y3.9.202103031533/remove_bk_cpu_mhz_field.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202103031533/remove_bk_cpu_mhz_field.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202103031533/remove_bk_cpu_mhz_field.go index 19298d1a4d..12f2ee5270 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202103031533/remove_bk_cpu_mhz_field.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202103031533/remove_bk_cpu_mhz_field.go @@ -18,12 +18,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // removeHostCPUMhzField remove host bk_cpu_mhz field in object attribute table and from host instances -func removeHostCPUMhzField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func removeHostCPUMhzField(ctx context.Context, db dal.RDB, conf *history.Config) error { // remove bk_cpu_mhz attributes attrFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDHost, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202103231621/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202103231621/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202103231621/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202103231621/pkg.go index 9bc7484707..d1a2d00ac4 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202103231621/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202103231621/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202103231621", upgrade) + history.RegistUpgrader("y3.9.202103231621", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202103231621") err = updateHostEmptySpecialField(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202103231621/update_host_empty_special_field.go b/src/scene_server/admin_server/upgrader/history/y3.9.202103231621/update_host_empty_special_field.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202103231621/update_host_empty_special_field.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202103231621/update_host_empty_special_field.go index 64f7a02763..7c20cb1098 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202103231621/update_host_empty_special_field.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202103231621/update_host_empty_special_field.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // updateHostEmptySpecialField update host special field's empty value to nil so that unique index will ignore them -func updateHostEmptySpecialField(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateHostEmptySpecialField(ctx context.Context, db dal.RDB, conf *history.Config) error { specialFields := []string{common.BKHostInnerIPField, common.BKHostOuterIPField, common.BKOperatorField, common.BKBakOperatorField} diff --git a/src/scene_server/admin_server/upgrader/y3.9.202104011012/add_bk_cpu_architecture_attr.go b/src/scene_server/admin_server/upgrader/history/y3.9.202104011012/add_bk_cpu_architecture_attr.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.9.202104011012/add_bk_cpu_architecture_attr.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202104011012/add_bk_cpu_architecture_attr.go index 4639d19915..70f9b8e574 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202104011012/add_bk_cpu_architecture_attr.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202104011012/add_bk_cpu_architecture_attr.go @@ -20,12 +20,12 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/metadata" mCommon "configcenter/src/scene_server/admin_server/common" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addHostBkCPUArchitectureAttr add bk_cpu_architecture attribute for host -func addHostBkCPUArchitectureAttr(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addHostBkCPUArchitectureAttr(ctx context.Context, db dal.RDB, conf *history.Config) error { attrFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDHost, common.BKPropertyIDField: "bk_cpu_architecture", diff --git a/src/scene_server/admin_server/upgrader/y3.9.202104011012/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202104011012/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202104011012/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202104011012/pkg.go index caabf92033..b36d4f002c 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202104011012/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202104011012/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202104011012", upgrade) + history.RegistUpgrader("y3.9.202104011012", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202104011012") err = addHostBkCPUArchitectureAttr(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202104211151/change_set_unique_index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202104211151/change_set_unique_index.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202104211151/change_set_unique_index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202104211151/change_set_unique_index.go index 4d69f2cc60..1e642f268e 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202104211151/change_set_unique_index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202104211151/change_set_unique_index.go @@ -17,7 +17,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -34,7 +34,7 @@ var ( } ) -func changeSetUniqueIndex(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func changeSetUniqueIndex(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { idxUniqueParentIDSetName := types.Index{ Keys: bson.D{{common.BKParentIDField, sortFlag}, {common.BKSetNameField, sortFlag}}, Unique: true, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202104211151/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202104211151/pkg.go similarity index 87% rename from src/scene_server/admin_server/upgrader/y3.9.202104211151/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202104211151/pkg.go index 6680253cd0..4d8a02ad89 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202104211151/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202104211151/pkg.go @@ -16,12 +16,12 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202104211151", upgrade) + history.RegistUpgrader("y3.9.202104211151", upgrade) } // upgrade TODO @@ -30,7 +30,7 @@ func init() { Delete unique index 'idx_unique_bizID_setName' 在不同自定义层级下允许创建同名集群,删除唯一索引'idx_unique_bizID_setName' */ -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202104211151,remove set name unique with biz index, and add set name unique with parent id index") err = changeSetUniqueIndex(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202105261459/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202105261459/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202105261459/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202105261459/pkg.go index 40041acbfe..f705db5c0f 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202105261459/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202105261459/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202105261459", upgrade) + history.RegistUpgrader("y3.9.202105261459", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) error { blog.Infof("start execute y3.9.202105261459") err := updateConfigAdmin(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202105261459/update_config_admin.go b/src/scene_server/admin_server/upgrader/history/y3.9.202105261459/update_config_admin.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.10.202105261459/update_config_admin.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202105261459/update_config_admin.go index 16f31b181c..ce2ee19ca4 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202105261459/update_config_admin.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202105261459/update_config_admin.go @@ -10,16 +10,16 @@ * limitations under the License. */ -package y3_10_202105261459 +package y3_9_202105261459 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) -func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *history.Config) error { config := ` { "backend": { @@ -142,6 +142,6 @@ func updateConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) e } } ` - upgrader.AddConfigAdminChangeItem("y3.10.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) - return upgrader.UpgradeConfigAdmin(ctx, db, "y3.10.202105261459") + history.AddConfigAdminChangeItem("y3.9.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) + return history.UpgradeConfigAdmin(ctx, db, "y3.9.202105261459") } diff --git a/src/scene_server/admin_server/upgrader/y3.9.202106031151/add_unix_property.go b/src/scene_server/admin_server/upgrader/history/y3.9.202106031151/add_unix_property.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202106031151/add_unix_property.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202106031151/add_unix_property.go index f049f62f19..dc951276ea 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202106031151/add_unix_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202106031151/add_unix_property.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -50,7 +50,7 @@ type attribute struct { LastTime *time.Time `json:"last_time" bson:"last_time"` } -func addUnixProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addUnixProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") diff --git a/src/scene_server/admin_server/upgrader/y3.9.202106031151/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202106031151/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.9.202106031151/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202106031151/pkg.go index 5bfda7a20d..40671f456f 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202106031151/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202106031151/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202106031151", upgrade) + history.RegistUpgrader("y3.9.202106031151", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addUnixProperty(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.9.202106031151] addUnixProperty error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202106031151/update_process_pri_range.go b/src/scene_server/admin_server/upgrader/history/y3.9.202106031151/update_process_pri_range.go similarity index 90% rename from src/scene_server/admin_server/upgrader/y3.9.202106031151/update_process_pri_range.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202106031151/update_process_pri_range.go index 536192b7a5..8f4356ee1d 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202106031151/update_process_pri_range.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202106031151/update_process_pri_range.go @@ -1,14 +1,15 @@ package y3_9_202106031151 import ( + "context" + "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" - "context" ) -func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updatePriorityProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { filter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202106291420/index.go b/src/scene_server/admin_server/upgrader/history/y3.9.202106291420/index.go similarity index 93% rename from src/scene_server/admin_server/upgrader/y3.9.202106291420/index.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202106291420/index.go index 1d30d55e5f..fa1b66ac07 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202106291420/index.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202106291420/index.go @@ -18,14 +18,14 @@ import ( "configcenter/src/common/blog" "configcenter/src/common/index" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" "go.mongodb.org/mongo-driver/bson" ) -func addIndexes(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func addIndexes(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { indexes := map[string]types.Index{ "cc_ServiceInstance": { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202106291420/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202106291420/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.9.202106291420/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202106291420/pkg.go index a6834c514f..cf4f3912df 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202106291420/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202106291420/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202106291420", upgrade) + history.RegistUpgrader("y3.9.202106291420", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addIndexes(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.9.202106291420] index error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202106301910/change_host_attr_editable.go b/src/scene_server/admin_server/upgrader/history/y3.9.202106301910/change_host_attr_editable.go similarity index 92% rename from src/scene_server/admin_server/upgrader/y3.9.202106301910/change_host_attr_editable.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202106301910/change_host_attr_editable.go index 4e59c3d3ea..66f3ae3308 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202106301910/change_host_attr_editable.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202106301910/change_host_attr_editable.go @@ -15,12 +15,12 @@ package y3_9_202106301910 import ( "context" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // changeHostAttrEditable change host attributes that has the property group of auto to editable -func changeHostAttrEditable(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func changeHostAttrEditable(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { filter := map[string]interface{}{ "bk_property_group": "auto", "bk_obj_id": "host", diff --git a/src/scene_server/admin_server/upgrader/y3.9.202106301910/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202106301910/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202106301910/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202106301910/pkg.go index 9da57cea2a..ff15618e77 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202106301910/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202106301910/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202106301910", upgrade) + history.RegistUpgrader("y3.9.202106301910", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = changeHostAttrEditable(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.9.202106301910] change host auto attributes to editable err: %v", err) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107011154/drop_set_template_version_column.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107011154/drop_set_template_version_column.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202107011154/drop_set_template_version_column.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107011154/drop_set_template_version_column.go index f6530ab4e8..3a83dfb344 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107011154/drop_set_template_version_column.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107011154/drop_set_template_version_column.go @@ -6,13 +6,13 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) const step = 5000 -func dropVersionColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func dropVersionColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { existsVersionFilter := map[string]interface{}{ "version": map[string]interface{}{ common.BKDBExists: true, @@ -62,7 +62,7 @@ func dropVersionColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) e return nil } -func dropSetTplVersionColumn(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func dropSetTplVersionColumn(ctx context.Context, db dal.RDB, conf *history.Config) error { existsVersionFilter := map[string]interface{}{ "set_template_version": map[string]interface{}{ common.BKDBExists: true, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107011154/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107011154/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.9.202107011154/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107011154/pkg.go index 2df0f4fbec..379cc28040 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107011154/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107011154/pkg.go @@ -16,16 +16,16 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202107011154", upgrade) + history.RegistUpgrader("y3.9.202107011154", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = dropVersionColumn(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.9.202107011154] drop set template table version column error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107161611/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107161611/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202107161611/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107161611/pkg.go index 3c974480b2..ceba24f9d8 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107161611/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107161611/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202107161611", upgrade) + history.RegistUpgrader("y3.9.202107161611", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202107161611") // 更新 procBindInfo diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107161611/proc_bind_change.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107161611/proc_bind_change.go similarity index 89% rename from src/scene_server/admin_server/upgrader/y3.9.202107161611/proc_bind_change.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107161611/proc_bind_change.go index cf3fb3462e..f69f0b8604 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107161611/proc_bind_change.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107161611/proc_bind_change.go @@ -17,12 +17,12 @@ import ( "configcenter/src/common" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // updateProcBindInfo 更新绑定进程port提示信息 -func updateProcBindInfo(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updateProcBindInfo(ctx context.Context, db dal.RDB, conf *history.Config) error { bindIPAttrFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: "bind_info", diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107271940/delete_history_task.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107271940/delete_history_task.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202107271940/delete_history_task.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107271940/delete_history_task.go index 21d882d47d..b3cb9d51fd 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107271940/delete_history_task.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107271940/delete_history_task.go @@ -9,14 +9,14 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/mapstr" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) const step uint64 = 10000 // deleteTaskInvalidHistory delete task which settemplate or set has been removed -func deleteTaskInvalidHistory(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func deleteTaskInvalidHistory(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := mapstr.New() cond.Set(common.BKSetTemplateIDField, map[string]interface{}{common.BKDBNE: 0}) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107271940/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107271940/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.9.202107271940/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107271940/pkg.go index c7e63e9823..3bd477a07e 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107271940/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107271940/pkg.go @@ -16,16 +16,16 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202107271940", upgrade) + history.RegistUpgrader("y3.9.202107271940", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = deleteTaskInvalidHistory(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.9.202107271940] remove task invalid history failed, error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107301510/add_solaris_property.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107301510/add_solaris_property.go similarity index 95% rename from src/scene_server/admin_server/upgrader/y3.9.202107301510/add_solaris_property.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107301510/add_solaris_property.go index 0946459f26..8275b72d77 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107301510/add_solaris_property.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107301510/add_solaris_property.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common/condition" "configcenter/src/common/mapstr" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -50,7 +50,7 @@ type attribute struct { LastTime *time.Time `json:"last_time" bson:"last_time"` } -func addSolarisProperty(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addSolarisProperty(ctx context.Context, db dal.RDB, conf *history.Config) error { cond := condition.CreateCondition() cond.Field("bk_supplier_account").Eq("0") diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107301510/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107301510/pkg.go similarity index 83% rename from src/scene_server/admin_server/upgrader/y3.9.202107301510/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107301510/pkg.go index 4e2ff67f93..bfb9093169 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107301510/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107301510/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202107301510", upgrade) + history.RegistUpgrader("y3.9.202107301510", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { err = addSolarisProperty(ctx, db, conf) if err != nil { blog.Errorf("[upgrade y3.9.202107301510] addSolarisProperty error %s", err.Error()) diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107311844/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107311844/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202107311844/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107311844/pkg.go index 4b884b4e00..017efcef18 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107311844/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107311844/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202107311844", upgrade) + history.RegistUpgrader("y3.9.202107311844", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202107311844") if err = setProcBindIPNotRequired(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202107311844/set_proc_bind_ip_not_reuqired.go b/src/scene_server/admin_server/upgrader/history/y3.9.202107311844/set_proc_bind_ip_not_reuqired.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.9.202107311844/set_proc_bind_ip_not_reuqired.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202107311844/set_proc_bind_ip_not_reuqired.go index 365d33c45d..4d4a46d785 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202107311844/set_proc_bind_ip_not_reuqired.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202107311844/set_proc_bind_ip_not_reuqired.go @@ -17,12 +17,12 @@ import ( "configcenter/src/common" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // setProcBindIPNotRequired update process bind info attribute, set bind ip not required and allows empty value -func setProcBindIPNotRequired(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func setProcBindIPNotRequired(ctx context.Context, db dal.RDB, conf *history.Config) error { bindIPFilter := map[string]interface{}{ common.BKObjIDField: common.BKInnerObjIDProc, common.BKPropertyIDField: common.BKProcBindInfo, diff --git a/src/scene_server/admin_server/upgrader/y3.9.202112061431/add_bind_info_option.go b/src/scene_server/admin_server/upgrader/history/y3.9.202112061431/add_bind_info_option.go similarity index 96% rename from src/scene_server/admin_server/upgrader/y3.9.202112061431/add_bind_info_option.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202112061431/add_bind_info_option.go index abb057b90d..7c682daec6 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202112061431/add_bind_info_option.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202112061431/add_bind_info_option.go @@ -19,12 +19,12 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) // addProcessBindInfoOption update process bind info attribute -func addProcessBindInfoOption(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func addProcessBindInfoOption(ctx context.Context, db dal.RDB, conf *history.Config) error { procAttr := make([]metadata.Attribute, 0) bindInfoCond := map[string]interface{}{ diff --git a/src/scene_server/admin_server/upgrader/y3.9.202112061431/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202112061431/pkg.go similarity index 84% rename from src/scene_server/admin_server/upgrader/y3.9.202112061431/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202112061431/pkg.go index a11a5039fb..ddd4e62905 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202112061431/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202112061431/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202112061431", upgrade) + history.RegistUpgrader("y3.9.202112061431", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202112061431") if err = addProcessBindInfoOption(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202112071130/migrate_api_task.go b/src/scene_server/admin_server/upgrader/history/y3.9.202112071130/migrate_api_task.go similarity index 98% rename from src/scene_server/admin_server/upgrader/y3.9.202112071130/migrate_api_task.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202112071130/migrate_api_task.go index f49887a235..be98b1c5ab 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202112071130/migrate_api_task.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202112071130/migrate_api_task.go @@ -20,7 +20,7 @@ import ( "configcenter/src/common" "configcenter/src/common/blog" "configcenter/src/common/util" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" "configcenter/src/storage/dal/types" @@ -40,7 +40,7 @@ type subTaskInfo struct { } // migrateApiTask migrate api task table to common api task sync status table -func migrateApiTask(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateApiTask(ctx context.Context, db dal.RDB, conf *history.Config) error { indexes := map[string]types.Index{ "idx_taskID": {Name: "idx_taskID", Keys: bson.D{{"task_id", 1}}, Background: true}, "idx_flag_status_createTime": {Name: "idx_flag_status_createTime", Keys: bson.D{{"flag", 1}, @@ -167,7 +167,7 @@ func updateApiTaskStatus(ctx context.Context, db dal.RDB, task apiTaskInfo) erro } // migrateAPITaskSyncStatus migrate set template sync status table to common api task sync status table -func migrateAPITaskSyncStatus(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func migrateAPITaskSyncStatus(ctx context.Context, db dal.RDB, conf *history.Config) error { if err := db.DropTable(ctx, "cc_SetTemplateSyncStatus"); err != nil { blog.Errorf("drop cc_SetTemplateSyncStatus table failed, err: %v", err) return err diff --git a/src/scene_server/admin_server/upgrader/y3.9.202112071130/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202112071130/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.9.202112071130/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202112071130/pkg.go index 3a4e6cc46e..fc0ef28939 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202112071130/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202112071130/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202112071130", upgrade) + history.RegistUpgrader("y3.9.202112071130", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202112071130") if err = migrateApiTask(ctx, db, conf); err != nil { diff --git a/src/scene_server/admin_server/upgrader/y3.9.202112071431/pkg.go b/src/scene_server/admin_server/upgrader/history/y3.9.202112071431/pkg.go similarity index 85% rename from src/scene_server/admin_server/upgrader/y3.9.202112071431/pkg.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202112071431/pkg.go index 614da32575..41c8bbf52c 100644 --- a/src/scene_server/admin_server/upgrader/y3.9.202112071431/pkg.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202112071431/pkg.go @@ -16,15 +16,15 @@ import ( "context" "configcenter/src/common/blog" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) func init() { - upgrader.RegistUpgrader("y3.9.202112071431", upgrade) + history.RegistUpgrader("y3.9.202112071431", upgrade) } -func upgrade(ctx context.Context, db dal.RDB, conf *upgrader.Config) (err error) { +func upgrade(ctx context.Context, db dal.RDB, conf *history.Config) (err error) { blog.Infof("start execute y3.9.202112071431, update platform config") err = updatePlatformConfigAdmin(ctx, db, conf) diff --git a/src/scene_server/admin_server/upgrader/y3.10.202112071431/updateAdminConfigc.go b/src/scene_server/admin_server/upgrader/history/y3.9.202112071431/updateAdminConfigc.go similarity index 94% rename from src/scene_server/admin_server/upgrader/y3.10.202112071431/updateAdminConfigc.go rename to src/scene_server/admin_server/upgrader/history/y3.9.202112071431/updateAdminConfigc.go index 99da59d844..ffa53f23df 100644 --- a/src/scene_server/admin_server/upgrader/y3.10.202112071431/updateAdminConfigc.go +++ b/src/scene_server/admin_server/upgrader/history/y3.9.202112071431/updateAdminConfigc.go @@ -10,13 +10,13 @@ * limitations under the License. */ -package y3_10_202112071431 +package y3_9_202112071431 import ( "context" "configcenter/src/common/metadata" - "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/history" "configcenter/src/storage/dal" ) @@ -194,13 +194,13 @@ var config = ` } ` -func updatePlatformConfigAdmin(ctx context.Context, db dal.RDB, conf *upgrader.Config) error { +func updatePlatformConfigAdmin(ctx context.Context, db dal.RDB, conf *history.Config) error { // 将上一份配置文件写入到history中 - upgrader.AddConfigAdminChangeItem("y3.10.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) + history.AddConfigAdminChangeItem("y3.9.202105261459", "调整拓扑实例和模板名称的校验规则的配置", config) // 将本次平台管理配置文件写入history中 - upgrader.AddConfigAdminChangeItem("y3.10.202112071431", "调整平台管理配置", metadata.InitAdminConfig) + history.AddConfigAdminChangeItem("y3.9.202112071431", "调整平台管理配置", metadata.InitAdminConfig) - return upgrader.UpgradePlatConfigAdmin(ctx, db, "y3.10.202112071431") + return history.UpgradePlatConfigAdmin(ctx, db, "y3.9.202112071431") } diff --git a/src/scene_server/admin_server/upgrader/register.go b/src/scene_server/admin_server/upgrader/register.go index 6d21763159..5c654b2c72 100644 --- a/src/scene_server/admin_server/upgrader/register.go +++ b/src/scene_server/admin_server/upgrader/register.go @@ -1,387 +1,60 @@ -/* - * Tencent is pleased to support the open source community by making 蓝鲸 available. - * Copyright (C) 2017-2018 THL A29 Limited, a Tencent company. All rights reserved. - * Licensed under the MIT License (the "License"); you may not use this file except - * in compliance with the License. You may obtain a copy of the License at - * http://opensource.org/licenses/MIT - * Unless required by applicable law or agreed to in writing, software distributed under - * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, - * either express or implied. See the License for the specific language governing permissions and - * limitations under the License. - */ - package upgrader import ( - "context" "fmt" - "regexp" - "sort" - "strings" - "sync" "time" - "configcenter/src/ac/iam" - "configcenter/src/common" "configcenter/src/common/blog" - "configcenter/src/common/util" - ccversion "configcenter/src/common/version" + "configcenter/src/common/http/rest" "configcenter/src/storage/dal" - "configcenter/src/storage/dal/mongo/sharding" - "configcenter/src/storage/dal/redis" ) -// Config config for upgrader -type Config struct { - TenantID string - User string -} - -// Upgrader define a version upgrader -type Upgrader struct { - version string // v3.0.8-beta.11 - do func(context.Context, dal.RDB, redis.Client, *iam.IAM, *Config) error -} - -var upgraderPool = []Upgrader{} - -var registLock sync.Mutex - -/* - v3.5.x format: - x19_09_03_02 - v3.6.x format: - y3.6.201911081042 - legacy format: - v3.0.8 - v3.0.9-beta.1 - x18_12_13_02 - x08.09.04.01 - x18.09.30.01 - x19.01.18.01 - x19_09_03_02 -*/ - -// LegacyMigrationVersion TODO -var LegacyMigrationVersion = []string{ - "v3.0.8", - "v3.0.9-beta.1", - "v3.0.9-beta.3", - "v3.1.0-alpha.2", - "x08.09.04.01", - "x08.09.11.01", - "x08.09.13.01", - "x08.09.17.01", - "x08.09.18.01", - "x08.09.26.01", - "x18.09.30.01", - "x18.10.10.01", - "x18.10.30.01", - "x18.10.30.02", - "x18.11.19.01", - "x18.12.12.01", - "x18.12.12.02", - "x18.12.12.03", - "x18.12.12.04", - "x18.12.12.05", - "x18.12.12.06", - "x18.12.13.01", - "x18_12_13_02", - "x19.01.18.01", - "x19.02.15.10", - "x19.04.16.01", - "x19.04.16.02", - "x19.04.16.03", - "x19.05.16.01", - "x19_05_22_01", - "x19_08_19_01", - "x19_08_20_01", - "x19_08_26_02", - "x19_09_03_01", - "x19_09_03_02", - "x19_09_03_03", - "x19_09_03_04", - "x19_09_03_05", - "x19_09_03_06", - "x19_09_03_07", - "x19_09_03_08", - "x19_09_06_01", - "x19_09_27_01", - "x19_10_09_01", - "x19_10_22_01", -} - -// ValidMigrationVersionFormat TODO -var ValidMigrationVersionFormat = []*regexp.Regexp{ - // regexp.MustCompile(`^v(\d+\.){2}\d+$`), - // regexp.MustCompile(`^v(\d+\.){2}\d+\-beta\.\d+$`), - // regexp.MustCompile(`^v(\d+\.){2}\d+\-alpha\.\d+$`), - // regexp.MustCompile(`^x(\d+\.){3}\d+$`), - - // v3.5.x version format - regexp.MustCompile(`^x(\d+_){3}\d+$`), - // v3.6.x version format - regexp.MustCompile(`^y(\d+\.){2}\d{12}$`), -} +// RegisterUpgrade register upgrade handler +func RegisterUpgrade(version string, handlerFunc func(*rest.Kit, dal.Dal, *Config) error) { -// ValidateMigrationVersionFormat TODO -func ValidateMigrationVersionFormat(version string) error { - // only check newer add migration's version - if util.InStrArr(LegacyMigrationVersion, version) { - return nil - } - match := false - for _, re := range ValidMigrationVersionFormat { - if re.MatchString(version) { - match = true - break - } - } - if !match { - err := fmt.Errorf(` - invalid migration version: %s, - please use a valid format: - x19_09_03_02(v3.5.x) - y3.6.201911081042(>=v3.6.x) - `, version) - return err + if err := validateVersionFormat(version); err != nil { + blog.Errorf("invalid version format, err: %v", err) + return } - - // since v3.6.x migration version must - if strings.HasPrefix(version, VersionNgPrefix) { - ngVersion, err := ParseNgVersion(version) - if err != nil { - return err - } - - // third field in version split by `.` shouldn't greater than tomorrow - timeFormat := "200601021504" - maxMigrationTime := time.Now().AddDate(0, 0, 1) - maxVersionCurrently := maxMigrationTime.Format(timeFormat) - if ngVersion.Patch >= maxVersionCurrently { - err := fmt.Errorf(` - invalid time field of migration version: %s, - please use current time as part of migration version: - ex: y3.6.%s - `, version, time.Now().Format(timeFormat)) - return err - } - } - return nil -} - -// RegistUpgrader register upgrader -func RegistUpgrader(version string, handlerFunc func(context.Context, dal.RDB, *Config) error) { - if err := ValidateMigrationVersionFormat(version); err != nil { - blog.Fatalf("ValidateMigrationVersionFormat failed, err: %s", err.Error()) - } - registLock.Lock() - defer registLock.Unlock() + registerLock.Lock() v := Upgrader{ version: version, - do: func(ctx context.Context, rdb dal.RDB, cache redis.Client, iam *iam.IAM, config *Config) error { - return handlerFunc(ctx, rdb, config) + do: func(kit *rest.Kit, rdb dal.Dal, config *Config) error { + return handlerFunc(kit, rdb, config) }, } - upgraderPool = append(upgraderPool, v) + UpgraderPool = append(UpgraderPool, v) + registerLock.Unlock() } -// RegisterUpgraderWithRedis register upgrader with redis -func RegisterUpgraderWithRedis(version string, - handlerFunc func(context.Context, dal.RDB, redis.Client, *Config) error) { - if err := ValidateMigrationVersionFormat(version); err != nil { - blog.Fatalf("ValidateMigrationVersionFormat failed, err: %s", err.Error()) - } - registLock.Lock() - defer registLock.Unlock() - v := Upgrader{ - version: version, - do: func(ctx context.Context, rdb dal.RDB, cache redis.Client, iam *iam.IAM, config *Config) error { - return handlerFunc(ctx, rdb, cache, config) - }, - } - upgraderPool = append(upgraderPool, v) -} +func validateVersionFormat(version string) error { -// RegisterUpgraderWithIAM register upgrader with iam -func RegisterUpgraderWithIAM(version string, - handlerFunc func(context.Context, dal.RDB, redis.Client, *iam.IAM, *Config) error) { - if err := ValidateMigrationVersionFormat(version); err != nil { - blog.Fatalf("validate migration version format failed, err: %s", err.Error()) + if !validVersionRegx.MatchString(version) { + blog.Errorf("invalid migration version format: %s", version) + return fmt.Errorf("invalid migration version format: %s", version) } - registLock.Lock() - defer registLock.Unlock() - v := Upgrader{ - version: version, - do: func(ctx context.Context, rdb dal.RDB, cache redis.Client, iam *iam.IAM, config *Config) error { - return handlerFunc(ctx, rdb, cache, iam, config) - }, - } - upgraderPool = append(upgraderPool, v) -} - -// Upgrade upgrade the db data to newest version -// we use date instead of version later since 2018.09.04, because the version wasn't manage by the developer -// ps: when use date instead of version, the date should add x prefix cause x > v -func Upgrade(ctx context.Context, db dal.RDB, cache redis.Client, iam *iam.IAM, conf *Config) ( - currentVersion string, finishedMigrations []string, err error) { - sort.Slice(upgraderPool, func(i, j int) bool { - return VersionCmp(upgraderPool[i].version, upgraderPool[j].version) < 0 - }) - - cmdbVersion, err := getVersion(ctx, db) - if err != nil { - return "", nil, fmt.Errorf("getVersion failed, err: %s", err.Error()) - } - cmdbVersion.Distro = ccversion.CCDistro - cmdbVersion.DistroVersion = ccversion.CCDistroVersion - - currentVersion = remapVersion(cmdbVersion.CurrentVersion) - lastVersion := "" - finishedMigrations = make([]string, 0) - for _, v := range upgraderPool { - lastVersion = remapVersion(v.version) - if VersionCmp(v.version, currentVersion) <= 0 { - blog.Infof(`currentVision is "%s" skip upgrade "%s"`, currentVersion, v.version) - continue - } - blog.Infof(`run migration: %s`, v.version) - err = v.do(ctx, db, cache, iam, conf) - if err != nil { - blog.Errorf("upgrade version %s error: %s", v.version, err.Error()) - return currentVersion, finishedMigrations, fmt.Errorf("run migration %s failed, err: %s", v.version, - err.Error()) - } - cmdbVersion.CurrentVersion = v.version - err = saveVersion(ctx, db, cmdbVersion) - if err != nil { - blog.Errorf("save version %s error: %s", v.version, err.Error()) - return currentVersion, finishedMigrations, fmt.Errorf("saveVersion failed, err: %s", err.Error()) - } - finishedMigrations = append(finishedMigrations, v.version) - blog.Infof("upgrade to version %s success", v.version) - } - - if "" == cmdbVersion.InitVersion { - cmdbVersion.InitVersion = lastVersion - cmdbVersion.InitDistroVersion = ccversion.CCDistroVersion - if err := saveVersion(ctx, db, cmdbVersion); err != nil { - return currentVersion, finishedMigrations, fmt.Errorf("saveVersion failed, err: %s", err.Error()) - } - } - return currentVersion, finishedMigrations, nil + return validateDateTimeString(version) } -// DBReady 已经执行过init_db. 数据库初始化成功 -func DBReady(ctx context.Context, db dal.Dal) (bool, error) { - - sort.Slice(upgraderPool, func(i, j int) bool { - return VersionCmp(upgraderPool[i].version, upgraderPool[j].version) < 0 - }) - - cmdbVersion, err := getVersion(ctx, db.Shard(sharding.NewShardOpts().WithIgnoreTenant())) +func validateDateTimeString(version string) error { + const layoutISO = "200601021504" + datetime := version[len(version)-len(layoutISO):] + t, err := time.Parse(layoutISO, datetime) if err != nil { - return false, fmt.Errorf("getVersion failed, err: %s", err.Error()) - } - - currentVersion := "" - for _, v := range upgraderPool { - if VersionCmp(v.version, currentVersion) <= 0 { - blog.Infof(`currentVision is "%s" skip upgrade "%s"`, currentVersion, v.version) - continue - } - currentVersion = v.version - } - if currentVersion == cmdbVersion.CurrentVersion { - return true, nil - } - return false, nil -} - -// UpgradeSpecifyVersion 强制执行version版本的migrate, 不会修改数据库cc_System表中migrate 版本 -func UpgradeSpecifyVersion(ctx context.Context, db dal.RDB, cache redis.Client, iam *iam.IAM, conf *Config, - version string) (err error) { - - sort.Slice(upgraderPool, func(i, j int) bool { - return VersionCmp(upgraderPool[i].version, upgraderPool[j].version) < 0 - }) - - hasCurrent := false - for _, v := range upgraderPool { - if v.version != version { - continue - } - blog.Infof(`run specify migration: %s`, v.version) - err = v.do(ctx, db, cache, iam, conf) - if err != nil { - blog.Errorf("upgrade specify version %s error: %s", v.version, err.Error()) - return fmt.Errorf("run specify migration %s failed, err: %s", v.version, err.Error()) - } - hasCurrent = true - } - if !hasCurrent { - return fmt.Errorf("run specify migration %s failed, err: not found", version) - } - - return nil -} -func remapVersion(v string) string { - if correct, ok := wrongVersion[v]; ok { - return correct + return fmt.Errorf("invalid datetime format: %s", datetime) } - return v -} -var wrongVersion = map[string]string{ - "x18_10_10_01": "x18.10.10.01", -} + year, month, day, hour, minute := t.Year(), int(t.Month()), t.Day(), t.Hour(), t.Minute() -func getVersion(ctx context.Context, db dal.RDB) (*Version, error) { - data := new(Version) - condition := map[string]interface{}{ - "type": SystemTypeVersion, + if year == 0 || month <= 0 || month > 12 || day <= 0 || day > 31 || hour < 0 || hour > 23 || minute < 0 || minute > 59 { + return fmt.Errorf("invalid datetime format: %s", datetime) } - err := db.Table(common.BKTableNameSystem).Find(condition).One(ctx, &data) - if db.IsNotFoundError(err) { - data = new(Version) - data.Type = SystemTypeVersion - err = db.Table(common.BKTableNameSystem).Insert(ctx, data) - if err != nil { - return nil, err - } - return data, nil + maxMigrationTime := time.Now().AddDate(0, 0, 1) + maxVersionCurrently := maxMigrationTime.Format(layoutISO) + if datetime >= maxVersionCurrently { + return fmt.Errorf("invalid datetime format, time is longer than now: %s", datetime) } - if err != nil { - blog.Errorf("get system version error,err:%s", err.Error()) - return nil, err - } - - return data, nil -} - -func saveVersion(ctx context.Context, db dal.RDB, version *Version) error { - condition := map[string]interface{}{ - "type": SystemTypeVersion, - } - return db.Table(common.BKTableNameSystem).Update(ctx, condition, version) -} - -// System TODO -type System struct { - Type string `bson:"type"` -} - -// Version TODO -type Version struct { - System `bson:",inline"` - CurrentVersion string `bson:"current_version"` - Distro string `bson:"distro"` - DistroVersion string `bson:"distro_version"` - InitVersion string `bson:"init_version"` - InitDistroVersion string `bson:"init_distro_version"` + return nil } - -// SystemTypeVersion TODO -const SystemTypeVersion = "version" diff --git a/src/scene_server/admin_server/upgrader/tools/create_index.go b/src/scene_server/admin_server/upgrader/tools/create_index.go new file mode 100644 index 0000000000..e48769e34c --- /dev/null +++ b/src/scene_server/admin_server/upgrader/tools/create_index.go @@ -0,0 +1,68 @@ +package tools + +import ( + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/storage/dal" + "configcenter/src/storage/dal/types" + "go.mongodb.org/mongo-driver/bson" +) + +func CreateIndexes(kit *rest.Kit, db dal.Dal, table string, indexes []types.Index) error { + existIndexes, err := db.Shard(kit.ShardOpts()).Table(table).Indexes(kit.Ctx) + if err != nil { + blog.Errorf("get %s table index failed, err: %v", table, err) + return err + } + + existIndexMap := make(map[string]struct{}) + for _, index := range existIndexes { + existIndexMap[index.Name] = struct{}{} + } + + for _, index := range indexes { + if _, exist := existIndexMap[index.Name]; exist { + continue + } + + if isExitKeys(existIndexes, index) { + continue + } + + err = db.Shard(kit.ShardOpts()).Table(table).CreateIndex(kit.Ctx, index) + if err != nil && !db.Shard(kit.ShardOpts()).IsDuplicatedError(err) { + blog.Errorf("create %s table index %+v failed, err: %v", table, index, err) + return err + } + } + + return nil +} + +func isExitKeys(existIndexes []types.Index, newIndex types.Index) bool { + for _, index := range existIndexes { + if len(index.Keys) != len(newIndex.Keys) { + continue + } + + if cmpBsonD(index.Keys, newIndex.Keys) { + return true + } + } + + return false +} + +func cmpBsonD(dbKey, newKey bson.D) bool { + if len(dbKey) != len(newKey) { + return false + } + + for i := 0; i < len(dbKey); i++ { + if dbKey[i].Key != newKey[i].Key || dbKey[i].Value != newKey[i].Value { + return false + } + } + + return true +} diff --git a/src/scene_server/admin_server/upgrader/tools/create_table.go b/src/scene_server/admin_server/upgrader/tools/create_table.go new file mode 100644 index 0000000000..308a596949 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/tools/create_table.go @@ -0,0 +1,45 @@ +package tools + +import ( + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/storage/dal" +) + +func CreateTable(kit *rest.Kit, db dal.Dal, table string) error { + exists, err := db.Shard(kit.ShardOpts()).HasTable(kit.Ctx, table) + if err != nil { + blog.Errorf("check if %s exists failed, err: %v", table, err) + return err + } + + if exists { + return nil + } + + if err = db.Shard(kit.ShardOpts()).CreateTable(kit.Ctx, table); err != nil { + blog.Errorf("create %s table failed, err: %v", table, err) + return err + } + + return nil +} + +func CreatePlatTable(kit *rest.Kit, db dal.Dal, table string) error { + exists, err := db.Shard(kit.SysShardOpts()).HasTable(kit.Ctx, table) + if err != nil { + blog.Errorf("check if %s exists failed, err: %v", table, err) + return err + } + + if exists { + return nil + } + + if err = db.Shard(kit.SysShardOpts()).CreateTable(kit.Ctx, table); err != nil { + blog.Errorf("create %s table failed, err: %v", table, err) + return err + } + + return nil +} diff --git a/src/scene_server/admin_server/upgrader/upgrader.go b/src/scene_server/admin_server/upgrader/upgrader.go index 6cb66a93ce..84b3573174 100644 --- a/src/scene_server/admin_server/upgrader/upgrader.go +++ b/src/scene_server/admin_server/upgrader/upgrader.go @@ -1,2 +1,62 @@ -// Package upgrader TODO package upgrader + +import ( + "fmt" + "sort" + "strings" + + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + ccversion "configcenter/src/common/version" + "configcenter/src/storage/dal" +) + +// Upgrade cmdb to new version +func Upgrade(kit *rest.Kit, db dal.Dal, cfg *Config) (currentVersion string, finishedMigrations []string, + err error) { + + sort.Slice(UpgraderPool, func(i, j int) bool { + return strings.Compare(UpgraderPool[i].version, UpgraderPool[j].version) < 0 + }) + + cmdbVersion, err := getVersion(kit, db) + if err != nil { + return "", nil, fmt.Errorf("getVersion failed, err: %v", err) + } + cmdbVersion.Distro = ccversion.CCDistro + cmdbVersion.DistroVersion = ccversion.CCDistroVersion + + currentVersion = cmdbVersion.CurrentVersion + finishedMigrations = make([]string, 0) + for _, v := range UpgraderPool { + if strings.Compare(v.version, currentVersion) <= 0 { + blog.Infof("currentVision is %s skip upgrade %s", currentVersion, v.version) + continue + } + blog.Infof("run migration: %s", v.version) + err = v.do(kit, db, cfg) + if err != nil { + blog.Errorf("upgrade version %s failed, error: %v", v.version, err) + return currentVersion, finishedMigrations, fmt.Errorf("upgrade version %s failed, err: %s", v.version, + err) + } + cmdbVersion.CurrentVersion = v.version + err = saveVersion(kit, db, cmdbVersion) + if err != nil { + blog.Errorf("save version %s failed, error: %s", v.version, err) + return currentVersion, finishedMigrations, fmt.Errorf("save version %s error: %s", v.version, err) + } + finishedMigrations = append(finishedMigrations, v.version) + blog.Infof("upgrade to version %s success", v.version) + currentVersion = v.version + } + + if cmdbVersion.InitVersion == "" { + cmdbVersion.InitVersion = currentVersion + cmdbVersion.InitDistroVersion = ccversion.CCDistroVersion + if err := saveVersion(kit, db, cmdbVersion); err != nil { + return currentVersion, finishedMigrations, fmt.Errorf("saveVersion failed, err: %v", err) + } + } + return currentVersion, finishedMigrations, nil +} diff --git a/src/scene_server/admin_server/upgrader/utils.go b/src/scene_server/admin_server/upgrader/utils.go new file mode 100644 index 0000000000..9663b99ec9 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/utils.go @@ -0,0 +1,40 @@ +package upgrader + +import ( + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/storage/dal" +) + +func getVersion(kit *rest.Kit, db dal.Dal) (*Version, error) { + data := new(Version) + condition := map[string]interface{}{ + "type": SystemTypeVersion, + } + + err := db.Shard(kit.SysShardOpts()).Table(common.BKTableNameSystem).Find(condition).One(kit.Ctx, &data) + if db.Shard(kit.SysShardOpts()).IsNotFoundError(err) { + data = new(Version) + data.Type = SystemTypeVersion + + err = db.Shard(kit.SysShardOpts()).Table(common.BKTableNameSystem).Insert(kit.Ctx, data) + if err != nil { + return nil, err + } + return data, nil + } + if err != nil { + blog.Errorf("get system version error,err:%s", err.Error()) + return nil, err + } + + return data, nil +} + +func saveVersion(kit *rest.Kit, db dal.Dal, version *Version) error { + condition := map[string]interface{}{ + "type": SystemTypeVersion, + } + return db.Shard(kit.SysShardOpts()).Table(common.BKTableNameSystem).Update(kit.Ctx, condition, version) +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_applicationbase_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_applicationbase_data.go new file mode 100644 index 0000000000..0932d53160 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_applicationbase_data.go @@ -0,0 +1,237 @@ +package data + +import ( + "fmt" + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func AddApplicationData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameBaseApp) + if err := addBuleKingAppData(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add blueking app data failed, err: %v", err) + return err + } + + if err := addDefaultAppData(kit, db, conf); err != nil { + blog.Errorf("add default app data failed, err: %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameBaseApp) + return nil +} + +func addBuleKingAppData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + for _, data := range BlueKingBizData { + + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameBaseApp) + if err != nil { + blog.Errorf("get next audit log id failed, err: %v", err) + return err + } + data.BizID = int64(id) + + setID, err := addMuduleData(kit, db, data, conf) + if err != nil { + blog.Errorf("add module data failed, %v", err) + return err + } + + if err := addDefaultFaultModule(kit, db, setID, uint64(data.BizID), conf); err != nil { + blog.Errorf("add default fault module data failed, %v", err) + return err + } + if err := addRecycleModule(kit, db, setID, uint64(data.BizID), conf); err != nil { + blog.Errorf("add recycle module data failed, %v", err) + return err + } + } + + if err := addDefaultAppData(kit, db, conf); err != nil { + blog.Errorf("add default app data failed, err: %v", err) + return err + } + return nil +} + +func addDefaultAppData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + for _, data := range DefaultBizData { + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameBaseApp) + if err != nil { + blog.Errorf("get next audit log id failed, err: %v", err) + return err + } + data.BizID = int64(id) + + _, err = addMuduleData(kit, db, data, conf) + if err != nil { + blog.Errorf("add default module data failed, %v", err) + return err + } + } + return nil +} + +func addMuduleData(kit *rest.Kit, db dal.Dal, data *ApplicationData, conf *upgrader.Config) (uint64, error) { + curTime := time.Now() + data.TenantID = kit.TenantID + data.CreateTime = &curTime + data.LastTime = &curTime + + cond := mapstr.MapStr{common.BKAppNameField: data.BizName} + result := make([]ApplicationData, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseApp).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("get biz failed, err: %v", err) + return 0, err + } + if len(result) >= 1 { + blog.Errorf("duplicate bizName %s", data.BizName) + return 0, fmt.Errorf("duplicate bizName %s", data.BizName) + } + + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseApp).Insert(kit.Ctx, data); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseApp) + return 0, err + } + + // 添加审计数据 + if err := addAuditLog(kit, db, data, uint64(data.BizID), conf); err != nil { + blog.Errorf("add audit log data, error: %v", err) + return 0, err + } + + setID, err := addSetBaseData(kit, db, data.BizID, conf) + if err != nil { + blog.Errorf("add set base data failed, error: %v", err) + return 0, err + } + if err := addDefaultResModule(kit, db, setID, uint64(data.BizID), conf); err != nil { + blog.Errorf("add default module data failed, error: %v", err) + return 0, err + } + return setID, nil +} + +// BlueKingBizData 业务数据 +var BlueKingBizData = []*ApplicationData{ + { + BizName: common.BKAppName, + BizMaintainer: "admin", + BizProductor: "", + TimeZone: "Asia/Shanghai", + Language: "1", + LifeCycle: common.DefaultAppLifeCycleNormal, + Default: common.DefaultFlagDefaultValue, + BizTester: "", + Operator: "", + BizDeveloper: "", + }, +} + +// DefaultBizData 资源池业务数据 +var DefaultBizData = []*ApplicationData{ + { + BizName: common.DefaultAppName, + BizProductor: "admin", + BizMaintainer: "admin", + TimeZone: "Asia/Shanghai", + Language: "1", + LifeCycle: common.DefaultAppLifeCycleNormal, + Default: common.DefaultAppFlag, + BizTester: "", + Operator: "", + BizID: 1, + BizDeveloper: "", + }, +} + +func addAuditLog(kit *rest.Kit, db dal.Dal, data *ApplicationData, bizID uint64, + conf *upgrader.Config) error { + + action := metadata.AuditCreate + logDetail := &BasicContent{ + CurData: *data, + } + + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameAuditLog) + if err != nil { + blog.Errorf("get next audit log id failed, err: %s", err) + return err + } + log := metadata.AuditLog{ + ID: int64(id), + AuditType: metadata.BusinessType, + TenantID: kit.TenantID, + User: conf.User, + ResourceType: metadata.BusinessRes, + Action: action, + OperateFrom: metadata.FromCCSystem, + BusinessID: int64(bizID), + ResourceID: int64(bizID), + ResourceName: data.BizName, + OperationDetail: &InstanceOpDetail{ + BasicOpDetail: BasicOpDetail{ + Details: logDetail, + }, + ModelID: common.BKInnerObjIDApp, + }, + OperationTime: metadata.Now(), + } + + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameAuditLog).Insert(kit.Ctx, log); err != nil { + blog.Errorf("add audit log %s error %v", log, err) + return err + } + return nil +} + +type ApplicationData struct { + ID int64 `field:"id" json:"id" bson:"id"` + TenantID string `field:"tenant_id" json:"tenant_id" bson:"tenant_id"` + BizMaintainer string `field:"bk_biz_maintainer" json:"bk_biz_maintainer" bson:"bk_biz_maintainer"` + LifeCycle string `field:"life_cycle" json:"life_cycle" bson:"life_cycle"` + CreateTime *time.Time `json:"create_time" bson:"create_time"` + LastTime *time.Time `json:"last_time" bson:"last_time"` + Default int `field:"default" json:"default" bson:"default"` + BizTester string `field:"bk_biz_tester" json:"bk_biz_tester" bson:"bk_biz_tester"` + Operator string `field:"operator" json:"operator" bson:"operator"` + BizProductor string `field:"bk_biz_productor" json:"bk_biz_productor" bson:"bk_biz_productor"` + TimeZone string `field:"time_zone" json:"time_zone" bson:"time_zone"` + Language string `field:"language" json:"language" bson:"language"` + BizID int64 `field:"bk_biz_id" json:"bk_biz_id" bson:"bk_biz_id"` + BizName string `field:"bk_biz_name" json:"bk_biz_name" bson:"bk_biz_name"` + BizDeveloper string `field:"bk_biz_developer" json:"bk_biz_developer" bson:"bk_biz_developer"` +} + +// BasicContent contains the details information with in a user's operation. +type BasicContent struct { + // PreData the previous data before the deletion or updating operation + PreData ApplicationData `json:"pre_data" bson:"pre_data"` + // CurData the current date after the creation operation + CurData ApplicationData `json:"cur_data" bson:"cur_data"` + // UpdateFields the data that user uses to update the pre data, might not be the actual changed data + UpdateFields ApplicationData `json:"update_fields" bson:"update_fields"` +} + +type InstanceOpDetail struct { + BasicOpDetail `bson:",inline"` + // BkObjID the object ID of the instance's model + ModelID string `json:"bk_obj_id" bson:"bk_obj_id"` +} + +type BasicOpDetail struct { + // Details contains all the details information about a user's operation + Details *BasicContent `json:"details" bson:"details"` +} + +func (op *InstanceOpDetail) WithName() string { + return "InstanceOpDetail" +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_asstdes_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_asstdes_data.go new file mode 100644 index 0000000000..e8c56d7233 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_asstdes_data.go @@ -0,0 +1,109 @@ +package data + +import ( + "fmt" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +var asstTypes = []*metadata.AssociationKind{ + &metadata.AssociationKind{ + AssociationKindID: "belong", + AssociationKindName: "属于", + SourceToDestinationNote: "属于", + DestinationToSourceNote: "包含", + Direction: metadata.DestinationToSource, + IsPre: &trueVar, + }, + &metadata.AssociationKind{ + AssociationKindID: "group", + AssociationKindName: "组成", + SourceToDestinationNote: "组成", + DestinationToSourceNote: "组成于", + Direction: metadata.DestinationToSource, + IsPre: &trueVar, + }, + &metadata.AssociationKind{ + AssociationKindID: "bk_mainline", + AssociationKindName: "拓扑组成", + SourceToDestinationNote: "组成", + DestinationToSourceNote: "组成于", + Direction: metadata.DestinationToSource, + IsPre: &trueVar, + }, + &metadata.AssociationKind{ + AssociationKindID: "run", + AssociationKindName: "运行", + SourceToDestinationNote: "运行于", + DestinationToSourceNote: "运行", + Direction: metadata.DestinationToSource, + IsPre: &trueVar, + }, + &metadata.AssociationKind{ + AssociationKindID: "connect", + AssociationKindName: "上联", + SourceToDestinationNote: "上联", + DestinationToSourceNote: "下联", + Direction: metadata.DestinationToSource, + IsPre: &trueVar, + }, + &metadata.AssociationKind{ + AssociationKindID: "default", + AssociationKindName: "默认关联", + SourceToDestinationNote: "关联", + DestinationToSourceNote: "被关联", + Direction: metadata.DestinationToSource, + IsPre: &trueVar, + }, +} + +func AddAssociationType(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameAsstDes) + if err := addAssociationTypeTenant(kit, db, conf); err != nil { + fmt.Errorf("add association type failed, error: %v", err) + } + + if err := addAssociationTypeTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + fmt.Errorf("add association type failed, error: %v", err) + } + blog.Infof("end add init data for table: %s", common.BKTableNameAsstDes) + + return nil +} + +func addAssociationTypeTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + + for _, asstType := range asstTypes { + cond := map[string]interface{}{common.AssociationKindIDField: asstType.AssociationKindID} + result := make([]map[string]interface{}, 0) + err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameAsstDes).Find(cond).All(kit.Ctx, &result) + if err != nil { + blog.Errorf("find id generator data failed, cond: %+v, err: %v", cond, err) + return err + } + + if len(result) >= 1 { + blog.Errorf("duplicate asst type %s", asstType.AssociationKindID) + return fmt.Errorf("duplicate asst type %s", asstType.AssociationKindID) + } + + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameAsstDes) + if err != nil { + blog.Errorf("get next audit log id failed, err: %s", err) + return err + } + asstType.ID = int64(id) + asstType.TenantID = conf.TenantID + + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameAsstDes).Insert(kit.Ctx, asstType); err != nil { + blog.Errorf("add data for %s table failed, err: %v", common.BKTableNameAsstDes, err) + return err + } + } + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_bizsetbase_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_bizsetbase_data.go new file mode 100644 index 0000000000..228f75ff6e --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_bizsetbase_data.go @@ -0,0 +1,98 @@ +package data + +import ( + "fmt" + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +var data = []*metadata.BizSetInst{ + { + BizSetID: 9991001, + BizSetName: "BlueKing", + BizSetMaintainer: "admin", + CreateTime: metadata.Time{time.Now()}, + LastTime: metadata.Time{time.Now()}, + Default: common.DefaultResBusinessSetFlag, + Scope: metadata.BizSetScope{ + MatchAll: true, + }, + }, +} + +func AddDefaultBusinessSetData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameBaseBizSet) + if err := addDefaultBusinessSetDataTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add default business set data failed, %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameBaseBizSet) + return nil +} + +func addDefaultBusinessSetDataTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + for _, data := range data { + data.TenantID = kit.TenantID + result := make([]metadata.BizSetInst, 0) + filter := map[string]interface{}{ + common.BKDBOR: []map[string]interface{}{ + { + common.BKBizSetIDField: data.BizSetID, + }, + { + common.BKBizSetNameField: data.BizSetName, + }, + }, + } + + err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseBizSet).Find(filter).All(kit.Ctx, &result) + if err != nil && !db.Shard(kit.ShardOpts()).IsNotFoundError(err) { + blog.Errorf("find business set failed, err: %v", err) + return err + } + + if len(result) >= 2 { + blog.Errorf("business set id %s and name %s already exists, the number of business set that meet the "+ + "condition is greater than 2, val: %v", data.BizSetID, data.BizSetName, result) + return fmt.Errorf("failed to add default business set, business set id: %d or name: %s already exists, the "+ + "number of business set that meet the condition is greater than 2", data.BizSetID, data.BizSetName) + } + + if len(result) == 1 { + if result[0].BizSetID == data.BizSetID && result[0].BizSetName == data.BizSetName && result[0].Scope.MatchAll && + result[0].TenantID == conf.TenantID { + + if result[0].Default != common.DefaultResBusinessSetFlag { + data := map[string]interface{}{ + common.BKDefaultField: common.DefaultResBusinessSetFlag, + } + + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseBizSet).Update(kit.Ctx, filter, + data); err != nil { + blog.Errorf("update business set default val failed, err: %v", err) + return err + } + } + + return nil + } + + blog.Errorf("business set id %s or name %s already exists, user needs to deal with duplicates first to "+ + "successfully upgrade", data.BizSetID, data.BizSetName) + return fmt.Errorf("failed to add default business set, business set id: %d or name: %s already exists, user "+ + "needs to deal with duplicates first to successfully upgrade", data.BizSetID, data.BizSetName) + } + + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseBizSet).Insert(kit.Ctx, data); err != nil { + blog.Errorf("insert default business set failed, val: %v, err: %v", data, err) + return err + } + } + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_idgenerator_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_idgenerator_data.go new file mode 100644 index 0000000000..aa84791ea4 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_idgenerator_data.go @@ -0,0 +1,86 @@ +package data + +import ( + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/common/metadata" + "configcenter/src/common/util" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func AddSelfIncrIDData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameIDgenerator) + if err := addSelfIncrIDTenant(kit, db, conf); err != nil { + blog.Errorf("add self incr id data failed, err: %v", err) + return err + } + + if err := addSelfIncrIDTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add self incr id data failed, err: %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameIDgenerator) + return nil +} + +func addSelfIncrIDTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + objects := make([]metadata.Object, 0) + err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjDes).Find(mapstr.MapStr{}).Fields(common.BKObjIDField). + All(kit.Ctx, &objects) + if err != nil { + blog.Errorf("find all objects failed, err: %v", err) + return err + } + + ids := make([]string, 0) + for _, object := range objects { + ids = append(ids, metadata.GetIDRule(object.ObjectID)) + } + ids = append(ids, metadata.GetIDRule(common.GlobalIDRule)) + + cond := mapstr.MapStr{common.BKFieldDBID: mapstr.MapStr{common.BKDBIN: ids}} + data := make([]map[string]interface{}, 0) + err = db.Shard(kit.SysShardOpts()).Table(common.BKTableNameIDgenerator).Find(cond).Fields(common.BKFieldDBID). + All(kit.Ctx, &data) + if err != nil { + blog.Errorf("find id generator data failed, cond: %+v, err: %v", cond, err) + return err + } + + dbIDMap := make(map[string]struct{}) + for _, val := range data { + dbIDMap[util.GetStrByInterface(val[common.BKFieldDBID])] = struct{}{} + } + + needAddIDs := make([]map[string]interface{}, 0) + now := time.Now() + for _, id := range ids { + if _, ok := dbIDMap[id]; ok { + continue + } + + addID := map[string]interface{}{ + common.BKFieldDBID: id, + common.BKFieldSeqID: 0, + common.CreateTimeField: now, + common.LastTimeField: now, + } + needAddIDs = append(needAddIDs, addID) + } + + if len(needAddIDs) == 0 { + return nil + } + + if err = db.Shard(kit.SysShardOpts()).Table(common.BKTableNameIDgenerator).Insert(kit.Ctx, needAddIDs); err != nil { + blog.Errorf("add id generator data failed, data: %+v, err: %v", needAddIDs, err) + return err + } + + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_modulebase_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_modulebase_data.go new file mode 100644 index 0000000000..bd07327402 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_modulebase_data.go @@ -0,0 +1,164 @@ +package data + +import ( + "fmt" + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func addDefaultResModule(kit *rest.Kit, db dal.Dal, setID, bizID uint64, conf *upgrader.Config) error { + + data := map[string]interface{}{ + common.BKSetIDField: setID, + common.BKInstParentStr: setID, + common.BKAppIDField: bizID, + common.BKModuleNameField: common.DefaultResModuleName, + common.BKDefaultField: common.DefaultResModuleFlag, + common.TenantID: kit.TenantID, + common.BKServiceCategoryIDField: 2, + common.BKSetTemplateIDField: 0, + common.HostApplyEnabledField: false, + common.BKModuleTypeField: "1", + common.CreateTimeField: time.Now(), + common.LastTimeField: time.Now(), + } + + cond := mapstr.MapStr{ + common.BKAppIDField: data[common.BKAppIDField], + common.BKSetIDField: data[common.BKSetIDField], + common.BKModuleNameField: data[common.BKModuleNameField], + } + result := make([]map[string]interface{}, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseModule).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("get module base failed, condition: %+v, err: %v", cond, err) + return err + } + + if len(result) >= 1 { + blog.Errorf("module is exit, table: %s, cond: %+v", common.BKTableNameBaseModule, cond) + return fmt.Errorf("module is exit, table: %s", common.BKTableNameBaseModule) + } + + ID, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameBaseModule) + if err != nil { + blog.Errorf("failed to get next sequence, err: %v, tableName: %s", err, common.BKTableNameBaseModule) + return err + } + data[common.BKModuleIDField] = ID + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseModule).Insert(kit.Ctx, data); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseModule) + return fmt.Errorf("insert error %v", err) + } + + return nil +} + +func addDefaultFaultModule(kit *rest.Kit, db dal.Dal, setID, bizID uint64, conf *upgrader.Config) error { + + data := map[string]interface{}{ + common.BKSetIDField: setID, + common.BKInstParentStr: setID, + common.BKAppIDField: bizID, + common.BKModuleNameField: common.DefaultFaultModuleName, + common.BKDefaultField: common.DefaultFaultModuleFlag, + common.TenantID: kit.TenantID, + common.BKServiceCategoryIDField: 2, + common.BKServiceTemplateIDField: common.ServiceTemplateIDNotSet, + common.BKSetTemplateIDField: common.SetTemplateIDNotSet, + common.HostApplyEnabledField: false, + common.BKModuleTypeField: "1", + common.BKOperatorField: "", + common.BKBakOperatorField: "", + common.CreateTimeField: time.Now(), + common.LastTimeField: time.Now(), + } + + cond := mapstr.MapStr{ + common.BKAppIDField: data[common.BKAppIDField], + common.BKSetIDField: data[common.BKSetIDField], + common.BKModuleNameField: data[common.BKModuleNameField], + } + result := make([]map[string]interface{}, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseModule).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("get module base failed, condition: %+v, err: %v", cond, err) + return err + } + + if len(result) >= 1 { + blog.Errorf("module is exit, table: %s, cond: %v", common.BKTableNameBaseModule, cond) + return fmt.Errorf("module is exit, table: %s", common.BKTableNameBaseModule) + } + + ID, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameBaseModule) + if err != nil { + blog.Errorf("failed to get next sequence, err: %v, tableName: %s", err, common.BKTableNameBaseModule) + return err + } + data[common.BKModuleIDField] = ID + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseModule).Insert(kit.Ctx, data); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseModule) + return err + } + + return nil +} + +func addRecycleModule(kit *rest.Kit, db dal.Dal, setID, bizID uint64, conf *upgrader.Config) error { + // add recycle module + + data := map[string]interface{}{ + common.BKSetIDField: setID, + common.BKParentIDField: setID, + common.TenantID: kit.TenantID, + common.BKModuleTypeField: common.DefaultModuleType, + common.BKOperatorField: "", + common.BKModuleNameField: common.DefaultRecycleModuleName, + common.BKDefaultField: common.DefaultRecycleModuleFlag, + common.BKBakOperatorField: "", + common.BKServiceCategoryIDField: 2, + common.BKServiceTemplateIDField: common.ServiceTemplateIDNotSet, + common.BKSetTemplateIDField: common.SetTemplateIDNotSet, + common.HostApplyEnabledField: false, + common.CreateTimeField: time.Now(), + common.LastTimeField: time.Now(), + common.BKAppIDField: bizID, + } + + cond := mapstr.MapStr{ + common.BKAppIDField: data[common.BKAppIDField], + common.BKSetIDField: data[common.BKSetIDField], + common.BKModuleNameField: data[common.BKModuleNameField], + } + result := make([]map[string]interface{}, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseModule).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("get module base failed, condition: %+v, err: %v", cond, err) + return err + } + + if len(result) >= 1 { + blog.Errorf("module is exit, table: %s, cond: %v", common.BKTableNameBaseModule, cond) + return fmt.Errorf("module is exit, table: %s", common.BKTableNameBaseModule) + } + + ID, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameBaseModule) + if err != nil { + blog.Errorf("failed to get next sequence, err: %v, tableName: %s", err, common.BKTableNameBaseModule) + return err + } + data[common.BKModuleIDField] = ID + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseModule).Insert(kit.Ctx, data); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseModule) + return err + } + + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objAttDesc_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objAttDesc_data.go new file mode 100644 index 0000000000..8719ae74df --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objAttDesc_data.go @@ -0,0 +1,246 @@ +package data + +import ( + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func getBizObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range bizObjAttrs { + attr.ObjectID = "biz" + attr.Unit = "" + attr.Placeholder = "" + attr.IsPre = true + attr.IsReadOnly = false + attr.IsOnly = false + attr.IsSystem = false + attr.Default = nil + attr.IsAPI = false + attr.Description = "" + attr.TemplateID = 0 + attr.Creator = "cc_system" + attr.CreateTime = &time + attr.LastTime = &time + } + blog.Errorf("%s", bizObjAttrs[0].ObjectID) + + return bizObjAttrs +} + +func getHostObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range hostObjAttrs { + attr.BizID = 0 + attr.Creator = "cc_system" + attr.Default = nil + attr.IsOnly = false + attr.IsPre = true + attr.IsRequired = false + attr.ObjectID = "host" + attr.TemplateID = 0 + attr.CreateTime = &time + attr.LastTime = &time + } + return hostObjAttrs +} + +func getSetObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range setObjAttrs { + attr.BizID = 0 + attr.Creator = "cc_system" + attr.Default = nil + attr.IsOnly = false + attr.IsPre = true + attr.ObjectID = "set" + attr.Placeholder = "" + attr.PropertyGroup = "default" + attr.Unit = "" + attr.TemplateID = 0 + attr.CreateTime = &time + attr.LastTime = &time + } + return setObjAttrs +} + +func getProcessObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range processObjAttrs { + attr.BizID = 0 + attr.Creator = "cc_system" + attr.Default = nil + attr.IsOnly = false + attr.IsPre = true + attr.IsReadOnly = true + attr.IsSystem = true + attr.ObjectID = "process" + attr.TemplateID = 0 + attr.CreateTime = &time + attr.LastTime = &time + } + return processObjAttrs +} + +func getModuleObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range moduleObjAttrs { + attr.BizID = 0 + attr.Creator = "cc_system" + attr.Default = nil + attr.IsOnly = false + attr.IsPre = true + attr.ObjectID = "module" + attr.PropertyGroup = "default" + attr.Unit = "" + attr.TemplateID = 0 + attr.CreateTime = &time + attr.LastTime = &time + } + return moduleObjAttrs +} + +func getPlatObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range platObjAttrs { + attr.BizID = 0 + attr.Creator = "cc_system" + attr.Default = nil + attr.Description = "" + attr.IsAPI = false + attr.IsOnly = false + attr.IsPre = true + attr.IsReadOnly = false + attr.IsSystem = false + attr.Placeholder = "" + attr.ObjectID = "plat" + attr.PropertyGroup = "default" + attr.Unit = "" + attr.TemplateID = 0 + attr.CreateTime = &time + attr.LastTime = &time + } + return platObjAttrs +} + +func getBizSetObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range bizSetObjAttrData { + attr.BizID = 0 + attr.Creator = "cc_system" + attr.Default = nil + attr.Description = "" + attr.IsOnly = false + attr.IsPre = true + attr.IsReadOnly = false + attr.IsSystem = false + attr.Placeholder = "" + attr.ObjectID = "bk_biz_set_obj" + attr.PropertyGroup = "default" + attr.Unit = "" + attr.TemplateID = 0 + attr.CreateTime = &time + attr.LastTime = &time + } + return bizSetObjAttrData +} + +func getProjectObjAttrs() []*metadata.Attribute { + time := metadata.Now() + for _, attr := range projectObjAttrs { + attr.BizID = 0 + attr.Creator = "cc_system" + attr.Default = nil + attr.Description = "" + attr.IsOnly = false + attr.IsPre = true + attr.IsReadOnly = false + attr.IsSystem = false + attr.Placeholder = "" + attr.ObjectID = "bk_project" + attr.PropertyGroup = "default" + attr.Unit = "" + attr.TemplateID = 0 + attr.CreateTime = &time + attr.LastTime = &time + } + return projectObjAttrs +} + +func AddObjAttrData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameObjAttDes) + objAttrData = append(objAttrData, getBizObjAttrs()...) + objAttrData = append(objAttrData, getProjectObjAttrs()...) + objAttrData = append(objAttrData, getPlatObjAttrs()...) + objAttrData = append(objAttrData, getModuleObjAttrs()...) + objAttrData = append(objAttrData, getHostObjAttrs()...) + objAttrData = append(objAttrData, getSetObjAttrs()...) + objAttrData = append(objAttrData, getProcessObjAttrs()...) + objAttrData = append(objAttrData, getBizSetObjAttrs()...) + + if err := addObjAttrDataTenant(kit, db, conf); err != nil { + blog.Errorf("add obj attribute data failed, %v", err) + return err + } + + if err := addObjAttrDataTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add obj attribute data failed, %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameObjAttDes) + + return nil +} + +func addObjAttrDataTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + for _, attr := range objAttrData { + if attrIndex, err := getAttrLastIndex(kit, db, attr); err != nil { + attr.PropertyIndex = attrIndex + 1 + } + attr.TenantID = kit.TenantID + instID, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameObjAttDes) + if err != nil { + blog.Errorf("failed to get next sequence, error: %v, table: %s", err, common.BKTableNameObjAttDes) + return err + } + attr.ID = int64(instID) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjAttDes).Insert(kit.Ctx, attr); err != nil { + blog.Error("insert obj attribute data failed, error: %v", err) + return err + } + } + return nil +} + +// getAttrLastIndex 获取属性的最后一个计数索引 +func getAttrLastIndex(kit *rest.Kit, db dal.Dal, attribute *metadata.Attribute) (int64, error) { + + opt := make(map[string]interface{}) + opt[common.BKObjIDField] = attribute.ObjectID + opt[common.BKPropertyGroupField] = attribute.PropertyGroup + count, err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjAttDes).Find(opt).Count(kit.Ctx) + if err != nil { + blog.Error("count obj attribute failed, error: %v", err) + return 0, err + } + if count <= 0 { + return 0, nil + } + + attrs := make([]metadata.Attribute, 0) + sortCond := "-bk_property_index" + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjAttDes).Find(opt).Sort(sortCond).Limit(1).All(kit.Ctx, + &attrs); err != nil { + blog.Error("get obj attribute failed, err: %v ", err) + return 0, err + } + + if len(attrs) <= 0 { + return 0, nil + } + return attrs[0].PropertyIndex, nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objasst_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objasst_data.go new file mode 100644 index 0000000000..9c54399452 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objasst_data.go @@ -0,0 +1,88 @@ +package data + +import ( + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +var switchAsst = []*metadata.Association{ + { + AsstKindID: "bk_mainline", + ObjectID: "set", + AsstObjID: "biz", + AssociationName: "set_bk_mainline_biz", + Mapping: metadata.OneToOneMapping, + OnDelete: metadata.NoAction, + IsPre: &trueVar, + AssociationAliasName: "", + }, + { + AsstKindID: "bk_mainline", + ObjectID: "module", + AsstObjID: "set", + AssociationName: "module_bk_mainline_set", + Mapping: metadata.OneToOneMapping, + OnDelete: metadata.NoAction, + IsPre: &trueVar, + AssociationAliasName: "", + }, + { + AsstKindID: "bk_mainline", + ObjectID: "host", + AsstObjID: "module", + AssociationName: "host_bk_mainline_module", + Mapping: metadata.OneToOneMapping, + OnDelete: metadata.NoAction, + IsPre: &trueVar, + AssociationAliasName: "", + }, + { + AsstKindID: "connect", + ObjectID: "bk_switch", + AsstObjID: "host", + AssociationName: "bk_switch_connect_host", + Mapping: metadata.OneToManyMapping, + OnDelete: metadata.NoAction, + IsPre: &falseVar, + AssociationAliasName: "", + }, +} + +func AddObjAssociationData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameObjAsst) + if err := addObjAssociationTenant(kit, db, conf); err != nil { + blog.Errorf("add switch association data failed, err: %v", err) + return err + } + + if err := addObjAssociationTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add switch association data failed, err: %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameObjAsst) + return nil +} + +func addObjAssociationTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + + for _, asst := range switchAsst { + asst.TenantID = kit.TenantID + + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameObjAsst) + if err != nil { + blog.Errorf("get next obj assosiation id failed, err: %s", err) + return err + } + asst.ID = int64(id) + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjAsst).Insert(kit.Ctx, asst); err != nil { + blog.Errorf("add next obj assosiation data failed, data: %+v, err: %v", asst, err) + return err + } + } + + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objclassfication_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objclassfication_data.go new file mode 100644 index 0000000000..2bc25401e0 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objclassfication_data.go @@ -0,0 +1,98 @@ +package data + +import ( + "fmt" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +var objClassificationDataData = []*metadata.Classification{ + { + ClassificationID: "bk_host_manage", + ClassificationName: "主机管理", + ClassificationType: "", + ClassificationIcon: "icon-cc-host", + }, + { + ClassificationID: "bk_biz_topo", + ClassificationName: "业务拓扑", + ClassificationType: "", + ClassificationIcon: "icon-cc-business", + }, + { + ClassificationID: "bk_organization", + ClassificationName: "组织架构", + ClassificationType: "", + ClassificationIcon: "icon-cc-organization", + }, + { + ClassificationID: "bk_network", + ClassificationName: "网络", + ClassificationType: "", + ClassificationIcon: "icon-cc-network-equipment", + }, + { + ClassificationIcon: "icon-cc-default", + ClassificationType: "inner", + ClassificationID: "bk_uncategorized", + ClassificationName: "未分类", + }, + { + ClassificationType: metadata.HiddenType, + ClassificationID: "bk_table_classification", + ClassificationName: "表格分类", + }, +} + +func AddObjClassificationData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameObjClassification) + if err := addObjClassificationDataTenant(kit, db, conf); err != nil { + blog.Errorf("add obj classification data failed, err: %v", err) + return err + } + + if err := addObjClassificationDataTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add obj classification data failed, err: %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameObjClassification) + return nil +} + +func addObjClassificationDataTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + + for _, classification := range objClassificationDataData { + cond := mapstr.MapStr{common.BKClassificationIDField: classification.ClassificationID} + result := make([]map[string]interface{}, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjClassification).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("get obj classification failed, err: %v", err) + return err + } + + if len(result) >= 1 { + blog.Errorf("duplicate classification id %s", classification.ClassificationID) + return fmt.Errorf("duplicate classification id %s", classification.ClassificationID) + } + + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameObjClassification) + if err != nil { + blog.Errorf("get next obj classification id failed, err: %v", err) + return err + } + classification.ID = int64(id) + classification.TenantID = kit.TenantID + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjClassification).Insert(kit.Ctx, + classification); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseApp) + return err + } + } + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objdes_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objdes_data.go new file mode 100644 index 0000000000..d107417187 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objdes_data.go @@ -0,0 +1,217 @@ +package data + +import ( + "fmt" + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func AddBizSetObjectRow(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameObjDes) + if err := addBizSetObjectRowTenant(kit, db, conf); err != nil { + blog.Errorf("add biz set object row failed, err: %v", err) + return err + } + + if err := addBizSetObjectRowTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add biz set object row failed, err: %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameObjDes) + return nil +} + +func addBizSetObjectRowTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + curTime := metadata.Time{Time: time.Now()} + + for _, row := range objectData { + sortNumber, err := getSortNum(kit, db, row) + if err != nil { + blog.Errorf("get sort number error %v", err) + return err + } + row.ObjSortNumber = sortNumber + row.TenantID = kit.TenantID + row.CreateTime = &curTime + row.LastTime = &curTime + + cond := mapstr.MapStr{common.BKObjIDField: row.ObjectID} + result := make([]ApplicationData, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjDes).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("get object failed, err: %v", err) + return err + } + if len(result) >= 1 { + blog.Errorf("duplicate obj id %s", row.ObjectID) + return fmt.Errorf("duplicate obj id %s", row.ObjectID) + } + + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameObjDes) + if err != nil { + blog.Errorf("get next object id failed, err: %v, table: %s", err, common.BKTableNameObjDes) + return err + } + row.ID = int64(id) + + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjDes).Insert(kit.Ctx, row); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseApp) + return err + } + } + return nil +} + +// getSortNum 获取模型排序字段 +func getSortNum(kit *rest.Kit, db dal.Dal, model *metadata.Object) (int64, error) { + // 查询当前分组下的模型信息 + + modelInput := map[string]interface{}{metadata.ModelFieldObjCls: model.ObjCls} + modelResult := make([]metadata.Object, 0) + sortCond := "-obj_sort_number" + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjDes).Find(modelInput).Sort(sortCond).Fields( + metadata.ModelFieldID, metadata.ModelFieldObjSortNumber).Limit(1).All(kit.Ctx, &modelResult); err != nil { + if !db.Shard(kit.ShardOpts()).IsNotFoundError(err) { + return 1, nil + } + blog.Errorf("get object sort number failed, err: %v", err) + return 0, err + } + if len(modelResult) <= 0 { + return 1, nil + } + + return modelResult[0].ObjSortNumber + 1, nil +} + +var objectData = []*metadata.Object{ + { + ObjCls: "bk_host_manage", + ObjectID: common.BKInnerObjIDHost, + ObjectName: "主机", + IsPre: true, + ObjIcon: "icon-cc-host", + Position: `{"bk_host_manage":{"x":-600,"y":-650}}`, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_biz_topo", + ObjectID: common.BKInnerObjIDModule, + ObjectName: "模块", + IsPre: true, + ObjIcon: "icon-cc-module", + Position: ``, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_biz_topo", + ObjectID: common.BKInnerObjIDSet, + ObjectName: "集群", + IsPre: true, + ObjIcon: "icon-cc-set", + Position: ``, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_organization", + ObjectID: common.BKInnerObjIDApp, + ObjectName: "业务", + IsPre: true, + ObjIcon: "icon-cc-business", + Position: `{"bk_organization":{"x":-100,"y":-100}}`, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_host_manage", + ObjectID: common.BKInnerObjIDProc, + ObjectName: "进程", + IsPre: true, + ObjIcon: "icon-cc-process", + Position: `{"bk_host_manage":{"x":-450,"y":-650}}`, + IsHidden: true, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_host_manage", + ObjectID: common.BKInnerObjIDPlat, + ObjectName: "云区域", + IsPre: true, + ObjIcon: "icon-cc-subnet", + Position: `{"bk_host_manage":{"x":-600,"y":-500}}`, + IsHidden: true, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_network", + ObjectID: common.BKInnerObjIDSwitch, + ObjectName: "交换机", + ObjIcon: "icon-cc-switch2", + Position: `{"bk_network":{"x":-200,"y":-50}}`, + IsPre: false, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_network", + ObjectID: common.BKInnerObjIDRouter, + ObjectName: "路由器", + ObjIcon: "icon-cc-router", + Position: `{"bk_network":{"x":-350,"y":-50}}`, + IsPre: false, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_network", + ObjectID: common.BKInnerObjIDBlance, + ObjectName: "负载均衡", + ObjIcon: "icon-cc-balance", + Position: `{"bk_network":{"x":-500,"y":-50}}`, + IsPre: false, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_network", + ObjectID: common.BKInnerObjIDFirewall, + ObjectName: "防火墙", + ObjIcon: "icon-cc-firewall", + Position: `{"bk_network":{"x":-650,"y":-50}}`, + IsPre: false, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_organization", + ObjectID: common.BKInnerObjIDBizSet, + ObjectName: "业务集", + ObjIcon: "icon-cc-business-set", + Position: ``, + IsPre: true, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, + { + ObjCls: "bk_organization", + ObjectID: common.BKInnerObjIDProject, + ObjectName: "项目", + ObjIcon: "icon-cc-project", + Position: ``, + IsPre: true, + Creator: common.CCSystemOperatorUserName, + IsPaused: false, + }, +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objectunique_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objectunique_data.go new file mode 100644 index 0000000000..6a0889d845 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_objectunique_data.go @@ -0,0 +1,234 @@ +package data + +import ( + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func generateUniqueKey(objID, propertyID string) string { + return objID + ":" + propertyID +} + +func getUniqueKeys(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) ([]*objectUnique, error) { + attrArr := make([]metadata.Attribute, 0) + err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjAttDes).Find(nil).All(kit.Ctx, &attrArr) + if err != nil { + blog.Errorf("get host unique fields failed, err: %v", err) + return nil, err + } + + attrIDMap := make(map[string]uint64) + for _, attr := range attrArr { + attrIDMap[generateUniqueKey(attr.ObjectID, attr.PropertyID)] = uint64(attr.ID) + } + + agentIDUnique := []*objectUnique{ + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_cloud_id")]}, + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_cloud_id")]}, + }, + ObjID: common.BKInnerObjIDHost, + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("biz", "bk_biz_name")]}, + }, + ObjID: "biz", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("set", "bk_biz_id")]}, + {Kind: "property", ID: attrIDMap[generateUniqueKey("set", "bk_set_name")]}, + {Kind: "property", ID: attrIDMap[generateUniqueKey("set", "bk_parent_id")]}, + }, + ObjID: "set", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("module", "bk_biz_id")]}, + {Kind: "property", ID: attrIDMap[generateUniqueKey("module", "bk_set_id")]}, + {Kind: "property", ID: attrIDMap[generateUniqueKey("module", "bk_module_name")]}, + }, + ObjID: "module", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("plat", "bk_cloud_name")]}, + }, + ObjID: "plat", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_host_outerip")]}, + }, + ObjID: "host", + IsPre: false, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_cloud_inst_id")]}, + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_cloud_vendor")]}, + }, + ObjID: "host", + IsPre: false, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("plat", "bk_vpc_id")]}, + }, + ObjID: "plat", + IsPre: false, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("bk_biz_set_obj", "bk_biz_set_id")]}, + }, + ObjID: "bk_biz_set_obj", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("bk_biz_set_name", "bk_biz_set_id")]}, + }, + ObjID: "bk_biz_set_name", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_host_innerip_v6")]}, + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_cloud_id")]}, + }, + ObjID: "host", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("bk_project", "bk_project_code")]}, + }, + ObjID: "bk_project", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("bk_project", "bk_project_id")]}, + }, + ObjID: "bk_project", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("bk_project", "bk_project_name")]}, + }, + ObjID: "bk_project", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("bk_project", "id")]}, + }, + ObjID: "bk_project", + IsPre: true, + LastTime: time.Now(), + }, + { + Keys: []uniqueKey{ + {Kind: "property", ID: attrIDMap[generateUniqueKey("host", "bk_agent_id")]}, + }, + ObjID: "host", + IsPre: true, + LastTime: time.Now(), + }, + } + return agentIDUnique, nil +} + +func AddObjectUniqueData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameObjUnique) + if err := addObjectUniqueDataTenant(kit, db, conf); err != nil { + blog.Errorf("add object unique data failed, err: %v", err) + return err + } + + if err := addObjectUniqueDataTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add object unique data failed, err: %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameObjUnique) + return nil +} + +func addObjectUniqueDataTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + + attrArr, err := getUniqueKeys(kit, db, conf) + if err != nil { + blog.Errorf("get unique keys failed, err: %v", err) + return err + } + count := 0 + for _, attr := range attrArr { + // get already exist host uniques + uniqueCond := map[string]interface{}{common.BKObjIDField: attr.ObjID} + existUniques := make([]objectUnique, 0) + err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjUnique).Find(uniqueCond).All(kit.Ctx, &existUniques) + if err != nil { + blog.Errorf("get host unique failed, filter: %+v, err: %v", uniqueCond, err) + return err + } + + newUniqueID, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameObjUnique) + if err != nil { + blog.Errorf("get next unique id failed, err: %v, table: %s", err, common.BKTableNameObjUnique) + return err + } + + attr.ID = newUniqueID + attr.TenantID = kit.TenantID + count++ + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameObjUnique).Insert(kit.Ctx, attr); err != nil { + blog.Errorf("insert host unique keys failed, unique: %+v, err: %v", attr, err) + return err + } + } + + return nil +} + +type objectUnique struct { + ID uint64 `bson:"id"` + ObjID string `bson:"bk_obj_id"` + Keys []uniqueKey `bson:"keys"` + IsPre bool `bson:"ispre"` + TenantID string `bson:"tenant_id"` + LastTime time.Time `bson:"last_time"` +} + +type uniqueKey struct { + Kind string `bson:"key_kind"` + ID uint64 `bson:"key_id"` +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_platbase_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_platbase_data.go new file mode 100644 index 0000000000..aeb30060a3 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_platbase_data.go @@ -0,0 +1,105 @@ +package data + +import ( + "fmt" + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +var cloudAreaData = []*metadata.CloudArea{ + { + CloudID: 0, + CloudName: "Default Area", + AccountID: 0, + Status: "1", + CreateTime: time.Now(), + LastTime: time.Now(), + Default: int64(common.BuiltIn), + }, + { + CloudID: common.UnassignedCloudAreaID, + CloudName: common.UnassignedCloudAreaName, + AccountID: 0, + CreateTime: time.Now(), + LastTime: time.Now(), + Default: int64(common.BuiltIn), + }, +} + +func AddUnassignedCloudArea(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameBasePlat) + if err := addUnassignedCloudAreaTenant(kit, db, conf); err != nil { + blog.Errorf("add unassigned cloud area failed, %v", err) + return err + } + + if err := addUnassignedCloudAreaTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add unassigned cloud area failed, %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNameBasePlat) + return nil +} + +func addUnassignedCloudAreaTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + for _, data := range cloudAreaData { + data.Creator = kit.User + data.LastEditor = kit.User + data.TenantID = kit.TenantID + + cond := mapstr.MapStr{ + common.BKDBAND: []mapstr.MapStr{ + {common.BKCloudIDField: mapstr.MapStr{common.BKDBGTE: common.ReservedCloudAreaStartID}}, + {common.BKCloudIDField: mapstr.MapStr{common.BKDBLTE: common.ReservedCloudAreaEndID}}, + {common.BKCloudIDField: mapstr.MapStr{common.BKDBNIN: common.ReservedCloudAreaIDs}}, + }, + } + + count, err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBasePlat).Find(cond).Count(kit.Ctx) + if err != nil { + blog.Errorf("count cloud area failed, err: %v, cond: %+v", err, cond) + return err + } + if count > 0 { + blog.Errorf("reserved cloud area data exists in db, range: [%d:%d]", common.ReservedCloudAreaStartID, + common.ReservedCloudAreaEndID) + return fmt.Errorf("reserved cloud area data exists in db, range: [%d:%d]", common.ReservedCloudAreaStartID, + common.ReservedCloudAreaEndID) + } + + cond = mapstr.MapStr{common.BKCloudIDField: data.CloudID} + result := make([]metadata.CloudArea, 0) + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameBasePlat).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("find cloud area failed, cond: %+v, err: %v", cond, err) + return err + } + + if len(result) >= 1 { + blog.Errorf("multiple cloud area have been found, cond: %+v, count: %d", cond, len(result)) + return fmt.Errorf("multiple cloud area have been found, cond: %+v, count: %d", cond, len(result)) + } + if data.CloudName != common.UnassignedCloudAreaName { + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameBasePlat) + if err != nil { + blog.Errorf("get next unassigned cloud id failed, err: %v", err) + return err + } + data.CloudID = int64(id) + } + + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameBasePlat).Insert(kit.Ctx, data); err != nil { + blog.Errorf("insert unassigned cloud area failed, data: %+v, err: %v", data, err) + return err + } + } + + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_propertygroup_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_propertygroup_data.go new file mode 100644 index 0000000000..5d6e96e752 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_propertygroup_data.go @@ -0,0 +1,245 @@ +package data + +import ( + "fmt" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/metadata" + mCommon "configcenter/src/scene_server/admin_server/common" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func AddPropertyGroupData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNamePropertyGroup) + if err := addPropertyGroupDataTenant(kit, db, conf); err != nil { + blog.Errorf("add property group data failed, err: %v", err) + return err + } + + if err := addPropertyGroupDataTenant(upgrader.GetBlueKingKit(), db, conf); err != nil { + blog.Errorf("add property group data failed, err: %v", err) + return err + } + blog.Infof("end add init data for table: %s", common.BKTableNamePropertyGroup) + return nil +} + +func addPropertyGroupDataTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + + for _, row := range dataRows { + row.TenantID = kit.TenantID + groupIndex, err := getPropertyGroupLastIndex(kit, db, conf, row) + if err != nil { + blog.Errorf("get property group last index failed, err: %v") + return err + } + row.GroupIndex = groupIndex + 1 + + cond := map[string]interface{}{common.BKObjIDField: row.ObjectID, common.BKAppIDField: row.BizID, + common.BKPropertyGroupIndexField: row.GroupIndex} + + result := make([]map[string]interface{}, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNamePropertyGroup).Find(cond).All(kit.Ctx, + &result); err != nil { + blog.Errorf("get property group failed, err: %v", err) + return err + } + if len(result) >= 1 { + blog.Errorf("duplicate insert property group %+v, tableName: %s", cond, common.BKTableNamePropertyGroup) + return fmt.Errorf("duplicate insert property group %+v, tableName: %s", cond, + common.BKTableNamePropertyGroup) + } + + id, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNamePropertyGroup) + if err != nil { + blog.Errorf("get next property group id failed, err: %v, table: %s ", err, common.BKTableNamePropertyGroup) + return err + } + row.ID = int64(id) + + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNamePropertyGroup).Insert(kit.Ctx, row); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseApp) + return err + } + } + return nil +} + +var dataRows = []*metadata.Group{ + { + ObjectID: common.BKInnerObjIDApp, + GroupID: mCommon.BaseInfo, + GroupName: mCommon.BaseInfoName, + IsDefault: true, + IsPre: false, + BizID: 0, + IsCollapse: false, + }, + { + ObjectID: common.BKInnerObjIDApp, + GroupID: mCommon.AppRole, + GroupName: mCommon.AppRoleName, + IsDefault: true, + IsPre: false, + BizID: 0, + IsCollapse: false, + }, + { + ObjectID: common.BKInnerObjIDSet, + GroupID: mCommon.BaseInfo, + GroupName: mCommon.BaseInfoName, + IsDefault: true, + IsCollapse: false, + BizID: 0, + IsPre: false, + }, + { + ObjectID: common.BKInnerObjIDModule, + GroupID: mCommon.BaseInfo, + GroupName: mCommon.BaseInfoName, + IsDefault: true, + IsPre: false, + BizID: 0, + IsCollapse: false, + }, + { + ObjectID: common.BKInnerObjIDHost, + GroupID: mCommon.BaseInfo, + GroupName: mCommon.BaseInfoName, + IsDefault: true, + BizID: 0, + IsPre: false, + IsCollapse: false, + }, + { + ObjectID: common.BKInnerObjIDHost, + GroupID: mCommon.HostAutoFields, + GroupName: "主机系统配置", + IsDefault: true, + BizID: 0, + IsPre: false, + IsCollapse: false, + }, + { + ObjectID: common.BKInnerObjIDProc, + GroupID: mCommon.BaseInfo, + GroupName: mCommon.BaseInfoName, + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, + { + ObjectID: common.BKInnerObjIDProc, + GroupID: mCommon.ProcPort, + GroupName: mCommon.ProcPortName, + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, + { + ObjectID: common.BKInnerObjIDProc, + GroupID: mCommon.ProcGsekitBaseInfo, + GroupName: mCommon.ProcGsekitBaseInfoName, + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, + { + ObjectID: common.BKInnerObjIDProc, + GroupID: mCommon.ProcGsekitManageInfo, + GroupName: mCommon.ProcGsekitManageInfoName, + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, + { + ObjectID: common.BKInnerObjIDPlat, + GroupID: mCommon.BaseInfo, + GroupName: mCommon.BaseInfoName, + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, + { + ObjectID: "process", + GroupID: "network_proxy", + GroupName: "外网代理信息", + IsDefault: true, + BizID: 0, + IsPre: true, + IsCollapse: true, + }, + { + ObjectID: common.BKInnerObjIDProc, + GroupID: "proc_mgr", + GroupName: "进程管理信息", + IsDefault: true, + IsPre: false, + IsCollapse: true, + BizID: 0, + }, + { + ObjectID: common.BKInnerObjIDBizSet, + GroupID: "default", + GroupName: "基础信息", + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, + { + ObjectID: common.BKInnerObjIDBizSet, + GroupID: "default", + GroupName: "角色", + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, + { + ObjectID: common.BKInnerObjIDProject, + GroupID: "default", + GroupName: "基础信息", + IsDefault: true, + IsPre: false, + IsCollapse: false, + BizID: 0, + }, +} + +func getPropertyGroupLastIndex(kit *rest.Kit, db dal.Dal, conf *upgrader.Config, group *metadata.Group) (int64, + error) { + + opt := make(map[string]interface{}) + opt[common.BKObjIDField] = group.ObjectID + + count, err := db.Shard(kit.ShardOpts()).Table(common.BKTableNamePropertyGroup).Find(opt).Count(kit.Ctx) + if err != nil { + blog.Error("count property group failed, error info is %v", err) + return 0, err + } + if count <= 0 { + return 0, nil + } + + groups := make([]metadata.Group, 0) + sortCond := "-bk_group_index" + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNamePropertyGroup).Find(opt).Sort(sortCond).Limit(1).All(kit.Ctx, + &groups); err != nil { + blog.Error("get property group failed, err: %v", err) + return 0, err + } + + if len(groups) <= 0 { + return 0, nil + } + return groups[0].GroupIndex, nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_servicecategory_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_servicecategory_data.go new file mode 100644 index 0000000000..f9147f0876 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_servicecategory_data.go @@ -0,0 +1,204 @@ +package data + +import ( + "fmt" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/common/metadata" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +type serviceCategory struct { + Name string `field:"name" json:"name,omitempty" bson:"name"` + ParentName string `field:"bk_parent_id" json:"bk_parent_id,omitempty" bson:"bk_parent_id"` +} + +var innerCategories = []*serviceCategory{ + { + Name: "数据库", + ParentName: "", + }, + { + Name: "Mysql", + ParentName: "数据库", + }, + { + Name: "Redis", + ParentName: "数据库", + }, + { + Name: "Oracle", + ParentName: "数据库", + }, + { + Name: "SQLServer", + ParentName: "数据库", + }, + { + Name: "MongoDB", + ParentName: "数据库", + }, + { + Name: "Etcd", + ParentName: "数据库", + }, + { + Name: "Zookeeper", + ParentName: "数据库", + }, + { + Name: "消息队列", + ParentName: "", + }, + { + Name: "Kafka", + ParentName: "消息队列", + }, + { + Name: "RabbitMQ", + ParentName: "消息队列", + }, + { + Name: "HTTP 服务", + ParentName: "", + }, + { + Name: "Nginx", + ParentName: "HTTP 服务", + }, + { + Name: "Apache", + ParentName: "HTTP 服务", + }, + { + Name: "Tomcat", + ParentName: "HTTP 服务", + }, + { + Name: "存储", + ParentName: "", + }, + { + Name: "Ceph", + ParentName: "存储", + }, + { + Name: "NFS", + ParentName: "存储", + }, + { + Name: "Default", + ParentName: "", + }, + { + Name: "Default", + ParentName: "Default", + }, +} + +func AddServiceCategotyData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameServiceCategory) + err := addServiceCategotyDataTenant(kit, db, conf) + if err != nil { + return fmt.Errorf("failed add service category data, err: %v, rid: %s", err, kit.Rid) + } + + err = addServiceCategotyDataTenant(upgrader.GetBlueKingKit(), db, conf) + if err != nil { + return fmt.Errorf("failed add service category data, err: %v, rid: %s", err, kit.Rid) + } + blog.Infof("start add init data for table: %s", common.BKTableNameServiceCategory) + return nil +} + +func addServiceCategotyDataTenant(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + exist := false + categoryIDMap := map[string]int64{} + for _, category := range innerCategories { + parentID := int64(0) + if len(category.ParentName) > 0 { + parentID, exist = categoryIDMap[category.ParentName] + if !exist { + return fmt.Errorf("parent [%s] not found", category.ParentName) + } + } + categoryID, err := getOrCreateCategory(kit, db, category.Name, parentID) + if err != nil { + return fmt.Errorf("get or create category failed, err: %v", err) + } + categoryIDMap[category.Name] = categoryID + } + + return nil +} + +func getOrCreateCategory(kit *rest.Kit, db dal.Dal, name string, parentID int64) (int64, error) { + category := ServiceCategory{} + filter := map[string]interface{}{ + common.MetadataLabelBiz: mapstr.MapStr{common.BKDBExists: false}, + common.BKFieldName: name, + common.BKParentIDField: parentID, + } + err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameServiceCategory).Find(filter).One(kit.Ctx, &category) + + if err != nil { + if !db.Shard(kit.ShardOpts()).IsNotFoundError(err) { + blog.Errorf("find service category failed, filter: %+v, err: %v", filter, err) + return 0, err + } + + categoryID, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameServiceCategory) + if err != nil { + return 0, fmt.Errorf("get next category id failed, err: %v, table: %s", err, + common.BKTableNameServiceCategory) + } + + rootID := int64(0) + if parentID != 0 { + parentCategory := &metadata.ServiceCategory{} + parentFilter := map[string]interface{}{ + common.BKFieldID: parentID, + } + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameServiceCategory).Find(parentFilter).One(kit.Ctx, + parentCategory); err != nil { + return 0, fmt.Errorf("get parent category %d failed, err: %v", parentID, err) + } + rootID = parentCategory.RootID + if rootID == 0 { + rootID = parentCategory.ID + } + } + if rootID == 0 { + rootID = int64(categoryID) + } + + category = ServiceCategory{ + ID: int64(categoryID), + Name: name, + RootID: rootID, + ParentID: parentID, + TenantID: common.BKDefaultTenantID, + IsBuiltIn: true, + BizID: 0, + } + err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameServiceCategory).Insert(kit.Ctx, category) + if err != nil { + return 0, fmt.Errorf("insert service category failed, category: %+v, err: %v", category, err) + } + } + return category.ID, nil +} + +type ServiceCategory struct { + ID int64 `field:"id" json:"id,omitempty" bson:"id"` + Name string `field:"name" json:"name,omitempty" bson:"name"` + RootID int64 `field:"bk_root_id" json:"bk_root_id,omitempty" bson:"bk_root_id"` + ParentID int64 `field:"bk_parent_id" json:"bk_parent_id,omitempty" bson:"bk_parent_id"` + TenantID string `field:"tenant_id" json:"tenant_id,omitempty" bson:"tenant_id"` + IsBuiltIn bool `field:"is_built_in" json:"is_built_in" bson:"is_built_in"` + BizID int64 `field:"bk_biz_id" json:"bk_biz_id" bson:"bk_biz_id"` +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_setbase_data.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_setbase_data.go new file mode 100644 index 0000000000..eb457ab87f --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_setbase_data.go @@ -0,0 +1,57 @@ +package data + +import ( + "fmt" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/common/mapstr" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func addSetBaseData(kit *rest.Kit, db dal.Dal, bizID int64, conf *upgrader.Config) (uint64, + error) { + + data := map[string]interface{}{ + common.BKAppIDField: bizID, + common.BKInstParentStr: bizID, + common.BKSetNameField: common.DefaultResSetName, + common.BKDefaultField: common.DefaultResSetFlag, + common.TenantID: kit.TenantID, + common.BKSetEnvField: "3", + common.BKSetStatusField: "1", + common.BKSetTemplateIDField: 0, + common.BKDescriptionField: "", + } + + cond := mapstr.MapStr{ + common.BKAppIDField: data[common.BKAppIDField], + common.BKSetNameField: data[common.BKSetNameField], + common.BKParentIDField: data[common.BKParentIDField], + } + result := make([]map[string]interface{}, 0) + if err := db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseSet).Find(cond).All(kit.Ctx, &result); err != nil { + blog.Errorf("get set data failed, err: %v", err) + return 0, err + } + + if len(result) >= 1 { + blog.Errorf("set is exit, table: %s, cond: %v", common.BKTableNameBaseSet, cond) + return 0, fmt.Errorf("set is exit, table: %s", common.BKTableNameBaseSet) + } + + ID, err := db.Shard(kit.SysShardOpts()).NextSequence(kit.Ctx, common.BKTableNameBaseSet) + if err != nil { + blog.Errorf("failed to get next sequence, err: %v, tableName: %s", err, common.BKTableNameBaseSet) + return 0, err + } + data[common.BKSetIDField] = ID + + if err = db.Shard(kit.ShardOpts()).Table(common.BKTableNameBaseSet).Insert(kit.Ctx, data); err != nil { + blog.Errorf("failed to insert data, err: %v, table: %s", err, common.BKTableNameBaseSet) + return 0, err + } + return ID, nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_systemdata.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_systemdata.go new file mode 100644 index 0000000000..d891544f28 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/add_systemdata.go @@ -0,0 +1,70 @@ +package data + +import ( + "fmt" + "time" + + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func AddSystemData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + blog.Infof("start add init data for table: %s", common.BKTableNameSystem) + + tableName := common.BKTableNameSystem + data := map[string]interface{}{common.HostCrossBizField: common.HostCrossBizValue} + isExist, err := db.Shard(kit.SysShardOpts()).Table(tableName).Find(data).Count(kit.Ctx) + if err != nil { + blog.Errorf("get system data failed, err: %v", err) + return err + } + if isExist > 0 { + blog.Errorf("system info exit, table: %s", tableName) + return fmt.Errorf("system info exit, table: %s", tableName) + } + + err = db.Shard(kit.SysShardOpts()).Table(tableName).Insert(kit.Ctx, data) + if nil != err { + blog.Errorf("add data for %s table, error: %v", tableName, err) + return err + } + if err := initConfigAdmin(kit, db, conf); err != nil { + blog.Errorf("update config admin failed, error: %v", err) + return err + } + + blog.Infof("end add init data for table: %s", common.BKTableNameSystem) + return nil +} + +func initConfigAdmin(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + cond := map[string]interface{}{ + "_id": common.ConfigAdminID, + } + + cnt, err := db.Shard(kit.SysShardOpts()).Table(common.BKTableNameSystem).Find(cond).Count(kit.Ctx) + if err != nil { + blog.Errorf("find config admin failed, find err: %v, cond: %v", err, cond) + return err + } + + if cnt == 0 { + doc := map[string]interface{}{ + common.BKFieldDBID: common.ConfigAdminID, + common.CreateTimeField: time.Now(), + common.LastTimeField: time.Now(), + common.ConfigAdminValueField: initConfig, + } + if err := db.Shard(kit.SysShardOpts()).Table(common.BKTableNameSystem).Insert(kit.Ctx, doc); err != nil { + blog.Errorf("insert system data failed, err: %v, doc: %+v", err, doc) + return err + } + } + return nil + +} + +var initConfig = "{\"backend\":{\"max_biz_topo_level\":7,\"snapshot_biz_id\":2},\"validation_rules\":{\"number\":{\"value\":\"XihcLXxcKyk/XGQrJA==\",\"description\":\"字段类型“数字”的验证规则\",\"i18n\":{\"cn\":\"请输入整数数字\",\"en\":\"Please enter integer number\"}},\"float\":{\"value\":\"XlsrLV0/KFswLTldKlsuXT9bMC05XSt8WzAtOV0rWy5dP1swLTldKikoW2VFXVsrLV0/WzAtOV0rKT8k\",\"description\":\"字段类型“浮点”的验证规则\",\"i18n\":{\"cn\":\"请输入浮点型数字\",\"en\":\"Please enter float data\"}},\"singlechar\":{\"value\":\"XFMq\",\"description\":\"字段类型“短字符”的验证规则\",\"i18n\":{\"cn\":\"请输入256长度以内的字符串\",\"en\":\"Please enter the string within 256 length\"}},\"longchar\":{\"value\":\"XFMq\",\"description\":\"字段类型“长字符”的验证规则\",\"i18n\":{\"cn\":\"请输入2000长度以内的字符串\",\"en\":\"Please enter the string within 2000 length\"}},\"associationId\":{\"value\":\"XlthLXpBLVpdW1x3XSok\",\"description\":\"关联类型唯一标识验证规则\",\"i18n\":{\"cn\":\"由英文字符开头,和下划线、数字或英文组合的字符\",\"en\":\"Start with lowercase or uppercase letter, followed by lowercase / uppercase / underscore / numbers characters\"}},\"classifyId\":{\"value\":\"XlthLXpBLVpdW1x3XSok\",\"description\":\"模型分组唯一标识验证规则\",\"i18n\":{\"cn\":\"由英文字符开头,和下划线、数字或英文组合的字符\",\"en\":\"Start with lowercase or uppercase letter, followed by lowercase / uppercase / underscore / numbers characters\"}},\"modelId\":{\"value\":\"XlthLXpBLVpdW1x3XSok\",\"description\":\"模型唯一标识验证规则\",\"i18n\":{\"cn\":\"由英文字符开头,和下划线、数字或英文组合的字符\",\"en\":\"Start with lowercase or uppercase letter, followed by lowercase / uppercase / underscore / numbers characters\"}},\"enumId\":{\"value\":\"XlthLXpBLVowLTlfLV0qJA==\",\"description\":\"字段类型“枚举”ID的验证规则\",\"i18n\":{\"cn\":\"由大小写英文字母,数字,_ 或 - 组成的字符\",\"en\":\"Composed of uppercase / lowercase / numbers / - or _ characters\"}},\"enumName\":{\"value\":\"XihbYS16QS1aMC05X118W1x1NGUwMC1cdTlmYTVdfFsoKSst44CK44CLLO+8jO+8mzvigJzigJ3igJjigJnjgIJcLlwiXCcgXC86XSkqJA==\",\"description\":\"字段类型“枚举”值的验证规则\",\"i18n\":{\"cn\":\"请输入枚举值\",\"en\":\"Please enter the enum value\"}},\"fieldId\":{\"value\":\"XlthLXpBLVpdW1x3XSok\",\"description\":\"模型字段唯一标识的验证规则\",\"i18n\":{\"cn\":\"由英文字符开头,和下划线、数字或英文组合的字符\",\"en\":\"Start with lowercase or uppercase letter, followed by lowercase / uppercase / underscore / numbers characters\"}},\"namedCharacter\":{\"value\":\"XlthLXpBLVowLTlcdTRlMDAtXHU5ZmE1X1wtOlwoXCldKyQ=\",\"description\":\"服务分类名称的验证规则\",\"i18n\":{\"cn\":\"请输入中英文或特殊字符 :_- 组成的名称\",\"en\":\"Special symbols only support(:_-)\"}},\"instanceTagKey\":{\"value\":\"XlthLXpBLVpdKFthLXowLTlBLVpcLV8uXSpbYS16MC05QS1aXSk/JA==\",\"description\":\"服务实例标签键的验证规则\",\"i18n\":{\"cn\":\"请输入以英文开头的英文+数字组合\",\"en\":\"Please enter letter / number starts with letter\"}},\"instanceTagValue\":{\"value\":\"XlthLXowLTlBLVpdKFthLXowLTlBLVpcLV8uXSpbYS16MC05QS1aXSk/JA==\",\"description\":\"服务实例标签值的验证规则\",\"i18n\":{\"cn\":\"请输入英文 / 数字\",\"en\":\"Please enter letter / number\"}},\"businessTopoInstNames\":{\"value\":\"XlteXCNcLyxcPlw8XHxdKyQ=\",\"description\":\"集群/模块/实例名称的验证规则\",\"i18n\":{\"cn\":\"请输入除 #/,\\u003e\\u003c| 以外的字符\",\"en\":\"Please enter characters other than #/,\\u003e\\u003c|\"}}},\"set\":\"空闲机池\",\"idle_pool\":{\"idle\":\"空闲机\",\"fault\":\"故障机\",\"recycle\":\"待回收\",\"user_modules\":null},\"id_generator\":{\"enabled\":false,\"step\":1}}" diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/objAttDescData.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/objAttDescData.go new file mode 100644 index 0000000000..0e1fb3e9b6 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/data/objAttDescData.go @@ -0,0 +1,4268 @@ +package data + +import "configcenter/src/common/metadata" + +var ( + falseVar = false + trueVar = true + objAttrData = []*metadata.Attribute{} +) + +var provincesEnum = []metadata.EnumVal{ + { + ID: "110000", + Name: "北京市", + Type: "text", + IsDefault: false, + }, + { + ID: "120000", + Name: "天津市", + Type: "text", + IsDefault: false, + }, + { + ID: "130000", + Name: "河北省", + Type: "text", + IsDefault: false, + }, + { + ID: "140000", + Name: "山西省", + Type: "text", + IsDefault: false, + }, + { + ID: "150000", + Name: "内蒙古自治区", + Type: "text", + IsDefault: false, + }, + { + ID: "210000", + Name: "辽宁省", + Type: "text", + IsDefault: false, + }, + { + ID: "220000", + Name: "吉林省", + Type: "text", + IsDefault: false, + }, + { + ID: "230000", + Name: "黑龙江省", + Type: "text", + IsDefault: false, + }, + { + ID: "310000", + Name: "上海市", + Type: "text", + IsDefault: false, + }, + { + ID: "320000", + Name: "江苏省", + Type: "text", + IsDefault: false, + }, + { + ID: "330000", + Name: "浙江省", + Type: "text", + IsDefault: false, + }, + { + ID: "340000", + Name: "安徽省", + Type: "text", + IsDefault: false, + }, + { + ID: "350000", + Name: "福建省", + Type: "text", + IsDefault: false, + }, + { + ID: "360000", + Name: "江西省", + Type: "text", + IsDefault: false, + }, + { + ID: "370000", + Name: "山东省", + Type: "text", + IsDefault: false, + }, + { + ID: "410000", + Name: "河南省", + Type: "text", + IsDefault: false, + }, + { + ID: "420000", + Name: "湖北省", + Type: "text", + IsDefault: false, + }, + { + ID: "430000", + Name: "湖南省", + Type: "text", + IsDefault: false, + }, + { + ID: "440000", + Name: "广东省", + Type: "text", + IsDefault: false, + }, + { + ID: "450000", + Name: "广西壮族自治区", + Type: "text", + IsDefault: false, + }, + { + ID: "460000", + Name: "海南省", + Type: "text", + IsDefault: false, + }, + { + ID: "500000", + Name: "重庆市", + Type: "text", + IsDefault: false, + }, + { + ID: "510000", + Name: "四川省", + Type: "text", + IsDefault: false, + }, + { + ID: "520000", + Name: "贵州省", + Type: "text", + IsDefault: false, + }, + { + ID: "530000", + Name: "云南省", + Type: "text", + IsDefault: false, + }, + { + ID: "540000", + Name: "西藏自治区", + Type: "text", + IsDefault: false, + }, + { + ID: "610000", + Name: "陕西省", + Type: "text", + IsDefault: false, + }, + { + ID: "620000", + Name: "甘肃省", + Type: "text", + IsDefault: false, + }, + { + ID: "630000", + Name: "青海省", + Type: "text", + IsDefault: false, + }, + { + ID: "640000", + Name: "宁夏回族自治区", + Type: "text", + IsDefault: false, + }, + { + ID: "650000", + Name: "新疆维吾尔自治区", + Type: "text", + IsDefault: false, + }, + { + ID: "710000", + Name: "台湾省", + Type: "text", + IsDefault: false, + }, + { + ID: "810000", + Name: "香港特别行政区", + Type: "text", + IsDefault: false, + }, + { + ID: "820000", + Name: "澳门特别行政区", + Type: "text", + IsDefault: false, + }, +} + +var countryEnum = []metadata.EnumVal{ + + { + ID: "AR", + Name: "阿根廷", + Type: "text", + IsDefault: false, + }, + { + ID: "AD", + Name: "安道尔", + Type: "text", + IsDefault: false, + }, + { + ID: "AE", + Name: "阿联酋", + Type: "text", + IsDefault: false, + }, + { + ID: "AF", + Name: "阿富汗", + Type: "text", + IsDefault: false, + }, + { + ID: "AG", + Name: "安提瓜和巴布达", + Type: "text", + IsDefault: false, + }, + { + ID: "AI", + Name: "安圭拉", + Type: "text", + IsDefault: false, + }, + { + ID: "AL", + Name: "阿尔巴尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "AM", + Name: "亚美尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "AO", + Name: "安哥拉", + Type: "text", + IsDefault: false, + }, + { + ID: "AQ", + Name: "南极洲", + Type: "text", + IsDefault: false, + }, + { + ID: "AS", + Name: "美属萨摩亚", + Type: "text", + IsDefault: false, + }, + { + ID: "AT", + Name: "奥地利", + Type: "text", + IsDefault: false, + }, + { + ID: "AU", + Name: "澳大利亚", + Type: "text", + IsDefault: false, + }, + { + ID: "AW", + Name: "阿鲁巴", + Type: "text", + IsDefault: false, + }, + { + ID: "AX", + Name: "奥兰群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "AZ", + Name: "阿塞拜疆", + Type: "text", + IsDefault: false, + }, + { + ID: "BA", + Name: "波黑", + Type: "text", + IsDefault: false, + }, + { + ID: "BB", + Name: "巴巴多斯", + Type: "text", + IsDefault: false, + }, + { + ID: "BD", + Name: "孟加拉", + Type: "text", + IsDefault: false, + }, + { + ID: "BE", + Name: "比利时", + Type: "text", + IsDefault: false, + }, + { + ID: "BF", + Name: "布基纳法索", + Type: "text", + IsDefault: false, + }, + { + ID: "BG", + Name: "保加利亚", + Type: "text", + IsDefault: false, + }, + { + ID: "BH", + Name: "巴林", + Type: "text", + IsDefault: false, + }, + { + ID: "BI", + Name: "布隆迪", + Type: "text", + IsDefault: false, + }, + { + ID: "BJ", + Name: "贝宁", + Type: "text", + IsDefault: false, + }, + { + ID: "BL", + Name: "圣巴泰勒米岛", + Type: "text", + IsDefault: false, + }, + { + ID: "BM", + Name: "百慕大", + Type: "text", + IsDefault: false, + }, + { + ID: "BN", + Name: "文莱", + Type: "text", + IsDefault: false, + }, + { + ID: "BO", + Name: "玻利维亚", + Type: "text", + IsDefault: false, + }, + { + ID: "BQ", + Name: "荷兰加勒比区", + Type: "text", + IsDefault: false, + }, + { + ID: "BR", + Name: "巴西", + Type: "text", + IsDefault: false, + }, + { + ID: "BS", + Name: "巴哈马", + Type: "text", + IsDefault: false, + }, + { + ID: "BT", + Name: "不丹", + Type: "text", + IsDefault: false, + }, + { + ID: "BV", + Name: "布韦岛", + Type: "text", + IsDefault: false, + }, + { + ID: "BW", + Name: "博茨瓦纳", + Type: "text", + IsDefault: false, + }, + { + ID: "BY", + Name: "白俄罗斯", + Type: "text", + IsDefault: false, + }, + { + ID: "BZ", + Name: "伯利兹", + Type: "text", + IsDefault: false, + }, + { + ID: "CA", + Name: "加拿大", + Type: "text", + IsDefault: false, + }, + { + ID: "CC", + Name: "科科斯群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "CD", + Name: "刚果(金)", + Type: "text", + IsDefault: false, + }, + { + ID: "CF", + Name: "中非", + Type: "text", + IsDefault: false, + }, + { + ID: "CG", + Name: "刚果(布)", + Type: "text", + IsDefault: false, + }, + { + ID: "CH", + Name: "瑞士", + Type: "text", + IsDefault: false, + }, + { + ID: "CI", + Name: "科特迪瓦", + Type: "text", + IsDefault: false, + }, + { + ID: "CK", + Name: "库克群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "CL", + Name: "智利", + Type: "text", + IsDefault: false, + }, + { + ID: "CM", + Name: "喀麦隆", + Type: "text", + IsDefault: false, + }, + { + ID: "CN", + Name: "中国", + Type: "text", + IsDefault: false, + }, + { + ID: "CO", + Name: "哥伦比亚", + Type: "text", + IsDefault: false, + }, + { + ID: "CR", + Name: "哥斯达黎加", + Type: "text", + IsDefault: false, + }, + { + ID: "CU", + Name: "古巴", + Type: "text", + IsDefault: false, + }, + { + ID: "CV", + Name: "佛得角", + Type: "text", + IsDefault: false, + }, + { + ID: "CW", + Name: "库拉索", + Type: "text", + IsDefault: false, + }, + { + ID: "CX", + Name: "圣诞岛", + Type: "text", + IsDefault: false, + }, + { + ID: "CY", + Name: "塞浦路斯", + Type: "text", + IsDefault: false, + }, + { + ID: "CZ", + Name: "捷克", + Type: "text", + IsDefault: false, + }, + { + ID: "DE", + Name: "德国", + Type: "text", + IsDefault: false, + }, + { + ID: "DJ", + Name: "吉布提", + Type: "text", + IsDefault: false, + }, + { + ID: "DK", + Name: "丹麦", + Type: "text", + IsDefault: false, + }, + { + ID: "DM", + Name: "多米尼克", + Type: "text", + IsDefault: false, + }, + { + ID: "DO", + Name: "多米尼加", + Type: "text", + IsDefault: false, + }, + { + ID: "DZ", + Name: "阿尔及利亚", + Type: "text", + IsDefault: false, + }, + { + ID: "EC", + Name: "厄瓜多尔", + Type: "text", + IsDefault: false, + }, + { + ID: "EE", + Name: "爱沙尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "EG", + Name: "埃及", + Type: "text", + IsDefault: false, + }, + { + ID: "EH", + Name: "西撒哈拉", + Type: "text", + IsDefault: false, + }, + { + ID: "ER", + Name: "厄立特里亚", + Type: "text", + IsDefault: false, + }, + { + ID: "ES", + Name: "西班牙", + Type: "text", + IsDefault: false, + }, + { + ID: "ET", + Name: "埃塞俄比亚", + Type: "text", + IsDefault: false, + }, + { + ID: "FI", + Name: "芬兰", + Type: "text", + IsDefault: false, + }, + { + ID: "FJ", + Name: "斐济群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "FK", + Name: "马尔维纳斯群岛(福克兰)", + Type: "text", + IsDefault: false, + }, + { + ID: "FM", + Name: "密克罗尼西亚联邦", + Type: "text", + IsDefault: false, + }, + { + ID: "FO", + Name: "法罗群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "FR", + Name: "法国", + Type: "text", + IsDefault: false, + }, + { + ID: "GA", + Name: "加蓬", + Type: "text", + IsDefault: false, + }, + { + ID: "GB", + Name: "英国", + Type: "text", + IsDefault: false, + }, + { + ID: "GD", + Name: "格林纳达", + Type: "text", + IsDefault: false, + }, + { + ID: "GE", + Name: "格鲁吉亚", + Type: "text", + IsDefault: false, + }, + { + ID: "GF", + Name: "法属圭亚那", + Type: "text", + IsDefault: false, + }, + { + ID: "GG", + Name: "根西岛", + Type: "text", + IsDefault: false, + }, + { + ID: "GH", + Name: "加纳", + Type: "text", + IsDefault: false, + }, + { + ID: "GI", + Name: "直布罗陀", + Type: "text", + IsDefault: false, + }, + { + ID: "GL", + Name: "格陵兰", + Type: "text", + IsDefault: false, + }, + { + ID: "GM", + Name: "冈比亚", + Type: "text", + IsDefault: false, + }, + { + ID: "GN", + Name: "几内亚", + Type: "text", + IsDefault: false, + }, + { + ID: "GP", + Name: "瓜德罗普", + Type: "text", + IsDefault: false, + }, + { + ID: "GQ", + Name: "赤道几内亚", + Type: "text", + IsDefault: false, + }, + { + ID: "GR", + Name: "希腊", + Type: "text", + IsDefault: false, + }, + { + ID: "GS", + Name: "南乔治亚岛和南桑威奇群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "GT", + Name: "危地马拉", + Type: "text", + IsDefault: false, + }, + { + ID: "GU", + Name: "关岛", + Type: "text", + IsDefault: false, + }, + { + ID: "GW", + Name: "几内亚比绍", + Type: "text", + IsDefault: false, + }, + { + ID: "GY", + Name: "圭亚那", + Type: "text", + IsDefault: false, + }, + { + ID: "HM", + Name: "赫德岛和麦克唐纳群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "HN", + Name: "洪都拉斯", + Type: "text", + IsDefault: false, + }, + { + ID: "HR", + Name: "克罗地亚", + Type: "text", + IsDefault: false, + }, + { + ID: "HT", + Name: "海地", + Type: "text", + IsDefault: false, + }, + { + ID: "HU", + Name: "匈牙利", + Type: "text", + IsDefault: false, + }, + { + ID: "ID", + Name: "印尼", + Type: "text", + IsDefault: false, + }, + { + ID: "IE", + Name: "爱尔兰", + Type: "text", + IsDefault: false, + }, + { + ID: "IL", + Name: "以色列", + Type: "text", + IsDefault: false, + }, + { + ID: "IM", + Name: "马恩岛", + Type: "text", + IsDefault: false, + }, + { + ID: "IN", + Name: "印度", + Type: "text", + IsDefault: false, + }, + { + ID: "IO", + Name: "英属印度洋领地", + Type: "text", + IsDefault: false, + }, + { + ID: "IQ", + Name: "伊拉克", + Type: "text", + IsDefault: false, + }, + { + ID: "IR", + Name: "伊朗", + Type: "text", + IsDefault: false, + }, + { + ID: "IS", + Name: "冰岛", + Type: "text", + IsDefault: false, + }, + { + ID: "IT", + Name: "意大利", + Type: "text", + IsDefault: false, + }, + { + ID: "JE", + Name: "泽西岛", + Type: "text", + IsDefault: false, + }, + { + ID: "JM", + Name: "牙买加", + Type: "text", + IsDefault: false, + }, + { + ID: "JO", + Name: "约旦", + Type: "text", + IsDefault: false, + }, + { + ID: "JP", + Name: "日本", + Type: "text", + IsDefault: false, + }, + { + ID: "KE", + Name: "肯尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "KG", + Name: "吉尔吉斯斯坦", + Type: "text", + IsDefault: false, + }, + { + ID: "KH", + Name: "柬埔寨", + Type: "text", + IsDefault: false, + }, + { + ID: "KI", + Name: "基里巴斯", + Type: "text", + IsDefault: false, + }, + { + ID: "KM", + Name: "科摩罗", + Type: "text", + IsDefault: false, + }, + { + ID: "KN", + Name: "圣基茨和尼维斯", + Type: "text", + IsDefault: false, + }, + { + ID: "KP", + Name: "朝鲜", + Type: "text", + IsDefault: false, + }, + { + ID: "KR", + Name: "韩国", + Type: "text", + IsDefault: false, + }, + { + ID: "KW", + Name: "科威特", + Type: "text", + IsDefault: false, + }, + { + ID: "KY", + Name: "开曼群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "KZ", + Name: "哈萨克斯坦", + Type: "text", + IsDefault: false, + }, + { + ID: "LA", + Name: "老挝", + Type: "text", + IsDefault: false, + }, + { + ID: "LB", + Name: "黎巴嫩", + Type: "text", + IsDefault: false, + }, + { + ID: "LC", + Name: "圣卢西亚", + Type: "text", + IsDefault: false, + }, + { + ID: "LI", + Name: "列支敦士登", + Type: "text", + IsDefault: false, + }, + { + ID: "LK", + Name: "斯里兰卡", + Type: "text", + IsDefault: false, + }, + { + ID: "LR", + Name: "利比里亚", + Type: "text", + IsDefault: false, + }, + { + ID: "LS", + Name: "莱索托", + Type: "text", + IsDefault: false, + }, + { + ID: "LT", + Name: "立陶宛", + Type: "text", + IsDefault: false, + }, + { + ID: "LU", + Name: "卢森堡", + Type: "text", + IsDefault: false, + }, + { + ID: "LV", + Name: "拉脱维亚", + Type: "text", + IsDefault: false, + }, + { + ID: "LY", + Name: "利比亚", + Type: "text", + IsDefault: false, + }, + { + ID: "MA", + Name: "摩洛哥", + Type: "text", + IsDefault: false, + }, + { + ID: "MC", + Name: "摩纳哥", + Type: "text", + IsDefault: false, + }, + { + ID: "MD", + Name: "摩尔多瓦", + Type: "text", + IsDefault: false, + }, + { + ID: "ME", + Name: "黑山", + Type: "text", + IsDefault: false, + }, + { + ID: "MF", + Name: "法属圣马丁", + Type: "text", + IsDefault: false, + }, + { + ID: "MG", + Name: "马达加斯加", + Type: "text", + IsDefault: false, + }, + { + ID: "MH", + Name: "马绍尔群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "MK", + Name: "马其顿", + Type: "text", + IsDefault: false, + }, + { + ID: "ML", + Name: "马里", + Type: "text", + IsDefault: false, + }, + { + ID: "MM", + Name: "缅甸", + Type: "text", + IsDefault: false, + }, + { + ID: "MN", + Name: "蒙古国", + Type: "text", + IsDefault: false, + }, + { + ID: "MP", + Name: "北马里亚纳群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "MQ", + Name: "马提尼克", + Type: "text", + IsDefault: false, + }, + { + ID: "MR", + Name: "毛里塔尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "MS", + Name: "蒙塞拉特岛", + Type: "text", + IsDefault: false, + }, + { + ID: "MT", + Name: "马耳他", + Type: "text", + IsDefault: false, + }, + { + ID: "MU", + Name: "毛里求斯", + Type: "text", + IsDefault: false, + }, + { + ID: "MV", + Name: "马尔代夫", + Type: "text", + IsDefault: false, + }, + { + ID: "MW", + Name: "马拉维", + Type: "text", + IsDefault: false, + }, + { + ID: "MX", + Name: "墨西哥", + Type: "text", + IsDefault: false, + }, + { + ID: "MY", + Name: "马来西亚", + Type: "text", + IsDefault: false, + }, + { + ID: "MZ", + Name: "莫桑比克", + Type: "text", + IsDefault: false, + }, + { + ID: "NA", + Name: "纳米比亚", + Type: "text", + IsDefault: false, + }, + { + ID: "NC", + Name: "新喀里多尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "NE", + Name: "尼日尔", + Type: "text", + IsDefault: false, + }, + { + ID: "NF", + Name: "诺福克岛", + Type: "text", + IsDefault: false, + }, + { + ID: "NG", + Name: "尼日利亚", + Type: "text", + IsDefault: false, + }, + { + ID: "NI", + Name: "尼加拉瓜", + Type: "text", + IsDefault: false, + }, + { + ID: "NL", + Name: "荷兰", + Type: "text", + IsDefault: false, + }, + { + ID: "NO", + Name: "挪威", + Type: "text", + IsDefault: false, + }, + { + ID: "NP", + Name: "尼泊尔", + Type: "text", + IsDefault: false, + }, + { + ID: "NR", + Name: "瑙鲁", + Type: "text", + IsDefault: false, + }, + { + ID: "NU", + Name: "纽埃", + Type: "text", + IsDefault: false, + }, + { + ID: "NZ", + Name: "新西兰", + Type: "text", + IsDefault: false, + }, + { + ID: "OM", + Name: "阿曼", + Type: "text", + IsDefault: false, + }, + { + ID: "PA", + Name: "巴拿马", + Type: "text", + IsDefault: false, + }, + { + ID: "PE", + Name: "秘鲁", + Type: "text", + IsDefault: false, + }, + { + ID: "PF", + Name: "法属波利尼西亚", + Type: "text", + IsDefault: false, + }, + { + ID: "PG", + Name: "巴布亚新几内亚", + Type: "text", + IsDefault: false, + }, + { + ID: "PH", + Name: "菲律宾", + Type: "text", + IsDefault: false, + }, + { + ID: "PK", + Name: "巴基斯坦", + Type: "text", + IsDefault: false, + }, + { + ID: "PL", + Name: "波兰", + Type: "text", + IsDefault: false, + }, + { + ID: "PM", + Name: "圣皮埃尔和密克隆", + Type: "text", + IsDefault: false, + }, + { + ID: "PN", + Name: "皮特凯恩群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "PR", + Name: "波多黎各", + Type: "text", + IsDefault: false, + }, + { + ID: "PS", + Name: "巴勒斯坦", + Type: "text", + IsDefault: false, + }, + { + ID: "PT", + Name: "葡萄牙", + Type: "text", + IsDefault: false, + }, + { + ID: "PW", + Name: "帕劳", + Type: "text", + IsDefault: false, + }, + { + ID: "PY", + Name: "巴拉圭", + Type: "text", + IsDefault: false, + }, + { + ID: "QA", + Name: "卡塔尔", + Type: "text", + IsDefault: false, + }, + { + ID: "RE", + Name: "留尼汪", + Type: "text", + IsDefault: false, + }, + { + ID: "RO", + Name: "罗马尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "RS", + Name: "塞尔维亚", + Type: "text", + IsDefault: false, + }, + { + ID: "RU", + Name: "俄罗斯", + Type: "text", + IsDefault: false, + }, + { + ID: "RW", + Name: "卢旺达", + Type: "text", + IsDefault: false, + }, + { + ID: "SA", + Name: "沙特阿拉伯", + Type: "text", + IsDefault: false, + }, + { + ID: "SB", + Name: "所罗门群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "SC", + Name: "塞舌尔", + Type: "text", + IsDefault: false, + }, + { + ID: "SD", + Name: "苏丹", + Type: "text", + IsDefault: false, + }, + { + ID: "SE", + Name: "瑞典", + Type: "text", + IsDefault: false, + }, + { + ID: "SG", + Name: "新加坡", + Type: "text", + IsDefault: false, + }, + { + ID: "SH", + Name: "圣赫勒拿", + Type: "text", + IsDefault: false, + }, + { + ID: "SI", + Name: "斯洛文尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "SJ", + Name: "斯瓦尔巴群岛和扬马延岛", + Type: "text", + IsDefault: false, + }, + { + ID: "SK", + Name: "斯洛伐克", + Type: "text", + IsDefault: false, + }, + { + ID: "SL", + Name: "塞拉利昂", + Type: "text", + IsDefault: false, + }, + { + ID: "SM", + Name: "圣马力诺", + Type: "text", + IsDefault: false, + }, + { + ID: "SN", + Name: "塞内加尔", + Type: "text", + IsDefault: false, + }, + { + ID: "SO", + Name: "索马里", + Type: "text", + IsDefault: false, + }, + { + ID: "SR", + Name: "苏里南", + Type: "text", + IsDefault: false, + }, + { + ID: "SS", + Name: "南苏丹", + Type: "text", + IsDefault: false, + }, + { + ID: "ST", + Name: "圣多美和普林西比", + Type: "text", + IsDefault: false, + }, + { + ID: "SV", + Name: "萨尔瓦多", + Type: "text", + IsDefault: false, + }, + { + ID: "SX", + Name: "荷属圣马丁", + Type: "text", + IsDefault: false, + }, + { + ID: "SY", + Name: "叙利亚", + Type: "text", + IsDefault: false, + }, + { + ID: "SZ", + Name: "斯威士兰", + Type: "text", + IsDefault: false, + }, + { + ID: "TC", + Name: "特克斯和凯科斯群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "TD", + Name: "乍得", + Type: "text", + IsDefault: false, + }, + { + ID: "TF", + Name: "法属南部领地", + Type: "text", + IsDefault: false, + }, + { + ID: "TG", + Name: "多哥", + Type: "text", + IsDefault: false, + }, + { + ID: "TH", + Name: "泰国", + Type: "text", + IsDefault: false, + }, + { + ID: "TJ", + Name: "塔吉克斯坦", + Type: "text", + IsDefault: false, + }, + { + ID: "TK", + Name: "托克劳", + Type: "text", + IsDefault: false, + }, + { + ID: "TL", + Name: "东帝汶", + Type: "text", + IsDefault: false, + }, + { + ID: "TM", + Name: "土库曼斯坦", + Type: "text", + IsDefault: false, + }, + { + ID: "TN", + Name: "突尼斯", + Type: "text", + IsDefault: false, + }, + { + ID: "TO", + Name: "汤加", + Type: "text", + IsDefault: false, + }, + { + ID: "TR", + Name: "土耳其", + Type: "text", + IsDefault: false, + }, + { + ID: "TT", + Name: "特立尼达和多巴哥", + Type: "text", + IsDefault: false, + }, + { + ID: "TV", + Name: "图瓦卢", + Type: "text", + IsDefault: false, + }, + { + ID: "TZ", + Name: "坦桑尼亚", + Type: "text", + IsDefault: false, + }, + { + ID: "UA", + Name: "乌克兰", + Type: "text", + IsDefault: false, + }, + { + ID: "UG", + Name: "乌干达", + Type: "text", + IsDefault: false, + }, + { + ID: "UM", + Name: "美国本土外小岛屿", + Type: "text", + IsDefault: false, + }, + { + ID: "UY", + Name: "乌拉圭", + Type: "text", + IsDefault: false, + }, + { + ID: "UZ", + Name: "乌兹别克斯坦", + Type: "text", + IsDefault: false, + }, + { + ID: "VA", + Name: "梵蒂冈", + Type: "text", + IsDefault: false, + }, + { + ID: "VC", + Name: "圣文森特和格林纳丁斯", + Type: "text", + IsDefault: false, + }, + { + ID: "VE", + Name: "委内瑞拉", + Type: "text", + IsDefault: false, + }, + { + ID: "VG", + Name: "英属维尔京群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "VI", + Name: "美属维尔京群岛", + Type: "text", + IsDefault: false, + }, + { + ID: "VN", + Name: "越南", + Type: "text", + IsDefault: false, + }, + { + ID: "US", + Name: "美国", + Type: "text", + IsDefault: false, + }, + { + ID: "VU", + Name: "瓦努阿图", + Type: "text", + IsDefault: false, + }, + { + ID: "WF", + Name: "瓦利斯和富图纳", + Type: "text", + IsDefault: false, + }, + { + ID: "WS", + Name: "萨摩亚", + Type: "text", + IsDefault: false, + }, + { + ID: "YE", + Name: "也门", + Type: "text", + IsDefault: false, + }, + { + ID: "YT", + Name: "马约特", + Type: "text", + IsDefault: false, + }, + { + ID: "ZA", + Name: "南非", + Type: "text", + IsDefault: false, + }, + { + ID: "ZM", + Name: "赞比亚", + Type: "text", + IsDefault: false, + }, + { + ID: "ZW", + Name: "津巴布韦", + Type: "text", + IsDefault: false, + }, +} + +var bizObjAttrs = []*metadata.Attribute{ + { + BizID: 0, + PropertyID: "bk_biz_name", + PropertyName: "业务名", + PropertyGroup: "default", + IsEditable: true, + IsRequired: true, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + }, + { + BizID: 0, + PropertyID: "life_cycle", + PropertyName: "生命周期", + PropertyGroup: "default", + IsEditable: true, + IsRequired: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "测试中", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "已上线", + Type: "text", + IsDefault: true, + }, + { + ID: "3", + Name: "停运", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + }, + { + BizID: 0, + PropertyID: "bk_biz_maintainer", + PropertyName: "运维人员", + PropertyGroup: "role", + IsEditable: true, + IsRequired: true, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + }, + { + BizID: 0, + PropertyID: "bk_biz_productor", + PropertyName: "产品人员", + PropertyGroup: "role", + IsEditable: true, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + }, + { + BizID: 0, + PropertyID: "bk_biz_tester", + PropertyName: "测试人员", + PropertyGroup: "role", + IsEditable: true, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + }, + { + BizID: 0, + PropertyID: "bk_biz_developer", + PropertyName: "开发人员", + PropertyGroup: "role", + IsEditable: true, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + }, + { + BizID: 0, + PropertyID: "operator", + PropertyName: "操作人员", + PropertyGroup: "role", + IsEditable: true, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + }, + { + BizID: 0, + PropertyID: "time_zone", + PropertyName: "时区", + PropertyGroup: "default", + IsEditable: false, + IsRequired: true, + PropertyType: "timezone", + Option: "", + IsMultiple: nil, + }, + { + BizID: 0, + PropertyID: "language", + PropertyName: "语言", + PropertyGroup: "default", + IsEditable: true, + IsRequired: true, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "中文", + Type: "text", + IsDefault: true, + }, + { + ID: "2", + Name: "English", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + }, + { + BizID: 0, + ObjectID: "biz", + PropertyID: "bk_created_at", + PropertyName: "创建时间", + PropertyGroup: "default", + IsEditable: false, + IsRequired: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + BizID: 0, + PropertyID: "bk_created_by", + PropertyName: "创建人", + PropertyGroup: "default", + IsEditable: false, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, + { + BizID: 0, + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + PropertyGroup: "default", + IsEditable: false, + IsRequired: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + BizID: 0, + PropertyID: "bk_updated_by", + PropertyName: "更新人", + PropertyGroup: "default", + IsEditable: false, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, +} + +var hostObjAttrs = []*metadata.Attribute{ + { + PropertyID: "bk_host_innerip", + PropertyName: "内网IPv4", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: `^((1?\d{1,2}|2[0-4]\d|25[0-5])[.]){3}(1?\d{1,2}|2[0-4]\d|25[0-5])(,((1?\d{1,2}|2[0-4]\d|25[0-5])[.]){3}(1?\d{1,2}|2[0-4]\d|25[0-5]))*$`, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_host_outerip", + PropertyName: "外网IPv4", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: `^((1?\d{1,2}|2[0-4]\d|25[0-5])[.]){3}(1?\d{1,2}|2[0-4]\d|25[0-5])(,((1?\d{1,2}|2[0-4]\d|25[0-5])[.]){3}(1?\d{1,2}|2[0-4]\d|25[0-5]))*$`, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "operator", + PropertyName: "主要维护人", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + Description: "", + }, + { + PropertyID: "bk_bak_operator", + PropertyName: "备份维护人", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + Description: "", + }, + { + PropertyID: "bk_asset_id", + PropertyName: "固资编号", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_sn", + PropertyName: "设备SN", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_comment", + PropertyName: "备注", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_service_term", + PropertyName: "质保年限", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 1, + Max: 10, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_sla", + PropertyName: "SLA级别", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "L1", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "L2", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "L3", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_cloud_id", + PropertyName: "管控区域", + PropertyGroup: "default", + Unit: "", + Placeholder: "管控区域为“未分配”的主机可在节点管理中重新指定管控区域并安装Agent", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "foreignkey", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_state_name", + PropertyName: "所在国家", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: countryEnum, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_province_name", + PropertyName: "所在省份", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: provincesEnum, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_isp_name", + PropertyName: "所属运营商", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "0", + Name: "其他", + Type: "text", + IsDefault: false, + }, + { + ID: "1", + Name: "电信", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "联通", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "移动", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_host_name", + PropertyName: "主机名称", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_os_type", + PropertyName: "操作系统类型", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "Linux", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "Windows", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "AIX", + Type: "text", + IsDefault: false, + }, + { + ID: "4", + Name: "Unix", + Type: "text", + IsDefault: false, + }, + { + ID: "5", + Name: "Solaris", + Type: "text", + IsDefault: false, + }, + { + ID: "7", + Name: "FreeBSD", + Type: "text", + IsDefault: false, + }, + { + ID: "8", + Name: "MacOS", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_os_name", + PropertyName: "操作系统名称", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_os_version", + PropertyName: "操作系统版本", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_os_bit", + PropertyName: "操作系统位数", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_cpu", + PropertyName: "CPU逻辑核心数", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 1, + Max: 1000000, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_cpu_module", + PropertyName: "CPU型号", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_mem", + PropertyName: "内存容量(MB)", + PropertyGroup: "auto", + Unit: "MB", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 1, + Max: 100000000, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_disk", + PropertyName: "磁盘容量(GB)", + PropertyGroup: "auto", + Unit: "GB", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 1, + Max: 100000000, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_mac", + PropertyName: "内网MAC地址", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_outer_mac", + PropertyName: "外网MAC地址", + PropertyGroup: "auto", + Unit: "", + Placeholder: "可人工设置。若需自动发现,请在主机上安装GseAgent和采集器。", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "create_time", + PropertyName: "录入时间", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "import_from", + PropertyName: "录入方式", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "excel", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "agent", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "api", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_state", + PropertyName: "当前状态", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "list", + Option: []string{ + "运营中[需告警]", + "运营中[无告警]", + "开发中[需告警]", + "开发中[无告警]", + "备用机", + "测试中", + "故障中", + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_cloud_inst_id", + PropertyName: "云主机实例ID", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_cloud_host_status", + PropertyName: "云主机状态", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "未知", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "启动中", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "运行中", + Type: "text", + IsDefault: false, + }, + { + ID: "4", + Name: "停止中", + Type: "text", + IsDefault: false, + }, + { + ID: "5", + Name: "已停止", + Type: "text", + IsDefault: false, + }, + { + ID: "6", + Name: "已销毁", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_cloud_vendor", + PropertyName: "云厂商", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "AWS", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "腾讯云", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "GCP", + Type: "text", + IsDefault: false, + }, + { + ID: "4", + Name: "Azure", + Type: "text", + IsDefault: false, + }, + { + ID: "5", + Name: "企业私有云", + Type: "text", + IsDefault: false, + }, + { + ID: "6", + Name: "SalesForce", + Type: "text", + IsDefault: false, + }, + { + ID: "7", + Name: "Oracle Cloud", + Type: "text", + IsDefault: false, + }, + { + ID: "8", + Name: "IBM Cloud", + Type: "text", + IsDefault: false, + }, + { + ID: "9", + Name: "阿里云", + Type: "text", + IsDefault: false, + }, + { + ID: "10", + Name: "中国电信", + Type: "text", + IsDefault: false, + }, + { + ID: "11", + Name: "UCloud", + Type: "text", + IsDefault: false, + }, + { + ID: "12", + Name: "美团云", + Type: "text", + IsDefault: false, + }, + { + ID: "13", + Name: "金山云", + Type: "text", + IsDefault: false, + }, + { + ID: "14", + Name: "百度云", + Type: "text", + IsDefault: false, + }, + { + ID: "15", + Name: "华为云", + Type: "text", + IsDefault: false, + }, + { + ID: "16", + Name: "首都云", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_cpu_architecture", + PropertyName: "CPU架构", + PropertyGroup: "auto", + Unit: "", + Placeholder: "选择CPU架构类型,如X86或ARM", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "x86", + Name: "X86", + Type: "text", + IsDefault: true, + }, + { + ID: "arm", + Name: "ARM", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_host_innerip_v6", + PropertyName: "内网IPv6", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: `^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?)*$`, + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_host_outerip_v6", + PropertyName: "外网IPv6", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: `^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?(((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?)*$`, + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_agent_id", + PropertyName: "GSE Agent ID", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: `^[a-zA-Z0-9]{0,64}$`, + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_cloud_host_identifier", + PropertyName: "云主机标识", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: true, + IsSystem: true, + IsAPI: true, + PropertyType: "bool", + Option: "", + IsMultiple: &falseVar, + Description: "云主机标识", + }, + { + PropertyID: "bk_addressing", + PropertyName: "寻址方式", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "static", + Name: "静态", + Type: "text", + IsDefault: true, + }, + { + ID: "dynamic", + Name: "动态", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_created_at", + PropertyName: "创建时间", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_created_by", + PropertyName: "创建人", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_by", + PropertyName: "更新人", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_cloud_region", + PropertyName: "云地域(Region)", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_cloud_zone", + PropertyName: "云可用区(Zone)", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, +} + +var setObjAttrs = []*metadata.Attribute{ + { + PropertyID: "bk_biz_id", + PropertyName: "业务ID", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: true, + PropertyType: "int", + Option: nil, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_set_name", + PropertyName: "集群名", + IsEditable: true, + IsRequired: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_set_desc", + PropertyName: "集群描述", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_set_env", + PropertyName: "环境类型", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "测试", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "体验", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "正式", + Type: "text", + IsDefault: true, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_service_status", + PropertyName: "服务状态", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "开放", + Type: "text", + IsDefault: true, + }, + { + ID: "2", + Name: "关闭", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "description", + PropertyName: "备注", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_capacity", + PropertyName: "设计容量", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 1, + Max: 999999999, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_parent_id", + PropertyName: "", + IsEditable: false, + IsRequired: true, + IsReadOnly: false, + IsSystem: true, + IsAPI: false, + PropertyType: "int", + Option: nil, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "set_template_id", + PropertyName: "集群模板ID", + IsEditable: false, + IsRequired: false, + IsReadOnly: true, + IsSystem: true, + IsAPI: true, + PropertyType: "int", + Option: "", + IsMultiple: nil, + Description: "集群模板ID", + }, + { + PropertyID: "set_template_version", + PropertyName: "集群模板", + IsEditable: true, + IsRequired: false, + IsReadOnly: true, + IsSystem: true, + IsAPI: true, + PropertyType: "int", + Option: "", + IsMultiple: nil, + Description: "集群版本,从通集群模板同步", + }, + { + PropertyID: "bk_created_at", + PropertyName: "创建时间", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_created_by", + PropertyName: "创建人", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_by", + PropertyName: "更新人", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, +} + +var processObjAttrs = []*metadata.Attribute{ + { + PropertyID: "bk_biz_id", + PropertyName: "业务ID", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsRequired: true, + IsAPI: true, + PropertyType: "int", + Option: nil, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_process_name", + PropertyName: "进程别名", + PropertyGroup: "default", + Unit: "", + Placeholder: "对外显示的服务名
比如程序的二进制名称为java的服务zookeeper,则填zookeeper", + IsEditable: true, + IsRequired: true, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "description", + PropertyName: "备注", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_func_name", + PropertyName: "进程名称", + PropertyGroup: "default", + Unit: "", + Placeholder: "程序的二进制名称
比如zookeeper的二进制名称是java,则填java", + IsEditable: true, + IsRequired: true, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "work_path", + PropertyName: "工作路径", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "执行进程启停等操作的工作路径", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "user", + PropertyName: "启动用户", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "proc_num", + PropertyName: "启动数量", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 1, + Max: 10000, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "priority", + PropertyName: "启动优先级", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "批量启动进程依据优先级从小到大排序操作,停止进程按反序操作。优先级数值范围支持输入 [ -100 ~ 10000 ]", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: -100, + Max: 10000, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "timeout", + PropertyName: "操作超时时长", + PropertyGroup: "proc_mgr", + Unit: "s", + Placeholder: "执行命令的超时时长", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 0, + Max: 10000, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "start_cmd", + PropertyName: "启动命令", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "stop_cmd", + PropertyName: "停止命令", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "restart_cmd", + PropertyName: "重启命令", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "face_stop_cmd", + PropertyName: "强制停止命令", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "reload_cmd", + PropertyName: "进程重载命令", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "pid_file", + PropertyName: "PID文件路径", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "auto_start", + PropertyName: "是否自动拉起", + PropertyGroup: "proc_mgr", + Unit: "", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: true, + PropertyType: "bool", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_start_param_regex", + PropertyName: "启动参数匹配规则", + PropertyGroup: "default", + Unit: "", + Placeholder: "程序启动参数
用于唯一识别一个进程,例如 -cp zookeeper", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bind_info", + PropertyName: "bind_info", + PropertyGroup: "proc_port", + Unit: "", + Placeholder: "process bind port information", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "table", + Option: []map[string]interface{}{ + { + "bk_property_id": "ip", + "bk_property_name": "IP", + "placeholder": "bind ip", + "editable": true, + "isrequired": false, + "isreadonly": false, + "bk_issystem": false, + "bk_isapi": false, + "bk_property_type": "singlechar", + "option": "(^((1?\\d{1,2}|2[0-4]\\d|25[0-5])[.]){3}(1?\\d{1,2}|2[0-4]\\d|25[0-5])$)|(^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$)", + "description": "", + "bk_property_group": "bind_info", + }, + { + "bk_property_id": "port", + "bk_property_name": "Port", + "placeholder": "Single port: 8080
Range port: 8080-9090", + "editable": true, + "isrequired": true, + "isreadonly": false, + "bk_issystem": false, + "bk_isapi": false, + "bk_property_type": "singlechar", + "option": "^(((([1-9][0-9]{0,3})|([1-5][0-9]{4})|(6[0-4][0-9]{3})|(65[0-4][0-9]{2})|(655[0-2][0-9])|(6553[0-5]))-(([1-9][0-9]{0,3})|([1-5][0-9]{4})|(6[0-4][0-9]{3})|(65[0-4][0-9]{2})|(655[0-2][0-9])|(6553[0-5])))|((([1-9][0-9]{0,3})|([1-5][0-9]{4})|(6[0-4][0-9]{3})|(65[0-4][0-9]{2})|(655[0-2][0-9])|(6553[0-5]))))$", + "description": "", + "bk_property_group": "bind_info", + }, + { + "bk_property_id": "protocol", + "bk_property_name": "Protocol", + "placeholder": "service use protocol,", + "editable": true, + "isrequired": true, + "isreadonly": false, + "bk_issystem": false, + "bk_isapi": false, + "bk_property_type": "enum", + "option": []metadata.EnumVal{ + { + ID: "1", + Name: "TCP", + Type: "text", + IsDefault: true, + }, + { + ID: "2", + Name: "UDP", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "TCP6", + Type: "text", + IsDefault: false, + }, + { + ID: "4", + Name: "UDP6", + Type: "text", + IsDefault: false, + }, + }, + "description": "", + "bk_property_group": "bind_info", + }, + { + "bk_property_id": "enable", + "bk_property_name": "Enable", + "placeholder": "enable port", + "editable": true, + "isrequired": true, + "isreadonly": false, + "bk_issystem": false, + "bk_isapi": false, + "bk_property_type": "bool", + "option": nil, + "description": "", + "bk_property_group": "bind_info", + }, + { + "bk_property_id": "template_row_id", + "bk_property_name": "RowID", + "placeholder": "process template row id", + "editable": false, + "isrequired": false, + "isreadonly": false, + "bk_issystem": false, + "bk_isapi": true, + "bk_property_type": "int", + "option": nil, + "description": "", + "bk_property_group": "bind_info", + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_start_check_secs", + PropertyName: "启动等待时长", + PropertyGroup: "proc_mgr", + Unit: "s", + Placeholder: "在执行启动命令后,等待多久检查PID存活的状态", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "int", + Option: metadata.IntOption{ + Min: 0, + Max: 600, + }, + IsMultiple: &falseVar, + Description: "cc_system", + }, + { + PropertyID: "service_instance_id", + PropertyName: "服务实例ID", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsRequired: true, + IsAPI: true, + PropertyType: "int", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_created_at", + PropertyName: "创建时间", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_created_by", + PropertyName: "创建人", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_by", + PropertyName: "更新人", + PropertyGroup: "default", + Unit: "", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, +} + +var moduleObjAttrs = []*metadata.Attribute{ + { + PropertyID: "bk_biz_id", + PropertyName: "业务ID", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: true, + PropertyType: "int", + Option: nil, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_set_id", + PropertyName: "集群ID", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: true, + PropertyType: "int", + Option: nil, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_module_name", + PropertyName: "模块名", + Placeholder: "", + IsEditable: true, + IsRequired: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "bk_module_type", + PropertyName: "模块类型", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "普通", + Type: "text", + IsDefault: true, + }, + { + ID: "2", + Name: "数据库", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: nil, + Description: "", + }, + { + PropertyID: "operator", + PropertyName: "主要维护人", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + Description: "", + }, + { + PropertyID: "bk_bak_operator", + PropertyName: "备份维护人", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + Description: "", + }, + { + PropertyID: "service_category_id", + PropertyName: "服务分类ID", + Placeholder: "", + IsEditable: true, + IsRequired: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: true, + PropertyType: "int", + Option: "", + IsMultiple: nil, + Description: "服务分类,外键到 cc_ServiceCategory", + }, + { + PropertyID: "service_template_id", + PropertyName: "服务模板ID", + Placeholder: "", + IsEditable: false, + IsRequired: true, + IsReadOnly: false, + IsSystem: false, + IsAPI: true, + PropertyType: "int", + Option: "", + IsMultiple: nil, + Description: "服务模板, 外键到 cc_ServiceTemplate", + }, + { + PropertyID: "set_template_id", + PropertyName: "集群模板ID", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsReadOnly: true, + IsSystem: true, + IsAPI: true, + PropertyType: "int", + Option: "", + IsMultiple: nil, + Description: "集群模板ID", + }, + { + PropertyID: "host_apply_enabled", + PropertyName: "主机属性自动应用", + Placeholder: "是否开启主机属性自动应用", + IsEditable: true, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: true, + PropertyType: "bool", + Option: nil, + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_parent_id", + PropertyName: "模块实例的父节点ID", + Placeholder: "", + IsEditable: false, + IsRequired: true, + IsReadOnly: false, + IsSystem: true, + IsAPI: true, + PropertyType: "int", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_created_at", + PropertyName: "创建时间", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_created_by", + PropertyName: "创建人", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, + { + PropertyID: "bk_updated_by", + PropertyName: "更新人", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsReadOnly: false, + IsSystem: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + Description: "", + }, +} + +var platObjAttrs = []*metadata.Attribute{ + { + PropertyID: "bk_cloud_name", + PropertyName: "管控区域", + IsEditable: true, + IsRequired: true, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + }, + { + PropertyID: "bk_supplier_account", + PropertyName: "供应商", + IsEditable: false, + IsRequired: true, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + }, + { + PropertyID: "bk_status", + PropertyName: "状态", + IsEditable: false, + IsRequired: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "正常", + Type: "text", + IsDefault: true, + }, + { + ID: "2", + Name: "异常", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_status_detail", + PropertyName: "状态详情", + IsEditable: false, + IsRequired: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_cloud_vendor", + PropertyName: "云厂商", + IsEditable: true, + IsRequired: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "1", + Name: "AWS", + Type: "text", + IsDefault: false, + }, + { + ID: "2", + Name: "腾讯云", + Type: "text", + IsDefault: false, + }, + { + ID: "3", + Name: "GCP", + Type: "text", + IsDefault: false, + }, + { + ID: "4", + Name: "Azure", + Type: "text", + IsDefault: false, + }, + { + ID: "5", + Name: "企业私有云", + Type: "text", + IsDefault: false, + }, + { + ID: "6", + Name: "SalesForce", + Type: "text", + IsDefault: false, + }, + { + ID: "7", + Name: "Oracle Cloud", + Type: "text", + IsDefault: false, + }, + { + ID: "8", + Name: "IBM Cloud", + Type: "text", + IsDefault: false, + }, + { + ID: "9", + Name: "阿里云", + Type: "text", + IsDefault: false, + }, + { + ID: "10", + Name: "中国电信", + Type: "text", + IsDefault: false, + }, + { + ID: "11", + Name: "UCloud", + Type: "text", + IsDefault: false, + }, + { + ID: "12", + Name: "美团云", + Type: "text", + IsDefault: false, + }, + { + ID: "13", + Name: "金山云", + Type: "text", + IsDefault: false, + }, + { + ID: "14", + Name: "百度云", + Type: "text", + IsDefault: false, + }, + { + ID: "15", + Name: "华为云", + Type: "text", + IsDefault: false, + }, + { + ID: "16", + Name: "首都云", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_vpc_id", + PropertyName: "VPC唯一标识", + IsEditable: false, + IsRequired: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_vpc_name", + PropertyName: "VPC名称", + IsEditable: false, + IsRequired: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_account_id", + PropertyName: "云账户ID", + IsEditable: false, + IsRequired: false, + PropertyType: "int", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_region", + PropertyName: "VPC所属地域", + IsEditable: true, + IsRequired: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_creator", + PropertyName: "创建者", + IsEditable: true, + IsRequired: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_last_editor", + PropertyName: "最后修改人", + IsEditable: true, + IsRequired: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_created_at", + PropertyName: "创建时间", + IsEditable: false, + IsRequired: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_created_by", + PropertyName: "创建人", + IsEditable: false, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + IsEditable: false, + IsRequired: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_updated_by", + PropertyName: "更新人", + IsEditable: false, + IsRequired: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, +} + +var projectObjAttrs = []*metadata.Attribute{ + { + PropertyID: "bk_project_type", + PropertyName: "项目类型", + IsEditable: true, + IsRequired: true, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "mobile_game", + Name: "手游", + Type: "text", + IsDefault: false, + }, + { + ID: "pc_game", + Name: "端游", + Type: "text", + IsDefault: false, + }, + { + ID: "web_game", + Name: "页游", + Type: "text", + IsDefault: false, + }, + { + ID: "platform_prod", + Name: "平台产品", + Type: "text", + IsDefault: false, + }, + { + ID: "support_prod", + Name: "支撑产品", + Type: "text", + IsDefault: false, + }, + { + ID: "other", + Name: "其他", + Type: "text", + IsDefault: true, + }, + }, + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_project_sec_lvl", + PropertyName: "保密级别", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "public", + Name: "公开", + Type: "text", + IsDefault: true, + }, + { + ID: "private", + Name: "私有", + Type: "text", + IsDefault: false, + }, + { + ID: "classified", + Name: "机密", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_status", + PropertyName: "项目状态", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "enum", + Option: []metadata.EnumVal{ + { + ID: "enable", + Name: "启用", + Type: "text", + IsDefault: true, + }, + { + ID: "disabled", + Name: "未启用", + Type: "text", + IsDefault: false, + }, + }, + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_project_icon", + PropertyName: "项目图标", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "id", + PropertyName: "ID", + IsEditable: false, + IsRequired: false, + IsAPI: true, + PropertyType: "int", + Option: nil, + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_project_id", + PropertyName: "项目ID", + IsEditable: false, + IsRequired: false, + IsAPI: true, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_project_desc", + PropertyName: "项目描述", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "longchar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_project_owner", + PropertyName: "项目负责人", + IsEditable: true, + IsRequired: true, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + }, + { + PropertyID: "bk_project_team", + PropertyName: "所属团队", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "organization", + Option: "", + IsMultiple: &trueVar, + }, + { + PropertyID: "bk_project_name", + PropertyName: "项目名称", + IsEditable: true, + IsRequired: true, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_project_code", + PropertyName: "项目英文名", + IsEditable: false, + IsRequired: true, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_created_at", + PropertyName: "创建时间", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_created_by", + PropertyName: "创建人", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_updated_by", + PropertyName: "更新人", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, +} + +var bizSetObjAttrData = []*metadata.Attribute{ + { + PropertyID: "bk_biz_maintainer", + PropertyName: "运维人员", + PropertyGroup: "role", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &trueVar, + }, + { + PropertyID: "bk_scope", + PropertyName: "业务范围", + PropertyGroup: "default", + Placeholder: "业务集所包含的业务的条件", + IsEditable: true, + IsRequired: true, + IsAPI: true, + PropertyType: "object", + Option: "", + IsMultiple: nil, + }, + { + PropertyID: "bk_biz_set_name", + PropertyName: "业务集名", + PropertyGroup: "default", + Placeholder: "", + IsEditable: true, + IsRequired: true, + IsAPI: false, + PropertyType: "singlechar", + Option: `^[^\\\|\/:\*,<>"\?#\s]+$`, + IsMultiple: nil, + }, + { + PropertyID: "bk_biz_set_id", + PropertyName: "业务集ID", + PropertyGroup: "default", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: true, + PropertyType: "int", + Option: nil, + IsMultiple: nil, + }, + { + PropertyID: "bk_biz_set_desc", + PropertyName: "业务集描述", + PropertyGroup: "default", + Placeholder: "", + IsEditable: true, + IsRequired: false, + IsAPI: false, + PropertyType: "singlechar", + Option: "", + IsMultiple: nil, + }, + { + PropertyID: "bk_created_at", + PropertyName: "创建时间", + PropertyGroup: "default", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_created_by", + PropertyName: "创建人", + PropertyGroup: "default", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_updated_at", + PropertyName: "更新时间", + PropertyGroup: "default", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "time", + Option: "", + IsMultiple: &falseVar, + }, + { + PropertyID: "bk_updated_by", + PropertyName: "更新人", + PropertyGroup: "default", + Placeholder: "", + IsEditable: false, + IsRequired: false, + IsAPI: false, + PropertyType: "objuser", + Option: "", + IsMultiple: &falseVar, + }, +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/indexes.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/indexes.go new file mode 100644 index 0000000000..abcea2f734 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/indexes.go @@ -0,0 +1,2249 @@ +package y3_15_202411071530 + +import ( + "configcenter/src/common" + "configcenter/src/storage/dal/types" + + "go.mongodb.org/mongo-driver/bson" +) + +var ( + APITaskSyncHistoryIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkInstID_flag_createTime", + Keys: bson.D{{"bk_inst_id", 1}, {"flag", 1}, {"create_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "lastTime", + Keys: bson.D{{"last_time", 1}}, + Background: false, + ExpireAfterSeconds: 3 * 30 * 24 * 60 * 60, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ObjAttDesIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID_bkPropertyID_bkBizID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_property_id", 1}, {"bk_biz_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkTemplateID_bkSupplierAccount", + Keys: bson.D{{"bk_template_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + APITaskIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "taskID", + Keys: bson.D{{"task_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "flag_status_createTime", + Keys: bson.D{{"flag", 1}, {"status", 1}, {"create_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "lastTime_status", + Keys: bson.D{{"last_time", 1}, {"status", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "lastTime", + Keys: bson.D{{"last_time", 1}}, + Background: false, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "createTime_name_status", + Keys: bson.D{{"create_time", 1}, {"name", 1}, {"status", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "status_lastTime", + Keys: bson.D{{"status", 1}, {"last_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_flag_createTime", + Keys: bson.D{{"name", 1}, {"flag", 1}, {"create_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ApplicationBaseIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "default", + Keys: bson.D{{"default", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizName", + Keys: bson.D{{"bk_biz_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"bk_biz_name": map[string]string{common.BKDBType: "string"}}, + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "default_bkSupplierAccount", + Keys: bson.D{{"default", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + AsstDesIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + AuditLogIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "operationTime", + Keys: bson.D{{"operation_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "user", + Keys: bson.D{{"user", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "resourceName", + Keys: bson.D{{"resource_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "auditType_resourceName_action_operationTime", + Keys: bson.D{{"audit_type", 1}, {"resource_type", 1}, {"action", 1}, + {"operation_time", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + BizSetBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetID", + Keys: bson.D{{"bk_biz_set_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizSetName", + Keys: bson.D{{"bk_biz_set_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizSetID_bkBizSetName_bkSupplierAccount", + Keys: bson.D{{"bk_biz_set_id", 1}, {"bk_biz_set_name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ChartConfigIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "configID", + Keys: bson.D{{"config_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ChartPositionIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + CloudAccountIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkAccountID", + Keys: bson.D{{"bk_account_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + CloudSyncHistoryIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkHistoryID", + Keys: bson.D{{"bk_history_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + CloudSyncTaskIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkTaskID", + Keys: bson.D{{"bk_task_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ClusterBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "UID", + Keys: bson.D{{"uid", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_name_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "xid_bkSupplierAccount", + Keys: bson.D{{"xid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameBaseContainer + ContainerBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkPodID_containerUID", + Keys: bson.D{{"bk_pod_id", 1}, {"container_uid", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkPodID_bkSupplierAccount", + Keys: bson.D{{"bk_pod_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkNamespaceID_bkSupplierAccount", + Keys: bson.D{{"bk_namespace_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "refID_refKind_bkSupplierAccount", + Keys: bson.D{{"ref.id", 1}, {"ref.kind", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameBaseCronJob + CronJobBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // cc_DaemonSetBase BKTableNameBaseDaemonSet + DaemonSetBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // cc_DelArchive BKTableNameDelArchive + DelArchiveIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "OID_coll", + Keys: bson.D{{"oid", 1}, {"coll", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "coll", + Keys: bson.D{{"coll", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "OID", + Keys: bson.D{{"oid", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "time", + Keys: bson.D{{"time", -1}}, + Background: true, + ExpireAfterSeconds: 7 * 24 * 60 * 60, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameBaseDeployment = "cc_DeploymentBase" + DeploymentBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameDynamicGroup = "cc_DynamicGroup" + DynamicGroupIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_ID", + Keys: bson.D{{"bk_biz_id", 1}, {"id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_name", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameFieldTemplate = "cc_FieldTemplate" + FieldTemplateIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "name", + Keys: bson.D{{"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameFullSyncCond = "cc_FullSyncCond" + FullSyncCondIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "resource_subResource_bkSupplierAccount", + Keys: bson.D{{"resource", 1}, {"sub_resource", 1}, {"bk_supplier_account", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"is_all": true}, + }, + } + // BKTableNameGameDeployment = "cc_GameDeploymentBase" + GameDeploymentBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // cc_GameStatefulSetBase BKTableNameGameStatefulSet + GameStatefulSetBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + + // BKTableNameHostApplyRule = "cc_HostApplyRule" + HostApplyRuleIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: false, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: false, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID", + Keys: bson.D{{"bk_module_id", 1}}, + Background: false, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_bkModuleID_serviceTemplateID_bkAttributeID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_module_id", 1}, {"service_template_id", 1}, + {"bk_attribute_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID_bkAttributeID", + Keys: bson.D{{"service_template_id", 1}, {"bk_attribute_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_serviceTemplateID_bkAttributeID", + Keys: bson.D{{"bk_biz_id", 1}, {"service_template_id", 1}, {"bk_attribute_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkModuleID_bkAttributeID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_module_id", 1}, {"bk_attribute_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkAttributeID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_attribute_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameBaseHost = "cc_HostBase" + HostBaseIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkHostName", + Keys: bson.D{{"bk_host_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkHostInnerIP", + Keys: bson.D{{"bk_host_innerip", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkCloudInstID", + Keys: bson.D{{"bk_cloud_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkCloudID", + Keys: bson.D{{"bk_cloud_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkOsType", + Keys: bson.D{{"bk_os_type", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostOuterIP", + Keys: bson.D{{"bk_host_outerip", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"bk_host_outerip": map[string]string{common.BKDBType: "string"}}, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkCloudInstID_bkCloudVendor", + Keys: bson.D{{"bk_cloud_inst_id", 1}, {"bk_cloud_vendor", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_cloud_inst_id": map[string]string{common.BKDBType: "string"}, + "bk_cloud_vendor": map[string]string{common.BKDBType: "string"}, + }, + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkHostID_bkSupplierAccount", + Keys: bson.D{{"bk_host_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAssetID", + Keys: bson.D{{"bk_asset_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkAgentID", + Keys: bson.D{{"bk_agent_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"bk_agent_id": map[string]string{common.BKDBType: "string", + common.BKDBGT: ""}}, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostInnerIP_bkCloudID", + Keys: bson.D{{"bk_host_innerip", 1}, {"bk_cloud_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_host_innerip": map[string]string{common.BKDBType: "string"}, + "bk_cloud_id": map[string]string{common.BKDBType: "number"}, + "bk_addressing": "static", + }, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkHostInnerIP_v6_bkCloudID", + Keys: bson.D{{"bk_host_innerip_v6", 1}, {"bk_cloud_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_cloud_id": map[string]string{common.BKDBType: "number"}, + "bk_addressing": "static", + "bk_host_innerip_v6": map[string]string{common.BKDBType: "string"}, + }, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkCloudID_bkHostInnerIP", + Keys: bson.D{{"bk_cloud_id", 1}, {"bk_host_innerip", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_cloud_id": map[string]string{common.BKDBType: "number"}, + "bk_host_innerip": map[string]string{common.BKDBType: "string"}, + "bk_addressing": "static", + }, + }, + } + + // BKTableNameHostLock = "cc_HostLock" + HostLockIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + // BKTableNameInstAsst = "cc_InstAsst" + InstAsstIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjId_bkInstId", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", -1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkAsstObjID_bkAsstID", + Keys: bson.D{{"bk_obj_id", -1}, {"bk_asst_obj_id", -1}, {"bk_asst_id", -1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkObjAsstID_ID", + Keys: bson.D{{"bk_obj_asst_id", -1}, {"id", -1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkObjAsstID_ID", + Keys: bson.D{{"bk_obj_asst_id", -1}, {"id", -1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + JobBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ObjAsstIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID", + Keys: bson.D{{"bk_asst_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkAsstObjID_bkAsstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_asst_obj_id", 1}, {"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ProjectBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkProjectID", + Keys: bson.D{{"bk_project_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkProjectName", + Keys: bson.D{{"bk_project_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkProjectCode", + Keys: bson.D{{"bk_project_code", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkStatus", + Keys: bson.D{{"bk_status", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + PlatBaseIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkVpcID", + Keys: bson.D{{"bk_vpc_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkCloudID", + Keys: bson.D{{"bk_cloud_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkCloudName", + Keys: bson.D{{"bk_cloud_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"bk_cloud_name": map[string]string{common.BKDBType: "string"}}, + }, + } + SetTemplateIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_name", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ProcessInstanceRelationIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "serviceInstanceID", + Keys: bson.D{{"service_instance_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "processTemplateID", + Keys: bson.D{{"process_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkProcessID", + Keys: bson.D{{"bk_process_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "serviceInstanceID_bkProcessID", + Keys: bson.D{{"service_instance_id", 1}, {"bk_process_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkProcessID_bkHostID", + Keys: bson.D{{"bk_process_id", 1}, {"bk_host_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + NetcollectPropertyIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "netcollectPropertyID", + Keys: bson.D{{"netcollect_property_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ObjectBaseIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkInstID", + Keys: bson.D{{"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkInstName", + Keys: bson.D{{"bk_inst_name", 1}}, + Background: false, + PartialFilterExpression: make(map[string]interface{}), + }, + } + PropertyGroupIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkGroupID", + Keys: bson.D{{"bk_group_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_bkGroupName_bkObjID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_group_name", 1}, {"bk_obj_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID_bkBizID_bkGroupIndex", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_biz_id", 1}, {"bk_group_index", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + /* { + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID_bkBizID_bkGroupID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_biz_id", 1}, {"bk_group_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + },*/ + } + ObjAttDesTemplateIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkTemplateID_bkPropertyID", + Keys: bson.D{{"bk_template_id", 1}, {"bk_property_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkTemplateID_bkPropertyName", + Keys: bson.D{{"bk_template_id", 1}, {"bk_property_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + SubscriptionIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "subscriptionID", + Keys: bson.D{{"subscription_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "subscriptionName", + Keys: bson.D{{"subscription_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ServiceCategoryIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "name_bkParentID_bkBizID", + Keys: bson.D{{"name", 1}, {"bk_parent_id", 1}, {"bk_biz_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + StatefulSetBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ModuleBaseIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkModuleName", + Keys: bson.D{{"bk_module_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "default", + Keys: bson.D{{"default", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSetID", + Keys: bson.D{{"bk_set_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkParentID", + Keys: bson.D{{"bk_parent_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_bkSetID_bkModuleName", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_set_id", 1}, {"bk_module_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"bk_biz_id": map[string]string{common.BKDBType: "number"}, + "bk_set_id": map[string]string{common.BKDBType: "number"}, + "bk_module_name": map[string]string{common.BKDBType: "string"}}, + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkBizID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkModuleID", + Keys: bson.D{{"bk_module_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "setTemplateID_serviceTemplateID", + Keys: bson.D{{"set_template_id", 1}, {"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "setTemplateID", + Keys: bson.D{{"set_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID", + Keys: bson.D{{"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ServiceTemplateAttrIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_serviceTemplateID_bkAttributeID", + Keys: bson.D{{"bk_biz_id", 1}, {"service_template_id", 1}, {"bk_attribute_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + SetServiceTemplateRelationIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "setTemplateID_serviceTemplateID", + Keys: bson.D{{"set_template_id", 1}, {"service_template_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_setTemplateID_serviceTemplateID", + Keys: bson.D{{"bk_biz_id", 1}, {"set_template_id", 1}, {"service_template_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ProcessTemplateIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID", + Keys: bson.D{{"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "serviceTemplateID_bkProcessName", + Keys: bson.D{{"service_template_id", 1}, {"bk_process_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + SetTemplateAttrIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_setTemplateID_bkAttributeID", + Keys: bson.D{{"bk_biz_id", 1}, {"set_template_id", 1}, {"bk_attribute_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ObjectUniqueTemplateIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkTemplateID_bkSupplierAccount", + Keys: bson.D{{"bk_template_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + NetcollectDeviceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "deviceID", + Keys: bson.D{{"device_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "deviceName", + Keys: bson.D{{"device_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + NsSharedClusterRelationIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID", + Keys: bson.D{{"bk_namespace_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstBizID", + Keys: bson.D{{"bk_asst_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ModelQuoteRelationIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "destModel_bkSupplierAccount", + Keys: bson.D{{"dest_model", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "srcModel_bkPropertyID_bkSupplierAccount", + Keys: bson.D{{"src_model", 1}, {"bk_property_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "srcModel_bkSupplierAccount", + Keys: bson.D{{"src_model", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ObjectBaseMappingIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkInstID", + Keys: bson.D{{"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ModuleHostConfigIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID", + Keys: bson.D{{"bk_module_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSetID", + Keys: bson.D{{"bk_set_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkModuleID_bkHostID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_host_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkHostID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkBizID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSetID_bkBizID", + Keys: bson.D{{"bk_set_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + TopoGraphicsIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "scopeType_scopeID_nodeType_bkObjID_bkInstID", + Keys: bson.D{{"scope_type", 1}, {"scope_id", 1}, {"node_type", 1}, {"bk_obj_id", 1}, + {"bk_inst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ServiceInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "serviceTemplateID", + Keys: bson.D{{"service_template_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID", + Keys: bson.D{{"bk_module_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_ID", + Keys: bson.D{{"bk_biz_id", 1}, {"id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkModuleID_bkBizID", + Keys: bson.D{{"bk_module_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkHostID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkHostID", + Keys: bson.D{{"bk_host_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + PodWorkloadBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkNamespaceID_name", + Keys: bson.D{{"bk_namespace_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ObjectUniqueIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Background: false, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkTemplateID_bkSupplierAccount", + Keys: bson.D{{"bk_template_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + NodeBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkClusterID_name", + Keys: bson.D{{"bk_cluster_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_clusterUID_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_bkHostID_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_host_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID_name_bkSupplierAccount", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + PodBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "refID_refKind_name", + Keys: bson.D{{"ref.id", 1}, {"ref.kind", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkHostID_bkSupplierAccount", + Keys: bson.D{{"bk_host_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "refName_refID_bkSupplierAccount", + Keys: bson.D{{"ref.name", 1}, {"ref.id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkClusterID_bkSupplierAccount", + Keys: bson.D{{"bk_cluster_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{{"cluster_uid", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{{"name", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkNodeID", + Keys: bson.D{{"bk_node_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkNamespaceID_bkSupplierAccount", + Keys: bson.D{{"bk_namespace_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "refID_refKind_bkSupplierAccount", + Keys: bson.D{{"ref.id", 1}, {"ref.kind", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + SetBaseIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkParentID", + Keys: bson.D{{"bk_parent_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSetName", + Keys: bson.D{{"bk_set_name", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkParentID_bkSetName", + Keys: bson.D{{"bk_parent_id", 1}, {"bk_set_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_bkSetName_bkParentID", + Keys: bson.D{{"bk_biz_id", 1}, {"bk_set_name", 1}, {"bk_parent_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{ + "bk_set_name": map[string]string{common.BKDBType: "string"}, + "bk_parent_id": map[string]string{common.BKDBType: "number"}, + "bk_biz_id": map[string]string{common.BKDBType: "number"}}, + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSetID_bkBizID", + Keys: bson.D{{"bk_set_id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkSetID", + Keys: bson.D{{"bk_set_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ProcessIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkProcessID", + Keys: bson.D{{"bk_process_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "serviceInstanceID_bkProcessName", + Keys: bson.D{{"service_instance_id", 1}, {"bk_process_name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"service_instance_id": map[string]string{common.BKDBType: "number"}, + "bk_process_name": map[string]string{common.BKDBType: "string"}}, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "serviceInstanceID_bkFuncName_bkStartParamRegex", + Keys: bson.D{{"service_instance_id", 1}, {"bk_func_name", 1}, + {"bk_start_param_regex", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: map[string]interface{}{"service_instance_id": map[string]string{common.BKDBType: "number"}, + "bk_func_name": map[string]string{common.BKDBType: "string"}, + "bk_start_param_regex": map[string]string{common.BKDBType: "string"}}, + }, + } + ObjDesIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkClassificationID", + Keys: bson.D{{"bk_classification_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkSupplierAccount", + Keys: bson.D{{"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjID", + Keys: bson.D{{"bk_obj_id", 1}}, + Unique: true, + Background: false, + PartialFilterExpression: map[string]interface{}{"bk_obj_id": map[string]string{common.BKDBType: "string"}}, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkObjName", + Keys: bson.D{{"bk_obj_name", 1}}, + Unique: true, + Background: false, + PartialFilterExpression: map[string]interface{}{"bk_obj_name": map[string]string{common.BKDBType: "string"}}, + }, + } + KubeDelArchiveIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "coll_oid", + Keys: bson.D{{"coll", 1}, {"oid", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "coll", + Keys: bson.D{{"coll", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "oid", + Keys: bson.D{{"oid", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "time", + Keys: bson.D{{"time", -1}}, + Background: true, + ExpireAfterSeconds: 2 * 24 * 60 * 60, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ServiceTemplateIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkBizID", + Keys: bson.D{{"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkBizID_name", + Keys: bson.D{{"bk_biz_id", 1}, {"name", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "ID_bkBizID", + Keys: bson.D{{"id", 1}, {"bk_biz_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ObjClassificationIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkClassificationID", + Keys: bson.D{{"bk_classification_id", 1}}, + Unique: true, + Background: false, + PartialFilterExpression: map[string]interface{}{"bk_classification_id": map[string]string{common.BKDBType: "string"}}, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkClassificationName", + Keys: bson.D{{"bk_classification_name", 1}}, + Unique: true, + Background: false, + PartialFilterExpression: map[string]interface{}{"bk_classification_name": map[string]string{common.BKDBType: "string"}}, + }, + } + ObjFieldTemplateRelationIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkTemplateID_objectID", + Keys: bson.D{{"bk_template_id", 1}, {"object_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "objectID_bkSupplierAccount", + Keys: bson.D{{"object_id", 1}, {"bk_supplier_account", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + NamespaceBaseIndexes = []types.Index{ + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{ + {"id", 1}, + }, + Background: true, + Unique: true, + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkClusterID_name", + Keys: bson.D{ + {"bk_cluster_id", 1}, + {"name", 1}, + }, + Background: true, + Unique: true, + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterUID_bkSupplierAccount", + Keys: bson.D{ + {"cluster_uid", 1}, + {"bk_supplier_account", 1}, + }, + Background: true, + }, + { + Name: common.CCLogicIndexNamePrefix + "clusterID_bkSupplierAccount", + Keys: bson.D{ + {"bk_cluster_id", 1}, + {"bk_supplier_account", 1}, + }, + Background: true, + }, + { + Name: common.CCLogicIndexNamePrefix + "name_bkSupplierAccount", + Keys: bson.D{ + {"name", 1}, + {"bk_supplier_account", 1}, + }, + Background: true, + }, + } + BizInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + ModuleInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + processInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + setInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + platInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + bkProjectInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + hostInstanceIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } + bkBizSetObjInstIndexes = []types.Index{ + { + Name: common.CCLogicIndexNamePrefix + "bkObjID_bkInstID", + Keys: bson.D{{"bk_obj_id", 1}, {"bk_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "ID", + Keys: bson.D{{"id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstObjID_bkAsstInstID", + Keys: bson.D{{"bk_asst_obj_id", 1}, {"bk_asst_inst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicIndexNamePrefix + "bkAsstID", + Keys: bson.D{{"bk_asst_id", 1}}, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + { + Name: common.CCLogicUniqueIdxNamePrefix + "bkInstID_bkAsstInstID_bkObjAsstID", + Keys: bson.D{{"bk_inst_id", 1}, {"bk_asst_inst_id", 1}, {"bk_obj_asst_id", 1}}, + Unique: true, + Background: true, + PartialFilterExpression: make(map[string]interface{}), + }, + } +) diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/initdata.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/initdata.go new file mode 100644 index 0000000000..4e1d9dc840 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/initdata.go @@ -0,0 +1,35 @@ +package y3_15_202411071530 + +import ( + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/y3.15.202411071530/data" + "configcenter/src/storage/dal" +) + +var tableDataArr = []func(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error{ + data.AddSystemData, + data.AddServiceCategotyData, + data.AddApplicationData, + data.AddAssociationType, + data.AddDefaultBusinessSetData, + data.AddObjAssociationData, + data.AddObjClassificationData, + data.AddBizSetObjectRow, + data.AddUnassignedCloudArea, + data.AddPropertyGroupData, + data.AddObjAttrData, + data.AddObjectUniqueData, + data.AddSelfIncrIDData, +} + +func InitData(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + for _, dataInitor := range tableDataArr { + if err := dataInitor(kit, db, conf); err != nil { + blog.Errorf("init data for table failed, err: %v", err) + return err + } + } + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/pkg.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/pkg.go new file mode 100644 index 0000000000..cb2fda07f4 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/pkg.go @@ -0,0 +1,31 @@ +package y3_15_202411071530 + +import ( + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/storage/dal" +) + +func init() { + upgrader.RegisterUpgrade("y3.15.202411071530", upgrade) +} + +func upgrade(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + if err := initTableIndex(kit, db, tableIndexMap, conf); err != nil { + blog.Errorf("[upgrade y3.15.202411071530] initTableIndex error %v", err) + return err + } + + if err := initTableIndex(upgrader.GetBlueKingKit(), db, tableIndexMap, conf); err != nil { + blog.Errorf("[upgrade y3.15.202411071530] initTableIndex error %v", err) + return err + } + + if err := InitData(kit, db, conf); err != nil { + blog.Errorf("[upgrade y3.15.202411071530] InitData error %v", err) + return err + } + + return nil +} diff --git a/src/scene_server/admin_server/upgrader/y3.15.202411071530/tableIndexMap.go b/src/scene_server/admin_server/upgrader/y3.15.202411071530/tableIndexMap.go new file mode 100644 index 0000000000..e1f3500479 --- /dev/null +++ b/src/scene_server/admin_server/upgrader/y3.15.202411071530/tableIndexMap.go @@ -0,0 +1,144 @@ +package y3_15_202411071530 + +import ( + "fmt" + + fullsynccond "configcenter/pkg/cache/full-sync-cond" + "configcenter/src/common" + "configcenter/src/common/blog" + "configcenter/src/common/http/rest" + "configcenter/src/kube/types" + "configcenter/src/scene_server/admin_server/upgrader" + "configcenter/src/scene_server/admin_server/upgrader/tools" + "configcenter/src/storage/dal" + daltypes "configcenter/src/storage/dal/types" +) + +var tableIndexMap = map[string][]daltypes.Index{ + common.BKTableNameAPITask: APITaskIndexes, + common.BKTableNameAPITaskSyncHistory: APITaskSyncHistoryIndexes, + common.BKTableNameBaseApp: ApplicationBaseIndexes, + common.BKTableNameAsstDes: AsstDesIndexes, + common.BKTableNameAuditLog: AuditLogIndexes, + common.BKTableNameBaseBizSet: BizSetBaseIndexes, + common.BKTableNamePropertyGroup: PropertyGroupIndexes, + common.BKTableNameObjDes: ObjDesIndexes, + common.BKTableNameObjUnique: ObjectUniqueIndexes, + common.BKTableNameObjAttDes: ObjAttDesIndexes, + common.BKTableNameObjClassification: ObjClassificationIndexes, + common.BKTableNameInstAsst: InstAsstIndexes, + common.BKTableNameModelQuoteRelation: ModelQuoteRelationIndexes, + common.BKTableNameBaseProject: ProjectBaseIndexes, + common.BKTableNameBaseHost: HostBaseIndexes, + common.BKTableNameBaseModule: ModuleBaseIndexes, + common.BKTableNameBaseInst: ObjectBaseIndexes, + common.BKTableNameBasePlat: PlatBaseIndexes, + common.BKTableNameBaseSet: SetBaseIndexes, + common.BKTableNameBaseProcess: ProcessIndexes, + common.BKTableNameDelArchive: DelArchiveIndexes, + common.BKTableNameKubeDelArchive: KubeDelArchiveIndexes, + common.BKTableNameModuleHostConfig: ModuleHostConfigIndexes, + common.BKTableNameHostFavorite: nil, + common.BKTableNameUserAPI: nil, + common.BKTableNameDynamicGroup: DynamicGroupIndexes, + common.BKTableNameUserCustom: nil, + common.BKTableNameObjAsst: ObjAsstIndexes, + common.BKTableNameTopoGraphics: TopoGraphicsIndexes, + common.BKTableNameHostLock: HostLockIndexes, + common.BKTableNameServiceCategory: ServiceCategoryIndexes, + common.BKTableNameServiceTemplate: ServiceTemplateIndexes, + common.BKTableNameServiceTemplateAttr: ServiceTemplateAttrIndexes, + common.BKTableNameServiceInstance: ServiceInstanceIndexes, + common.BKTableNameProcessTemplate: ProcessTemplateIndexes, + common.BKTableNameProcessInstanceRelation: ProcessInstanceRelationIndexes, + common.BKTableNameSetTemplate: SetTemplateIndexes, + common.BKTableNameSetTemplateAttr: SetTemplateAttrIndexes, + common.BKTableNameSetServiceTemplateRelation: SetServiceTemplateRelationIndexes, + common.BKTableNameHostApplyRule: HostApplyRuleIndexes, + common.BKTableNameFieldTemplate: FieldTemplateIndexes, + common.BKTableNameObjAttDesTemplate: ObjAttDesTemplateIndexes, + common.BKTableNameObjectUniqueTemplate: ObjectUniqueTemplateIndexes, + common.BKTableNameObjFieldTemplateRelation: ObjFieldTemplateRelationIndexes, + types.BKTableNameBaseCluster: ClusterBaseIndexes, + types.BKTableNameBaseContainer: ContainerBaseIndexes, + types.BKTableNameBaseCronJob: CronJobBaseIndexes, + types.BKTableNameBaseDaemonSet: DaemonSetBaseIndexes, + types.BKTableNameBaseDeployment: DeploymentBaseIndexes, + fullsynccond.BKTableNameFullSyncCond: FullSyncCondIndexes, + types.BKTableNameGameDeployment: GameDeploymentBaseIndexes, + types.BKTableNameGameStatefulSet: GameStatefulSetBaseIndexes, + types.BKTableNameBaseJob: JobBaseIndexes, + types.BKTableNameBaseStatefulSet: StatefulSetBaseIndexes, + types.BKTableNameNsSharedClusterRel: NsSharedClusterRelationIndexes, + types.BKTableNameBasePodWorkload: PodWorkloadBaseIndexes, + types.BKTableNameBaseNode: NodeBaseIndexes, + types.BKTableNameBasePod: PodBaseIndexes, + types.BKTableNameBaseNamespace: NamespaceBaseIndexes, + "cc_ObjectBaseMapping": ObjectBaseMappingIndexes, +} + +var platTableIndexesMap = map[string][]daltypes.Index{ + common.BKTableNameSystem: nil, + common.BKTableNameIDgenerator: nil, + common.BKTableNameWatchToken: nil, +} + +var tableInstAsstIndexesMap = map[string][]daltypes.Index{ + "biz": BizInstanceIndexes, + "module": ModuleInstanceIndexes, + "process": processInstanceIndexes, + "host": hostInstanceIndexes, + "bk_project": bkProjectInstanceIndexes, + "bk_biz_set_obj": bkBizSetObjInstIndexes, + "plat": platInstanceIndexes, + "set": setInstanceIndexes, +} + +func initTableIndex(kit *rest.Kit, db dal.Dal, tableIndexMap map[string][]daltypes.Index, + conf *upgrader.Config) error { + + for table, index := range tableIndexMap { + if err := tools.CreateTable(kit, db, table); err != nil { + return err + } + + if err := tools.CreateIndexes(kit, db, table, index); err != nil { + return err + } + } + + for table, _ := range platTableIndexesMap { + if err := tools.CreatePlatTable(kit, db, table); err != nil { + fmt.Errorf("create plat table failed, err: %v", err) + return err + } + } + + if err := createInstAsstTable(kit, db, conf); err != nil { + fmt.Errorf("create instance table failed, err: %v", err) + return err + } + + return nil +} + +func buildInstAsstTableName(objID, tenantID interface{}) string { + return fmt.Sprintf("cc_InstAsst_%v_pub_%v", tenantID, objID) +} + +func createInstAsstTable(kit *rest.Kit, db dal.Dal, conf *upgrader.Config) error { + for obj, index := range tableInstAsstIndexesMap { + tableName := buildInstAsstTableName(obj, kit.TenantID) + if err := tools.CreateTable(kit, db, tableName); err != nil { + blog.Errorf("create table %s failed, err: %v", tableName, err) + return err + } + + if err := tools.CreateIndexes(kit, db, tableName, index); err != nil { + return err + } + + } + + return nil +} diff --git a/src/source_controller/coreservice/core/model/attribute_curd.go b/src/source_controller/coreservice/core/model/attribute_curd.go index 3637dec5fa..3a33ee2f14 100644 --- a/src/source_controller/coreservice/core/model/attribute_curd.go +++ b/src/source_controller/coreservice/core/model/attribute_curd.go @@ -749,7 +749,6 @@ func (m *modelAttribute) search(kit *rest.Kit, cond universalsql.Condition) (res func (m *modelAttribute) searchWithSort(kit *rest.Kit, cond metadata.QueryCondition) (resultAttrs []metadata.Attribute, err error) { resultAttrs = []metadata.Attribute{} - instHandler := mongodb.Client().Table(common.BKTableNameObjAttDes).Find(cond.Condition) err = instHandler.Start(uint64(cond.Page.Start)).Limit(uint64(cond.Page.Limit)).Sort(cond.Page.Sort).All(kit.Ctx, &resultAttrs) @@ -1753,7 +1752,7 @@ func (m *modelAttribute) getLangObjID(kit *rest.Kit, objID string) string { return langObjID } -// GetAttrLastIndex TODO +// GetAttrLastIndex 获取属性的最后一个计数索引 func (m *modelAttribute) GetAttrLastIndex(kit *rest.Kit, attribute metadata.Attribute) (int64, error) { opt := make(map[string]interface{}) opt[common.BKObjIDField] = attribute.ObjectID