Skip to content

Commit 781050f

Browse files
AlanJagerWangHe
authored andcommitted
Add rollback for local volume migrate state change
Resolves ZSTAC-10519 Signed-off-by: AlanJager <[email protected]> 增加surfs的代码
1 parent 7141802 commit 781050f

File tree

103 files changed

+12264
-8
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+12264
-8
lines changed

conf/db/upgrade/V2.2.4.1__schema.sql

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
CREATE TABLE if not exists `zstack`.`SurfsBackupStorageVO` (
2+
`uuid` varchar(32) NOT NULL UNIQUE,
3+
`fsid` varchar(64) DEFAULT NULL,
4+
`poolName` varchar(255) NOT NULL,
5+
PRIMARY KEY (`uuid`)
6+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
7+
8+
CREATE TABLE if not exists `zstack`.`SurfsBackupStorageNodeVO` (
9+
`uuid` varchar(32) NOT NULL UNIQUE,
10+
`sshUsername` varchar(64) NOT NULL,
11+
`sshPassword` varchar(255) NOT NULL,
12+
`hostname` varchar(255) NOT NULL,
13+
`status` varchar(255) NOT NULL,
14+
`nodeAddr` varchar(255) NOT NULL,
15+
`sshPort` int unsigned NOT NULL,
16+
`nodePort` int unsigned NOT NULL,
17+
`backupStorageUuid` varchar(32) NOT NULL,
18+
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
19+
`createDate` timestamp,
20+
PRIMARY KEY (`uuid`)
21+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
22+
23+
CREATE TABLE if not exists `zstack`.`SurfsPrimaryStorageVO` (
24+
`uuid` varchar(32) NOT NULL UNIQUE,
25+
`fsid` varchar(64) DEFAULT NULL,
26+
`rootVolumePoolName` varchar(255) NOT NULL,
27+
`dataVolumePoolName` varchar(255) NOT NULL,
28+
`imageCachePoolName` varchar(255) NOT NULL,
29+
`userKey` varchar(255) DEFAULT NULL,
30+
PRIMARY KEY (`uuid`)
31+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
32+
33+
CREATE TABLE if not exists `zstack`.`SurfsPrimaryStorageNodeVO` (
34+
`uuid` varchar(32) NOT NULL UNIQUE,
35+
`sshUsername` varchar(64) NOT NULL,
36+
`sshPassword` varchar(255) NOT NULL,
37+
`hostname` varchar(255) NOT NULL,
38+
`status` varchar(255) NOT NULL,
39+
`nodeAddr` varchar(255) NOT NULL,
40+
`sshPort` int unsigned NOT NULL,
41+
`nodePort` int unsigned NOT NULL,
42+
`primaryStorageUuid` varchar(32) NOT NULL,
43+
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
44+
`createDate` timestamp,
45+
PRIMARY KEY (`uuid`)
46+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
47+
48+
CREATE TABLE if not exists `zstack`.`SurfsCapacityVO` (
49+
`fsid` varchar(64) NOT NULL UNIQUE,
50+
`totalCapacity` bigint unsigned DEFAULT 0,
51+
`availableCapacity` bigint unsigned DEFAULT 0,
52+
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
53+
`createDate` timestamp,
54+
PRIMARY KEY (`fsid`)
55+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
56+
57+
CREATE TABLE if not exists `zstack`.`SurfsPoolClassVO` (
58+
`uuid` varchar(32) NOT NULL UNIQUE,
59+
`fsid` varchar(64) NOT NULL,
60+
`clsname` varchar(32) NOT NULL,
61+
`clsdisplayname` varchar(64) NOT NULL,
62+
`isrootcls` tinyint(1) NOT NULL DEFAULT 0,
63+
`isactive` tinyint(1) NOT NULL DEFAULT 0,
64+
`totalCapacity` bigint unsigned DEFAULT 0,
65+
`availableCapacity` bigint unsigned DEFAULT 0,
66+
`lastOpDate` timestamp ON UPDATE CURRENT_TIMESTAMP,
67+
`createDate` timestamp,
68+
PRIMARY KEY (`uuid`)
69+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
70+
71+
delimiter //
72+
drop procedure if exists do_surfs_alter //
73+
create procedure do_surfs_alter()
74+
begin
75+
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsBackupStorageNodeVOBackupStorageEO') then
76+
ALTER TABLE SurfsBackupStorageNodeVO ADD CONSTRAINT fkSurfsBackupStorageNodeVOBackupStorageEO FOREIGN KEY (backupStorageUuid) REFERENCES BackupStorageEO (uuid) ON DELETE CASCADE;
77+
END IF;
78+
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsBackupStorageVOBackupStorageEO') then
79+
ALTER TABLE SurfsBackupStorageVO ADD CONSTRAINT fkSurfsBackupStorageVOBackupStorageEO FOREIGN KEY (uuid) REFERENCES BackupStorageEO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE;
80+
END IF;
81+
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsPrimaryStorageNodeVOPrimaryStorageEO') then
82+
ALTER TABLE SurfsPrimaryStorageNodeVO ADD CONSTRAINT fkSurfsPrimaryStorageNodeVOPrimaryStorageEO FOREIGN KEY (primaryStorageUuid) REFERENCES PrimaryStorageEO (uuid) ON DELETE CASCADE;
83+
END IF;
84+
IF not exists(select CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where CONSTRAINT_NAME='fkSurfsPrimaryStorageVOPrimaryStorageEO') then
85+
ALTER TABLE SurfsPrimaryStorageVO ADD CONSTRAINT fkSurfsPrimaryStorageVOPrimaryStorageEO FOREIGN KEY (uuid) REFERENCES PrimaryStorageEO (uuid) ON UPDATE RESTRICT ON DELETE CASCADE;
86+
END IF;
87+
end;//
88+
call do_surfs_alter() //
89+
drop procedure if exists do_surfs_alter //
90+
delimiter ;
91+
92+

conf/globalConfig/surfs.xml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<globalConfig xmlns="http://zstack.org/schema/zstack">
3+
<config>
4+
<name>backupStorage.image.download.timeout</name>
5+
<description>timeout of command of downloading images to surfs backup storage, in seconds.</description>
6+
<category>surfs</category>
7+
<defaultValue>3600</defaultValue>
8+
<type>java.lang.Long</type>
9+
</config>
10+
<config>
11+
<name>imageCache.cleanup.interval</name>
12+
<description>interval to cleanup stale image cache on primary storage, in seconds.</description>
13+
<category>surfs</category>
14+
<defaultValue>43200</defaultValue>
15+
<type>java.lang.Long</type>
16+
</config>
17+
<config>
18+
<name>primaryStorage.deletePool</name>
19+
<description>delete all primary storage related pools when deleting the surfs primary storage</description>
20+
<category>surfs</category>
21+
<defaultValue>false</defaultValue>
22+
<type>java.lang.Boolean</type>
23+
</config>
24+
<config>
25+
<name>primaryStorage.node.reconnectDelay</name>
26+
<description>the delay to reconnect a primary storage surfs node after a ping failure, in seconds</description>
27+
<category>surfs</category>
28+
<defaultValue>30</defaultValue>
29+
<type>java.lang.Integer</type>
30+
</config>
31+
<config>
32+
<name>backupStorage.node.reconnectDelay</name>
33+
<description>the delay to reconnect a backup storage surfs node after a ping failure, in seconds</description>
34+
<category>surfs</category>
35+
<defaultValue>30</defaultValue>
36+
<type>java.lang.Integer</type>
37+
</config>
38+
<config>
39+
<name>primaryStorage.node.autoReconnect</name>
40+
<description>whether to automatically reconnect a surfs primary storage node when it's unable to be pinged</description>
41+
<category>surfs</category>
42+
<defaultValue>true</defaultValue>
43+
<type>java.lang.Boolean</type>
44+
</config>
45+
<config>
46+
<name>backupStorage.node.autoReconnect</name>
47+
<description>whether to automatically reconnect a surfs backup storage node when it's unable to be pinged</description>
48+
<category>surfs</category>
49+
<defaultValue>true</defaultValue>
50+
<type>java.lang.Boolean</type>
51+
</config>
52+
</globalConfig>
53+

conf/persistence.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
<class>org.zstack.storage.fusionstor.primary.FusionstorPrimaryStorageMonVO</class>
123123
<class>org.zstack.storage.fusionstor.primary.FusionstorPrimaryStorageVO</class>
124124
<class>org.zstack.storage.fusionstor.FusionstorCapacityVO</class>
125+
<class>org.zstack.storage.surfs.backup.SurfsBackupStorageVO</class>
126+
<class>org.zstack.storage.surfs.backup.SurfsBackupStorageNodeVO</class>
127+
<class>org.zstack.storage.surfs.backup.SurfsPrimaryStorageVO</class>
128+
<class>org.zstack.storage.surfs.backup.SurfsPrimaryStorageNodeVO</class>
129+
<class>org.zstack.storage.surfs.SurfsCapacityVO</class>
125130
<class>org.zstack.core.gc.GarbageCollectorVO</class>
126131
<class>org.zstack.header.storage.primary.ImageCacheVolumeRefVO</class>
127132
<class>org.zstack.network.service.virtualrouter.lb.VirtualRouterLoadBalancerRefVO</class>

conf/serviceConfig/surfs.xml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<service xmlns="http://zstack.org/schema/zstack">
3+
<interceptor>SurfsApiInterceptor</interceptor>
4+
5+
<message>
6+
<name>org.zstack.storage.surfs.backup.APIAddSurfsBackupStorageMsg</name>
7+
<serviceId>storage.backup</serviceId>
8+
</message>
9+
10+
<message>
11+
<name>org.zstack.storage.surfs.backup.APIAddNodeToSurfsBackupStorageMsg</name>
12+
<serviceId>storage.backup</serviceId>
13+
</message>
14+
15+
<message>
16+
<name>org.zstack.storage.surfs.backup.APIUpdateSurfsBackupStorageNodeMsg</name>
17+
<serviceId>storage.backup</serviceId>
18+
</message>
19+
20+
<message>
21+
<name>org.zstack.storage.surfs.backup.APIRemoveNodeFromSurfsBackupStorageMsg</name>
22+
<serviceId>storage.backup</serviceId>
23+
</message>
24+
25+
<message>
26+
<name>org.zstack.storage.surfs.backup.APIQuerySurfsBackupStorageMsg</name>
27+
<serviceId>query</serviceId>
28+
</message>
29+
30+
<message>
31+
<name>org.zstack.storage.surfs.primary.APIAddSurfsPrimaryStorageMsg</name>
32+
<serviceId>storage.primary</serviceId>
33+
</message>
34+
35+
<message>
36+
<name>org.zstack.storage.surfs.primary.APIAddNodeToSurfsPrimaryStorageMsg</name>
37+
<serviceId>storage.primary</serviceId>
38+
</message>
39+
40+
<message>
41+
<name>org.zstack.storage.surfs.primary.APIUpdateSurfsPrimaryStorageNodeMsg</name>
42+
<serviceId>storage.primary</serviceId>
43+
</message>
44+
45+
<message>
46+
<name>org.zstack.storage.surfs.primary.APIRemoveNodeFromSurfsPrimaryStorageMsg</name>
47+
<serviceId>storage.primary</serviceId>
48+
</message>
49+
50+
<message>
51+
<name>org.zstack.storage.surfs.primary.APIQuerySurfsPrimaryStorageMsg</name>
52+
<serviceId>query</serviceId>
53+
</message>
54+
55+
<message>
56+
<name>org.zstack.storage.surfs.primary.APIQuerySurfsPoolClassMsg</name>
57+
<serviceId>query</serviceId>
58+
</message>
59+
</service>
60+

conf/springConfigXml/HostAllocatorManager.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
<value>Ceph</value>
4343
<value>XSky</value>
4444
</util:list>
45+
46+
<util:list id="SurfsMetric">
47+
<value>Surfs</value>
48+
</util:list>
4549

4650
<util:list id="FusionstorMetric">
4751
<value>Fusionstor</value>
@@ -55,6 +59,7 @@
5559
<entry key="SftpBackupStorage" value-ref="SftpBackupStorageMetric"/>
5660
<entry key="Fusionstor" value-ref="FusionstorMetric"/>
5761
<entry key="Ceph" value-ref="CephMetric"/>
62+
<entry key="Surfs" value-ref="SurfsMetric"/>
5863
<entry key="ImageStoreBackupStorage" value-ref="ImageStoreBackupStorageMetric"/>
5964
<entry key="SimulatorBackupStorage" value-ref="SimulatorBackupStorageMetric"/>
6065
<entry key="VCenter" value-ref="VCenterMetric"/>

conf/springConfigXml/surfs.xml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<beans xmlns="http://www.springframework.org/schema/beans"
2+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
3+
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:zstack="http://zstack.org/schema/zstack"
4+
xsi:schemaLocation="http://www.springframework.org/schema/beans
5+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
6+
http://www.springframework.org/schema/aop
7+
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
8+
http://www.springframework.org/schema/tx
9+
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
10+
http://zstack.org/schema/zstack
11+
http://zstack.org/schema/zstack/plugin.xsd"
12+
default-init-method="init" default-destroy-method="destroy">
13+
<bean id="SurfsBackupStorageFactory" class="org.zstack.storage.surfs.backup.SurfsBackupStorageFactory">
14+
<zstack:plugin>
15+
<zstack:extension interface="org.zstack.header.storage.backup.BackupStorageFactory" />
16+
<zstack:extension interface="org.zstack.storage.surfs.SurfsCapacityUpdateExtensionPoint" />
17+
<zstack:extension interface="org.zstack.header.Component" />
18+
</zstack:plugin>
19+
</bean>
20+
<bean id="SurfsPrimaryStorageFactory" class="org.zstack.storage.surfs.primary.SurfsPrimaryStorageFactory">
21+
<zstack:plugin>
22+
<zstack:extension interface="org.zstack.header.storage.primary.PrimaryStorageFactory" />
23+
<zstack:extension interface="org.zstack.storage.surfs.SurfsCapacityUpdateExtensionPoint" />
24+
<zstack:extension interface="org.zstack.kvm.KVMStartVmExtensionPoint" />
25+
<zstack:extension interface="org.zstack.kvm.KVMAttachVolumeExtensionPoint" />
26+
<zstack:extension interface="org.zstack.kvm.KVMDetachVolumeExtensionPoint" />
27+
<zstack:extension interface="org.zstack.header.storage.snapshot.CreateTemplateFromVolumeSnapshotExtensionPoint" />
28+
<zstack:extension interface="org.zstack.kvm.KvmSetupSelfFencerExtensionPoint" />
29+
<zstack:extension interface="org.zstack.header.Component" />
30+
</zstack:plugin>
31+
</bean>
32+
<bean id="SurfsPrimaryStorageVmMigrationExtension" class="org.zstack.storage.surfs.primary.SurfsPrimaryStorageVmMigrationExtension">
33+
<zstack:plugin>
34+
<zstack:extension interface="org.zstack.header.vm.VmInstanceMigrateExtensionPoint" />
35+
</zstack:plugin>
36+
</bean>
37+
<bean id="SurfsApiInterceptor" class="org.zstack.storage.surfs.SurfsApiInterceptor">
38+
<zstack:plugin>
39+
<zstack:extension interface="org.zstack.header.apimediator.ApiMessageInterceptor" />
40+
</zstack:plugin>
41+
</bean>
42+
</beans>
43+

conf/zstack.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
<import resource="springConfigXml/BackupStorageManager.xml"/>
4343
<import resource="springConfigXml/CascadeFacade.xml"/>
4444
<import resource="springConfigXml/ceph.xml"/>
45+
<import resource="springConfigXml/surfs.xml"/>
4546
<import resource="springConfigXml/CloudBus.xml"/>
4647
<import resource="springConfigXml/ClusterManager.xml"/>
4748
<import resource="springConfigXml/ConfigurationManager.xml"/>

0 commit comments

Comments
 (0)