minor fix

This commit is contained in:
Mengyi Zhou 2016-12-08 10:38:25 +08:00
parent 6a79d06b61
commit b2cc964861
4 changed files with 151 additions and 23 deletions

View file

@ -146,7 +146,7 @@ public class CertificateResource {
}
List<String> installingIps = null;
boolean greyscaledRequired = (greyscale != null && greyscale) || greyscaleIps != null;
boolean greyscaledRequired = (greyscale != null && greyscale) || (greyscaleIps != null && greyscaleIps.size() > 0);
if (greyscaledRequired) {
if (greyscale == null) {
throw new ValidationException("Query param greyscale=true is required for greyscale upgrading certificate.");

View file

@ -49,11 +49,6 @@ public class NginxResource {
if (key.length == 0) {
throw new ValidationException("Cannot find activated version of vs-" + vsId + ".");
}
VirtualServer vs = virtualServerRepository.getByKey(key[0]);
// Deprecated field slb-id
if (!vs.getSlbIds().contains(slbId) && !vs.getSlbId().equals(slbId)) {
throw new ValidationException("Activated version of vs-" + vsId + " is not related to slb-" + slbId + ".");
}
int version;
if (null == versionNum || versionNum <= 0) {

View file

@ -488,6 +488,25 @@ CREATE TABLE IF NOT EXISTS `group_slb` (
-- Data exporting was unselected.
-- Dumping structure for table message_queue
DROP TABLE IF EXISTS `message_queue`;
CREATE TABLE IF NOT EXISTS `message_queue` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`performer` varchar(128) DEFAULT NULL COMMENT 'p',
`type` varchar(128) NOT NULL DEFAULT 'unknown' COMMENT 'type',
`target_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'tid',
`target_data` varchar(2048) NOT NULL DEFAULT '0' COMMENT 'td',
`status` varchar(128) NOT NULL DEFAULT 'unknow' COMMENT 'status',
`create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'ct',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'dt',
PRIMARY KEY (`id`),
KEY `DataChange_LastTime` (`DataChange_LastTime`),
KEY `status_create_time` (`status`,`create_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='message_queue';
-- Data exporting was unselected.
-- Dumping structure for table nginx_conf
DROP TABLE IF EXISTS `nginx_conf`;
CREATE TABLE IF NOT EXISTS `nginx_conf` (
@ -529,9 +548,9 @@ CREATE TABLE IF NOT EXISTS `nginx_conf_server` (
DROP TABLE IF EXISTS `nginx_conf_slb`;
CREATE TABLE IF NOT EXISTS `nginx_conf_slb` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`slb_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'slb id',
`version` bigint(20) NOT NULL DEFAULT '0' COMMENT 'slb conf version',
`content` mediumtext NOT NULL COMMENT 'conf content',
`slb_id` bigint(20) NOT NULL COMMENT 'slb id',
`version` bigint(20) NOT NULL COMMENT 'slb conf version',
`content` mediumblob NOT NULL COMMENT 'conf content',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last time modified',
PRIMARY KEY (`id`),
UNIQUE KEY `slb_id_version` (`slb_id`,`version`),
@ -663,6 +682,55 @@ CREATE TABLE IF NOT EXISTS `report` (
-- Data exporting was unselected.
-- Dumping structure for table report_queue
DROP TABLE IF EXISTS `report_queue`;
CREATE TABLE IF NOT EXISTS `report_queue` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`target_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'target id',
`topic` int(11) NOT NULL DEFAULT '-1' COMMENT 'topic group',
`state` bit(1) NOT NULL DEFAULT b'0' COMMENT 'result',
`description` varchar(255) DEFAULT '0' COMMENT 'description',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last time modified',
PRIMARY KEY (`id`),
UNIQUE KEY `uniq_idx_topic_target` (`topic`,`target_id`),
KEY `DataChange_LastTime` (`DataChange_LastTime`),
KEY `state` (`state`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='report queue for meta data insertion/update/deletion';
-- Data exporting was unselected.
-- Dumping structure for table role
DROP TABLE IF EXISTS `role`;
CREATE TABLE IF NOT EXISTS `role` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(128) NOT NULL DEFAULT 'unknow' COMMENT 'name',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'DataChange_LastTime',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='role';
-- Data exporting was unselected.
-- Dumping structure for table role_resource
DROP TABLE IF EXISTS `role_resource`;
CREATE TABLE IF NOT EXISTS `role_resource` (
`role_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'r',
`type` varchar(128) NOT NULL DEFAULT 'unknow' COMMENT 't',
`data_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'o',
`operation` varchar(2048) NOT NULL DEFAULT '0',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'DataChange_LastTime',
UNIQUE KEY `role_id_type_data_id` (`role_id`,`type`,`data_id`),
KEY `DataChange_LastTime` (`DataChange_LastTime`),
KEY `role_id` (`role_id`),
KEY `role_id_type` (`role_id`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='role_resource';
-- Data exporting was unselected.
-- Dumping structure for table r_certificate_slb_server
DROP TABLE IF EXISTS `r_certificate_slb_server`;
CREATE TABLE IF NOT EXISTS `r_certificate_slb_server` (
@ -749,18 +817,19 @@ CREATE TABLE IF NOT EXISTS `r_group_vs` (
-- Dumping structure for table r_slb_slb_server
DROP TABLE IF EXISTS `r_slb_slb_server`;
CREATE TABLE IF NOT EXISTS `r_slb_slb_server` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'primary key',
`slb_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'slb_id',
`ip` varchar(200) NOT NULL DEFAULT '0' COMMENT 'slb_server ip',
`slb_version` int(11) NOT NULL DEFAULT '0' COMMENT 'slb version',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'last time modified',
DROP TABLE IF EXISTS `slb_virtual_server`;
CREATE TABLE IF NOT EXISTS `slb_virtual_server` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`slb_id` bigint(20) NOT NULL DEFAULT '0',
`name` varchar(200) NOT NULL DEFAULT '0',
`port` varchar(200) NOT NULL DEFAULT '0',
`is_ssl` bit(1) NOT NULL DEFAULT b'0',
`created_time` timestamp NULL DEFAULT NULL,
`version` int(11) NOT NULL DEFAULT '0' COMMENT 'version',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `DataChange_LastTime` (`DataChange_LastTime`),
KEY `slb_id` (`slb_id`),
KEY `ip` (`ip`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='relation table of slb and slb server';
KEY `idx_DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
-- Data exporting was unselected.
@ -1069,6 +1138,67 @@ CREATE TABLE IF NOT EXISTS `task` (
-- Data exporting was unselected.
-- Dumping structure for table task_execute_record
DROP TABLE IF EXISTS `task_execute_record`;
CREATE TABLE IF NOT EXISTS `task_execute_record` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`task_key` varchar(128) NOT NULL DEFAULT 'UNKNOW' COMMENT 'task key',
`last_execute_time` bigint(20) NOT NULL DEFAULT '0' COMMENT 'last execute time',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'DataChange_LastTime',
PRIMARY KEY (`id`),
UNIQUE KEY `task_key` (`task_key`),
KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='task_execute_record';
-- Data exporting was unselected.
-- Dumping structure for table user
DROP TABLE IF EXISTS `user`;
CREATE TABLE IF NOT EXISTS `user` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT 'id',
`name` varchar(128) NOT NULL DEFAULT 'unknow' COMMENT 'name',
`email` varchar(128) DEFAULT 'unknow' COMMENT 'email',
`bu` varchar(128) DEFAULT 'unknow' COMMENT 'bu',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'DataChange_LastTime',
PRIMARY KEY (`id`),
UNIQUE KEY `name` (`name`),
KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='user';
-- Data exporting was unselected.
-- Dumping structure for table user_resource
DROP TABLE IF EXISTS `user_resource`;
CREATE TABLE IF NOT EXISTS `user_resource` (
`user_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'u',
`type` varchar(128) NOT NULL DEFAULT 'unknow' COMMENT 't',
`data_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'r',
`operation` varchar(2048) NOT NULL DEFAULT '0',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'DataChange_LastTime',
UNIQUE KEY `user_id_type_data_id` (`user_id`,`type`,`data_id`),
KEY `DataChange_LastTime` (`DataChange_LastTime`),
KEY `user_id` (`user_id`),
KEY `user_id_type` (`user_id`,`type`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='user_resource';
-- Data exporting was unselected.
-- Dumping structure for table user_role
DROP TABLE IF EXISTS `user_role`;
CREATE TABLE IF NOT EXISTS `user_role` (
`user_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'u',
`role_id` bigint(20) NOT NULL DEFAULT '0' COMMENT 'r',
`DataChange_LastTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT 'DataChange_LastTime',
UNIQUE KEY `user_id_role_id` (`user_id`,`role_id`),
KEY `DataChange_LastTime` (`DataChange_LastTime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='user_role';
-- Data exporting was unselected.
-- Dumping structure for table waf_data
DROP TABLE IF EXISTS `waf_data`;
CREATE TABLE IF NOT EXISTS `waf_data` (

View file

@ -1,6 +1,7 @@
package com.ctrip.zeus.service;
import com.ctrip.zeus.AbstractServerTest;
import com.ctrip.zeus.commit.entity.ConfSlbVersion;
import com.ctrip.zeus.dal.core.*;
import com.ctrip.zeus.model.entity.*;
import com.ctrip.zeus.nginx.entity.ConfFile;
@ -10,6 +11,7 @@ import com.ctrip.zeus.nginx.entity.Vhosts;
import com.ctrip.zeus.nginx.transform.DefaultJsonParser;
import com.ctrip.zeus.service.build.BuildService;
import com.ctrip.zeus.service.build.NginxConfService;
import com.ctrip.zeus.service.version.ConfVersionService;
import com.ctrip.zeus.support.GenericSerializer;
import com.ctrip.zeus.util.CompressUtils;
import com.google.common.collect.Lists;
@ -17,10 +19,8 @@ import com.google.common.collect.Sets;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.unidal.dal.jdbc.DalException;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.*;
/**
@ -51,11 +51,13 @@ public class MultiGvsAtSameSlbTest extends AbstractServerTest {
private BuildService buildService;
@Resource
private NginxConfService nginxConfService;
@Resource
private ConfVersionService confVersionService;
private static boolean inited = false;
@Before
public void setCurrentVersion() throws DalException, IOException {
public void setCurrentVersion() throws Exception {
if (inited) return;
buildInfoDao.insert(new BuildInfoDo().setSlbId(1L).setPendingTicket(2).setCurrentTicket(1));
nginxConfDao.insert(new NginxConfDo().setSlbId(1L).setVersion(1).setContent("nginx.conf"));
@ -79,6 +81,7 @@ public class MultiGvsAtSameSlbTest extends AbstractServerTest {
nginxConfSlbDao.insert(new NginxConfSlbDo().setSlbId(1L).setVersion(1)
.setContent(CompressUtils.compress(GenericSerializer.writeJson(currentConf))));
confVersionService.addConfSlbVersion(new ConfSlbVersion().setSlbId(1L).setCurrentVersion(1L).setPreviousVersion(0L));
inited = true;
}