Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

华为云容器动态化部署时,admin服务出现历史日志无法查询问题修改 #3505

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.xxl.job.admin.controller;

import com.xxl.job.admin.core.complete.XxlJobCompleter;
import com.xxl.job.admin.core.entity.ExecutorAddressStatic;
import com.xxl.job.admin.core.exception.XxlJobException;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobInfo;
Expand Down Expand Up @@ -146,7 +147,10 @@ public ReturnT<LogResult> logDetailCat(long logId, int fromLineNum){
}

// log cat
ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(jobLog.getExecutorAddress());
//场景:docker容器化动态部署。容器中日志存储路径挂载于宿主机,且容器当重启执行器服务时,会动态化更换随机容器,执行器ip会变更,自动获取的ip为当前执行器的docker实例ip(192.*.*.*网段)
// 。容器互通,但容器无法访问其他容器的192网段地址,此处查询数据库日志表执行器字段,会出现历史日志无法访问的问题。所以在此,将访问地址替换为执行器传过来的执行地址。
logger.info("==============>logDetailCat执行器地址为: " + ExecutorAddressStatic.executorAddress);
ExecutorBiz executorBiz = XxlJobScheduler.getExecutorBiz(ExecutorAddressStatic.executorAddress);
ReturnT<LogResult> logResult = executorBiz.log(new LogParam(jobLog.getTriggerTime().getTime(), logId, fromLineNum));

// is end
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.xxl.job.admin.core.entity;

public class ExecutorAddressStatic {

public static String executorAddress;

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.xxl.job.admin.core.thread;

import com.xxl.job.admin.core.conf.XxlJobAdminConfig;
import com.xxl.job.admin.core.entity.ExecutorAddressStatic;
import com.xxl.job.admin.core.model.XxlJobGroup;
import com.xxl.job.admin.core.model.XxlJobRegistry;
import com.xxl.job.core.biz.model.RegistryParam;
Expand Down Expand Up @@ -166,6 +167,8 @@ public void run() {
// fresh
freshGroupRegistryInfo(registryParam);
}
ExecutorAddressStatic.executorAddress = registryParam.getRegistryValue();
logger.info("=============>registry执行日志注册地址为:" + ExecutorAddressStatic.executorAddress);
}
});

Expand Down