Skip to content

Commit e633154

Browse files
author
Fabrício Duarte
committed
Merge branch 'fix-incremental-snapshot-migration' into '4.20.0.0-scclouds'
Adição de suporte à migração de snapshots e backups incrementais com KVM Closes #2888 See merge request scclouds/scclouds!1248
2 parents 888ebb5 + 2232faa commit e633154

21 files changed

Lines changed: 1181 additions & 44 deletions

File tree

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
//
18+
19+
package com.cloud.agent.api;
20+
21+
import com.cloud.agent.api.to.DataStoreTO;
22+
import com.cloud.agent.api.to.DataTO;
23+
24+
import java.util.List;
25+
26+
public class MigrateBackupsBetweenSecondaryStoragesCommand extends MigrateBetweenSecondaryStoragesCommand {
27+
28+
List<List<DataTO>> backupChain;
29+
30+
public MigrateBackupsBetweenSecondaryStoragesCommand() {
31+
}
32+
33+
public MigrateBackupsBetweenSecondaryStoragesCommand(List<List<DataTO>> backupChain, DataStoreTO srcDataStore, DataStoreTO destDataStore) {
34+
super(srcDataStore, destDataStore);
35+
this.backupChain = backupChain;
36+
}
37+
38+
public List<List<DataTO>> getBackupChain() {
39+
return backupChain;
40+
}
41+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
//
18+
19+
package com.cloud.agent.api;
20+
21+
import com.cloud.agent.api.to.DataStoreTO;
22+
23+
public abstract class MigrateBetweenSecondaryStoragesCommand extends Command {
24+
25+
DataStoreTO srcDataStore;
26+
DataStoreTO destDataStore;
27+
28+
public MigrateBetweenSecondaryStoragesCommand() {
29+
}
30+
31+
public MigrateBetweenSecondaryStoragesCommand(DataStoreTO srcDataStore, DataStoreTO destDataStore) {
32+
this.srcDataStore = srcDataStore;
33+
this.destDataStore = destDataStore;
34+
}
35+
36+
@Override
37+
public boolean executeInSequence() {
38+
return false;
39+
}
40+
41+
public DataStoreTO getSrcDataStore() {
42+
return srcDataStore;
43+
}
44+
45+
public DataStoreTO getDestDataStore() {
46+
return destDataStore;
47+
}
48+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//
2+
// Licensed to the Apache Software Foundation (ASF) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The ASF licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
//
19+
20+
package com.cloud.agent.api;
21+
22+
import com.cloud.utils.Pair;
23+
24+
import java.util.List;
25+
26+
public class MigrateBetweenSecondaryStoragesCommandAnswer extends Answer {
27+
28+
List<Pair<Long, String>> migratedResourcesIdAndCheckpointPath;
29+
30+
public MigrateBetweenSecondaryStoragesCommandAnswer() {
31+
}
32+
33+
public MigrateBetweenSecondaryStoragesCommandAnswer(MigrateBetweenSecondaryStoragesCommand cmd, boolean success, String result, List<Pair<Long, String>> migratedResourcesIdAndCheckpointPath) {
34+
super(cmd, success, result);
35+
this.migratedResourcesIdAndCheckpointPath = migratedResourcesIdAndCheckpointPath;
36+
}
37+
38+
public List<Pair<Long, String>> getMigratedResources() {
39+
return migratedResourcesIdAndCheckpointPath;
40+
}
41+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
//
18+
19+
package com.cloud.agent.api;
20+
21+
import com.cloud.agent.api.to.DataStoreTO;
22+
import com.cloud.agent.api.to.DataTO;
23+
24+
import java.util.List;
25+
import java.util.Set;
26+
27+
public class MigrateSnapshotsBetweenSecondaryStoragesCommand extends MigrateBetweenSecondaryStoragesCommand {
28+
29+
List<DataTO> snapshotChain;
30+
Set<Long> snapshotsIdToMigrate;
31+
32+
public MigrateSnapshotsBetweenSecondaryStoragesCommand() {
33+
}
34+
35+
public MigrateSnapshotsBetweenSecondaryStoragesCommand(List<DataTO> snapshotChain, DataStoreTO srcDataStore, DataStoreTO destDataStore, Set<Long> snapshotsIdToMigrate) {
36+
super(srcDataStore, destDataStore);
37+
this.snapshotChain = snapshotChain;
38+
this.snapshotsIdToMigrate = snapshotsIdToMigrate;
39+
}
40+
41+
public List<DataTO> getSnapshotChain() {
42+
return snapshotChain;
43+
}
44+
45+
public Set<Long> getSnapshotsIdToMigrate() {
46+
return snapshotsIdToMigrate;
47+
}
48+
}

core/src/main/java/org/apache/cloudstack/storage/to/BackupDeltaTO.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ public BackupDeltaTO(DataStoreTO dataStoreTO, Hypervisor.HypervisorType hypervis
4343
this.format = Storage.ImageFormat.QCOW2;
4444
}
4545

46+
public BackupDeltaTO(long id, DataStoreTO dataStoreTO, Hypervisor.HypervisorType hypervisorType, String path) {
47+
this(dataStoreTO, hypervisorType, path);
48+
this.id = id;
49+
}
50+
4651
@Override
4752
public DataObjectType getObjectType() {
4853
return DataObjectType.BACKUP;

engine/api/src/main/java/org/apache/cloudstack/engine/subsystem/api/storage/SnapshotInfo.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public interface SnapshotInfo extends DataObject, Snapshot {
3030

3131
SnapshotInfo getParent();
3232

33+
List<SnapshotInfo> getParents();
34+
3335
String getPath();
3436

3537
SnapshotInfo getChild();
@@ -40,6 +42,8 @@ public interface SnapshotInfo extends DataObject, Snapshot {
4042

4143
List<SnapshotInfo> getChildren();
4244

45+
List<SnapshotInfo> getChildAndGrandchildren();
46+
4347
VolumeInfo getBaseVolume();
4448

4549
void addPayload(Object data);

engine/components-api/src/main/java/com/cloud/storage/StorageManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ public interface StorageManager extends StorageService {
213213
"Storage", "true", "Allow SSVMs to try copying public templates from one secondary storage to another instead of downloading them from the source.",
214214
true, ConfigKey.Scope.Zone, null);
215215

216+
ConfigKey<Integer> AgentMaxDataMigrationWaitTime = new ConfigKey<>("Advanced", Integer.class, "agent.max.data.migration.wait.time", "3600",
217+
"The maximum time (in seconds) that the secondary storage data migration command sent to the KVM Agent will be executed before a timeout occurs.", true, ConfigKey.Scope.Cluster);
218+
216219
/**
217220
* should we execute in sequence not involving any storages?
218221
* @return tru if commands should execute in sequence

0 commit comments

Comments
 (0)