Skip to content

Commit

Permalink
[INLONG-10096][Manager] Auto get secretKey by operator
Browse files Browse the repository at this point in the history
  • Loading branch information
fuweng11 committed May 13, 2024
1 parent e01847b commit f3fb411
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,6 @@ public class AgentClusterDTO {
@ApiModelProperty(value = "Version number of the server list collected by the cluster")
private Integer serverVersion;

@ApiModelProperty(value = "Auth secret id")
private String authSecretId;

@ApiModelProperty(value = "Auth secret key")
private String authSecretKey;

/**
* Get the dto instance from the request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ public class AgentClusterInfo extends ClusterInfo {
@ApiModelProperty(value = "Version number of the server list collected by the cluster")
private Integer serverVersion;

@ApiModelProperty(value = "Auth secret id")
private String authSecretId;

@ApiModelProperty(value = "Auth secret key")
private String authSecretKey;

public AgentClusterInfo() {
this.setType(ClusterType.AGENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,6 @@ public class AgentClusterRequest extends ClusterRequest {
@ApiModelProperty(value = "Version number of the server list collected by the cluster")
private Integer serverVersion = 1;

@ApiModelProperty(value = "Auth secret id")
private Integer authSecretId;

@ApiModelProperty(value = "Auth secret key")
private Integer authSecretKey;

public AgentClusterRequest() {
this.setType(ClusterType.AGENT);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@
import org.apache.inlong.manager.common.enums.ClusterType;
import org.apache.inlong.manager.common.enums.ModuleType;
import org.apache.inlong.manager.common.exceptions.BusinessException;
import org.apache.inlong.manager.common.util.AESUtils;
import org.apache.inlong.manager.common.util.Preconditions;
import org.apache.inlong.manager.dao.entity.InlongClusterEntity;
import org.apache.inlong.manager.dao.entity.InlongClusterNodeEntity;
import org.apache.inlong.manager.dao.entity.ModuleConfigEntity;
import org.apache.inlong.manager.dao.entity.PackageConfigEntity;
import org.apache.inlong.manager.dao.entity.UserEntity;
import org.apache.inlong.manager.dao.mapper.InlongClusterEntityMapper;
import org.apache.inlong.manager.dao.mapper.ModuleConfigEntityMapper;
import org.apache.inlong.manager.dao.mapper.PackageConfigEntityMapper;
import org.apache.inlong.manager.dao.mapper.UserEntityMapper;
import org.apache.inlong.manager.pojo.cluster.ClusterNodeRequest;
import org.apache.inlong.manager.pojo.cluster.agent.AgentClusterDTO;
import org.apache.inlong.manager.pojo.cluster.agent.AgentClusterNodeRequest;
Expand Down Expand Up @@ -56,12 +60,14 @@ public class AgentClusterNodeInstallOperator implements InlongClusterNodeInstall
private ModuleConfigEntityMapper moduleConfigEntityMapper;
@Autowired
private PackageConfigEntityMapper packageConfigEntityMapper;
@Autowired
private UserEntityMapper userEntityMapper;

@Value("${audit.proxy.url}")
@Value("${metrics.audit.proxy.hosts:127.0.0.1:10081}")
private String auditProxyUrl;
@Value("${agent.install.path}")
@Value("${agent.install.path:inlong/inlong-installer/}")
private String agentInstallPath;
@Value("${manager.url}")
@Value("${manager.url:127.0.0.1:8083}")
private String managerUrl;

@Override
Expand Down Expand Up @@ -90,11 +96,15 @@ public boolean install(ClusterNodeRequest clusterNodeRequest, String operator) {
Map<String, String> configMap = new HashMap<>();
configMap.put("agent.local.ip", request.getIp());
configMap.put("agent.manager.addr", managerUrl);
configMap.put("agent.manager.auth.secretId", agentClusterDTO.getAuthSecretId());
configMap.put("agent.manager.auth.secretKey", agentClusterDTO.getAuthSecretKey());
UserEntity userInfo = userEntityMapper.selectByName(operator);
Preconditions.expectNotNull(userInfo, "User doesn't exist");
String secretKey =
new String(AESUtils.decryptAsString(userInfo.getSecretKey(), userInfo.getEncryptVersion()));
configMap.put("agent.manager.auth.secretId", operator);
configMap.put("agent.manager.auth.secretKey", secretKey);
configMap.put("agent.cluster.tag", clusterEntity.getClusterTags());
configMap.put("agent.cluster.name", clusterEntity.getName());
configMap.put("agent.proxys", auditProxyUrl);
configMap.put("audit.proxys", auditProxyUrl);
commandExecutor.modifyConfig(request, configMap, confFile);
String startCmd = agentInstallPath + "bin/installer.sh start";
commandExecutor.execRemote(request, startCmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public CommandResult exec(String cmd) throws Exception {
public CommandResult execRemote(AgentClusterNodeRequest clusterNodeRequest, String cmd) throws Exception {
String cmdShell = "./conf/exec_cmd.exp";
String ip = clusterNodeRequest.getIp();
String port = String.valueOf(clusterNodeRequest.getPort());
String port = String.valueOf(clusterNodeRequest.getSshPort());
String user = clusterNodeRequest.getUsername();
String password = clusterNodeRequest.getPassword();
String remoteCommandTimeout = "20000";
Expand Down Expand Up @@ -124,7 +124,7 @@ public CommandResult tarPackage(AgentClusterNodeRequest clusterNodeRequest, Stri
@Override
public CommandResult downLoadPackage(AgentClusterNodeRequest clusterNodeRequest, String downLoadPath,
String downLoadUrl) throws Exception {
return execRemote(clusterNodeRequest, "wget -P " + downLoadPath + downLoadUrl);
return execRemote(clusterNodeRequest, "wget -P " + downLoadPath + InlongConstants.BLANK + downLoadUrl);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearc
audit.query.source=MYSQL
# Audit service url to query data
audit.query.url=http://127.0.0.1:10080
# Audit proxy url
audit.proxy.url=http://127.0.0.1:10080

# Database clean
# If turned on, logically deleted data will be collected and permanently deleted periodically
Expand Down Expand Up @@ -106,3 +104,4 @@ cls.manager.endpoint=127.0.0.1
module.name.map={'inlong-agent':1,'agent-installer':2,'temp-cmd':3}

manager.url=127.0.0.1:8083
agent.install.path=
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearc
audit.query.source=MYSQL
# Audit service url to query data
audit.query.url=http://127.0.0.1:10080
# Audit proxy url
audit.proxy.url=http://127.0.0.1:10080

# Database clean
# If turned on, logically deleted data will be collected and permanently deleted periodically
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.elasticsearc
audit.query.source=MYSQL
# Audit service url to query data
audit.query.url=http://127.0.0.1:10080
# Audit proxy url
audit.proxy.url=http://127.0.0.1:10080

# Database clean
# If turned on, logically deleted data will be collected and permanently deleted periodically
Expand Down

0 comments on commit f3fb411

Please sign in to comment.