Skip to content

Commit

Permalink
fix: 修复读取k8s大整型变成浮点数问题及单测修复 (closed TencentBlueKing#2521)
Browse files Browse the repository at this point in the history
  • Loading branch information
Huayeaaa committed Dec 23, 2024
1 parent 089d033 commit 2b9ce86
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def get_need_clean_subscription_app_code():

@periodic_task(run_every=constants.UPDATE_SUBSCRIPTION_TASK_INTERVAL, queue="backend", options={"queue": "backend"})
def schedule_update_subscription():
logger.info("start schedule update subscription")
name: str = constants.UPDATE_SUBSCRIPTION_REDIS_KEY_TPL
# 取出该hashset中所有的参数
update_params: Dict[str, bytes] = REDIS_INST.hgetall(name=name)
Expand All @@ -59,6 +60,7 @@ def schedule_update_subscription():

@periodic_task(run_every=constants.UPDATE_SUBSCRIPTION_TASK_INTERVAL, queue="backend", options={"queue": "backend"})
def schedule_run_subscription():
logger.info("start schedule run subscription")
name: str = constants.RUN_SUBSCRIPTION_REDIS_KEY_TPL
length: int = min(REDIS_INST.llen(name), constants.MAX_RUN_SUBSCRIPTION_TASK_COUNT)
run_params: List[bytes] = REDIS_INST.lrange(name, -length, -1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ def test_shell_solution(self):
f"-l http://127.0.0.1/download -r http://127.0.0.1/backend -L {self.DOWNLOAD_PATH}"
f" -c {solution_parse_result['params']['token']} -s {mock_data_utils.JOB_TASK_PIPELINE_ID}"
f" -HNT PAGENT -HIIP {host.inner_ip}"
f" -HC {self.CLOUD_ID} -HOT {host.os_type.lower()} -HI '{host.identity.password}'"
f" -HC {self.CLOUD_ID} -HOT {host.os_type.lower()} --host-identity='{host.identity.password}'"
f" -HP {host.identity.port} -HAT {host.identity.auth_type}"
f" -HA {host.identity.account} -HLIP {host.inner_ip}"
f" -HDD '{installation_tool.dest_dir}' -HPP '17981' -I 1.1.1.1"
Expand Down Expand Up @@ -826,7 +826,8 @@ def test_gen_install_channel_agent_command(self):
f"-l http://1.1.1.1:17980/ -r http://127.0.0.1/backend -L {self.DOWNLOAD_PATH}"
f" -c {solution_parse_result['params']['token']} -s {mock_data_utils.JOB_TASK_PIPELINE_ID}"
f" -HNT AGENT -HIIP {host.inner_ip}"
f" -HC 0 -HOT linux -HI 'password' -HP 22 -HAT {host.identity.auth_type} -HA root -HLIP {host.inner_ip}"
f" -HC 0 -HOT linux --host-identity='password' -HP 22 "
f"-HAT {host.identity.auth_type} -HA root -HLIP {host.inner_ip}"
f" -HDD '/tmp/' -HPP '17981' -I 1.1.1.1 -CPA 'http://127.0.0.1:17981'"
f" -HSJB {solution_parse_result['params']['host_solutions_json_b64']}"
],
Expand Down
2 changes: 1 addition & 1 deletion apps/node_man/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class TimeUnit:
DEFAULT_CLOUD = int(os.environ.get("DEFAULT_CLOUD", 0))
DEFAULT_CLOUD_NAME = os.environ.get("DEFAULT_CLOUD_NAME", _("直连区域"))
# 未分配管控区域ID
UNASSIGNED_CLOUD_ID = int(os.environ.get("BKAPP_UNASSIGNED_CLOUD_ID", 90000001))
UNASSIGNED_CLOUD_ID = int(float(os.environ.get("BKAPP_UNASSIGNED_CLOUD_ID", 90000001)))
# 自动选择接入点ID
DEFAULT_AP_ID = int(os.environ.get("DEFAULT_AP_ID", -1))
# 自动选择安装通道ID
Expand Down
3 changes: 2 additions & 1 deletion env/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@
)
BKAPP_DEFAULT_INSTALL_CHANNEL_ID = get_type_env(key="BKAPP_DEFAULT_INSTALL_CHANNEL_ID", default=-1, _type=int)
BKAPP_AUTOMATIC_CHOICE_CLOUD_ID = get_type_env(key="BKAPP_AUTOMATIC_CHOICE_CLOUD_ID", default=-1, _type=int)
BKAPP_UNASSIGNED_CLOUD_ID = get_type_env(key="BKAPP_UNASSIGNED_CLOUD_ID", default=90000001, _type=int)
# 适配从k8s读取值变成科学计数法问题
BKAPP_UNASSIGNED_CLOUD_ID = int(get_type_env(key="BKAPP_UNASSIGNED_CLOUD_ID", default=90000001, _type=float))

# ===============================================================================
# 日志
Expand Down

0 comments on commit 2b9ce86

Please sign in to comment.