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

Feat/bug fix config history rollback missing type #8800

Open
wants to merge 4 commits into
base: develop
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public class ConfigHistoryInfo implements Serializable {

private String encryptedDataKey;

private String type;

public long getId() {
return id;
}
Expand Down Expand Up @@ -174,4 +176,12 @@ public String getEncryptedDataKey() {
public void setEncryptedDataKey(String encryptedDataKey) {
this.encryptedDataKey = encryptedDataKey;
}

public String getType() {
return type;
}

public void setType(String type) {
this.type = type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,7 @@ public ConfigHistoryInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
configHistoryInfo.setOpType(rs.getString("op_type"));
configHistoryInfo.setCreatedTime(rs.getTimestamp("gmt_create"));
configHistoryInfo.setLastModifiedTime(rs.getTimestamp("gmt_modified"));
configHistoryInfo.setType(rs.getString("type"));
try {
configHistoryInfo.setEncryptedDataKey(rs.getString("encrypted_data_key"));
} catch (SQLException ignore) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2181,10 +2181,9 @@ public void insertConfigHistoryAtomic(long configHistoryId, ConfigInfo configInf
: configInfo.getEncryptedDataKey();

final String sql = "INSERT INTO his_config_info (id,data_id,group_id,tenant_id,app_name,content,md5,"
+ "src_ip,src_user,gmt_modified,op_type,encrypted_data_key) VALUES(?,?,?,?,?,?,?,?,?,?,?,?)";
+ "src_ip,src_user,gmt_modified,op_type,encrypted_data_key,type) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)";
final Object[] args = new Object[] {configHistoryId, configInfo.getDataId(), configInfo.getGroup(), tenantTmp,
appNameTmp, configInfo.getContent(), md5Tmp, srcIp, srcUser, time, ops, encryptedDataKey};

appNameTmp, configInfo.getContent(), md5Tmp, srcIp, srcUser, time, ops, encryptedDataKey, configInfo.getType()};
EmbeddedStorageContextUtils.addSqlContext(sql, args);
}

Expand Down Expand Up @@ -2235,7 +2234,7 @@ public void updateConfigSubAtomic(final String dataId, final String group, final

@Override
public ConfigHistoryInfo detailConfigHistory(Long nid) {
String sqlFetchRows = "SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified,encrypted_data_key FROM his_config_info WHERE nid = ?";
String sqlFetchRows = "SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified,encrypted_data_key,type FROM his_config_info WHERE nid = ?";
return databaseOperate.queryOne(sqlFetchRows, new Object[] {nid}, HISTORY_DETAIL_ROW_MAPPER);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2382,10 +2382,10 @@ public void insertConfigHistoryAtomic(long id, ConfigInfo configInfo, String src

try {
jt.update(
"INSERT INTO his_config_info (id,data_id,group_id,tenant_id,app_name,content,md5,src_ip,src_user,gmt_modified,op_type,encrypted_data_key) "
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?)", id, configInfo.getDataId(), configInfo.getGroup(),
"INSERT INTO his_config_info (id,data_id,group_id,tenant_id,app_name,content,md5,src_ip,src_user,gmt_modified,op_type,encrypted_data_key,`type`) "
+ "VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)", id, configInfo.getDataId(), configInfo.getGroup(),
tenantTmp, appNameTmp, configInfo.getContent(), md5Tmp, srcIp, srcUser, time, ops,
encryptedDataKey);
encryptedDataKey, configInfo.getType());
} catch (DataAccessException e) {
LogUtil.FATAL_LOG.error("[db-error] " + e.toString(), e);
throw e;
Expand Down Expand Up @@ -2445,7 +2445,7 @@ public void updateConfigSubAtomic(final String dataId, final String group, final

@Override
public ConfigHistoryInfo detailConfigHistory(Long nid) {
String sqlFetchRows = "SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified,encrypted_data_key FROM his_config_info WHERE nid = ?";
String sqlFetchRows = "SELECT nid,data_id,group_id,tenant_id,app_name,content,md5,src_user,src_ip,op_type,gmt_create,gmt_modified,encrypted_data_key,`type` FROM his_config_info WHERE nid = ?";
try {
ConfigHistoryInfo historyInfo = jt
.queryForObject(sqlFetchRows, new Object[] {nid}, HISTORY_DETAIL_ROW_MAPPER);
Expand Down
1 change: 1 addition & 0 deletions config/src/main/resources/META-INF/nacos-db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ CREATE TABLE `his_config_info` (
`op_type` char(10) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
`encrypted_data_key` text NOT NULL COMMENT '秘钥',
`type` varchar(64) DEFAULT NULL,
PRIMARY KEY (`nid`),
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`),
Expand Down
1 change: 1 addition & 0 deletions config/src/main/resources/META-INF/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CREATE TABLE his_config_info (
src_ip varchar(20) DEFAULT NULL,
op_type char(10) DEFAULT NULL,
encrypted_data_key LONG VARCHAR DEFAULT NULL,
type varchar(64) DEFAULT NULL,
constraint hisconfiginfo_nid_key PRIMARY KEY (nid));

CREATE INDEX hisconfiginfo_dataid_key_idx ON his_config_info(data_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class ConfigRollback extends React.Component {
this.group = getParams('group') || 'DEFAULT_GROUP';
this.serverId = getParams('serverId') || 'center';
this.nid = getParams('nid') || '';
this.type = getParams('type') || '';
this.state = {
envName: '',
visible: false,
Expand Down Expand Up @@ -90,6 +91,7 @@ class ConfigRollback extends React.Component {
self.opType = data.opType; // 当前回滚类型I:插入,D:删除,U:'更新'
self.field.setValue('group', data.group);
self.field.setValue('md5', data.md5);
self.field.setValue('type', data.type);
self.field.setValue('envName', envName);
self.setState({
envName,
Expand Down Expand Up @@ -138,12 +140,14 @@ class ConfigRollback extends React.Component {
self.serverId = getParams('serverId') || 'center';
self.dataId = self.field.getValue('dataId');
self.group = self.field.getValue('group');
self.type = self.field.getValue('type');
let postData = {
appName: self.field.getValue('appName'),
dataId: self.dataId,
group: self.group,
content: self.field.getValue('content'),
tenant: self.tenant,
type: self.type,
};

let url = 'v1/cs/configs';
Expand Down
1 change: 1 addition & 0 deletions console/src/main/resources/META-INF/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CREATE TABLE his_config_info (
src_ip varchar(20) DEFAULT NULL,
op_type char(10) DEFAULT NULL,
encrypted_data_key LONG VARCHAR DEFAULT NULL,
type varchar(64) DEFAULT NULL,
constraint hisconfiginfo_nid_key PRIMARY KEY (nid));

CREATE INDEX hisconfiginfo_dataid_key_idx ON his_config_info(data_id);
Expand Down
4 changes: 2 additions & 2 deletions console/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<link rel="stylesheet" type="text/css" href="console-ui/public/css/icon.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/font-awesome.css">
<!-- 第三方css结束 -->
<link href="./css/main.css?63e21d02ece6640bf812" rel="stylesheet"></head>
<link href="./css/main.css?e818fd1c5dafc49d09b5" rel="stylesheet"></head>

<body>
<div id="root" style="overflow:hidden"></div>
Expand All @@ -56,6 +56,6 @@
<script src="console-ui/public/js/merge.js"></script>
<script src="console-ui/public/js/loader.js"></script>
<!-- 第三方js结束 -->
<script type="text/javascript" src="./js/main.js?63e21d02ece6640bf812"></script></body>
<script type="text/javascript" src="./js/main.js?e818fd1c5dafc49d09b5"></script></body>

</html>
22 changes: 11 additions & 11 deletions console/src/main/resources/static/js/main.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions distribution/conf/nacos-mysql.sql
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ CREATE TABLE `his_config_info` (
`op_type` char(10) DEFAULT NULL,
`tenant_id` varchar(128) DEFAULT '' COMMENT '租户字段',
`encrypted_data_key` text NOT NULL COMMENT '秘钥',
`type` varchar(64) DEFAULT NULL,
PRIMARY KEY (`nid`),
KEY `idx_gmt_create` (`gmt_create`),
KEY `idx_gmt_modified` (`gmt_modified`),
Expand Down
1 change: 1 addition & 0 deletions distribution/conf/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ CREATE TABLE his_config_info (
src_ip varchar(50) DEFAULT NULL,
op_type char(10) DEFAULT NULL,
encrypted_data_key LONG VARCHAR DEFAULT NULL,
type varchar(64) DEFAULT NULL,
constraint hisconfiginfo_nid_key PRIMARY KEY (nid));

CREATE INDEX hisconfiginfo_dataid_key_idx ON his_config_info(data_id);
Expand Down