[
https://issues.apache.org/jira/browse/CLOUDSTACK-9932?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16310735#comment-16310735
]
ASF GitHub Bot commented on CLOUDSTACK-9932:
--------------------------------------------
rhtyd closed pull request #2149: CLOUDSTACK-9932 snapshot is getting deleted
while volume is in creating state
URL: https://github.com/apache/cloudstack/pull/2149
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
index 185cf567fa0..723d5c7b369 100644
---
a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
+++
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/StorageSystemSnapshotStrategy.java
@@ -38,6 +38,8 @@
import com.cloud.storage.dao.SnapshotDetailsDao;
import com.cloud.storage.dao.SnapshotDetailsVO;
import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.dao.VolumeDetailsDao;
+import com.cloud.storage.VolumeDetailVO;
import com.cloud.utils.db.DB;
import com.cloud.utils.exception.CloudRuntimeException;
import com.cloud.utils.fsm.NoTransitionException;
@@ -87,6 +89,7 @@
@Inject private VMInstanceDao vmInstanceDao;
@Inject private VolumeDao volumeDao;
@Inject private VolumeService volService;
+ @Inject private VolumeDetailsDao _volumeDetailsDaoImpl;
@Override
public SnapshotInfo backupSnapshot(SnapshotInfo snapshotInfo) {
@@ -165,6 +168,17 @@ private boolean cleanupSnapshotOnPrimaryStore(long
snapshotId) {
try {
snapshotObj.processEvent(Snapshot.Event.DestroyRequested);
+ List<VolumeDetailVO> volumesFromSnapshot;
+ volumesFromSnapshot =
_volumeDetailsDaoImpl.findDetails("SNAPSHOT_ID", String.valueOf(snapshotId),
null);
+
+ if (volumesFromSnapshot.size() > 0) {
+ try {
+ snapshotObj.processEvent(Snapshot.Event.OperationFailed);
+ } catch (NoTransitionException e1) {
+ s_logger.debug("Failed to change snapshot state: " +
e1.toString());
+ }
+ throw new InvalidParameterValueException("Unable to perform
delete operation, Snapshot with id: " + snapshotId + " is in use ");
+ }
}
catch (NoTransitionException e) {
s_logger.debug("Failed to set the state to destroying: ", e);
diff --git
a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
index a673a462375..479d7b4b670 100644
---
a/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
+++
b/engine/storage/snapshot/src/org/apache/cloudstack/storage/snapshot/XenserverSnapshotStrategy.java
@@ -53,9 +53,11 @@
import com.cloud.storage.StoragePoolStatus;
import com.cloud.storage.Volume;
import com.cloud.storage.VolumeVO;
+import com.cloud.storage.VolumeDetailVO;
import com.cloud.storage.dao.SnapshotDao;
import com.cloud.storage.dao.SnapshotDetailsDao;
import com.cloud.storage.dao.VolumeDao;
+import com.cloud.storage.dao.VolumeDetailsDao;
import com.cloud.utils.db.Transaction;
import com.cloud.utils.db.TransactionCallbackNoReturn;
import com.cloud.utils.db.TransactionStatus;
@@ -91,6 +93,8 @@
private SnapshotDetailsDao _snapshotDetailsDao;
@Inject
private SyncQueueItemDao _syncQueueItemDao;
+ @Inject
+ VolumeDetailsDao _volumeDetailsDaoImpl;
@Override
public SnapshotInfo backupSnapshot(SnapshotInfo snapshot) {
@@ -278,6 +282,17 @@ public boolean deleteSnapshot(Long snapshotId) {
SnapshotObject obj = (SnapshotObject)snapshotOnImage;
try {
obj.processEvent(Snapshot.Event.DestroyRequested);
+ List<VolumeDetailVO> volumesFromSnapshot;
+ volumesFromSnapshot =
_volumeDetailsDaoImpl.findDetails("SNAPSHOT_ID", String.valueOf(snapshotId),
null);
+
+ if (volumesFromSnapshot.size() > 0) {
+ try {
+ obj.processEvent(Snapshot.Event.OperationFailed);
+ } catch (NoTransitionException e1) {
+ s_logger.debug("Failed to change snapshot state: " +
e1.toString());
+ }
+ throw new InvalidParameterValueException("Unable to perform
delete operation, Snapshot with id: " + snapshotId + " is in use ");
+ }
} catch (NoTransitionException e) {
s_logger.debug("Failed to set the state to destroying: ", e);
return false;
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Snapshot is getting deleted while volume creation from the snapshot is in
> progress
> -----------------------------------------------------------------------------------
>
> Key: CLOUDSTACK-9932
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9932
> Project: CloudStack
> Issue Type: Bug
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Affects Versions: 4.10.0.0
> Environment: ACS -4.10.
> http://10.112.3.52:8080/client/
> user : admin
> password : password
> Reporter: veerapuppala
> Assignee: Pavan Kumar Aravapalli
>
> Issue:
> -------
> Snapshot is getting deleted while the volume create request from the snapshot
> is in progress.
> Steps to reproduce :
> -------------------------
> 1) Create root/data volume snapshot
> 2) Create Volumes from the snapshot
> 3) Delete the snapshot immediately while the volume creation is in progress
> Existing behavior:
> ---------------------
> Snapshot is getting deleted from the ACS and status is "Destroyed" in the
> snapshots table.
> Error message:
> ---------------------
> 2017-05-30 04:10:17,120 DEBUG [c.c.a.t.Request]
> (API-Job-Executor-26:ctx-8ba0012a job-188 ctx-ffe9988e) (logid:fd7a5d83) Seq
> 1-1570067420092044880: Received: { Ans: , MgmtId: 196796298644167, via:
> 1(localhost), Ver: v1, Flags: 110, { CopyCmdAnswer } }
> 2017-05-30 04:10:17,131 WARN [o.a.c.s.d.ObjectInDataStoreManagerImpl]
> (API-Job-Executor-26:ctx-8ba0012a job-188 ctx-ffe9988e) (logid:fd7a5d83)
> Unsupported data object (VOLUME,
> org.apache.cloudstack.storage.datastore.PrimaryDataStoreImpl@5c07d712), no
> need to delete from object in store ref table
> 2017-05-30 04:10:17,139 DEBUG [o.a.c.e.o.VolumeOrchestrator]
> (API-Job-Executor-26:ctx-8ba0012a job-188 ctx-ffe9988e) (logid:fd7a5d83)
> Failed to create volume from snapshot:null due to Task failed! Task record:
> uuid: bf2abdea-bea3-36e2-22f0-8fa62985c614
> nameLabel: Async.VDI.copy
> nameDescription:
> allowedOperations: []
> currentOperations: {}
> created: Tue May 30 04:10:10 EDT 2017
> finished: Tue May 30 04:10:16 EDT 2017
> status: failure
> residentOn: com.xensource.xenapi.Host@7a705050
> progress: 1.0
> type: <none/>
> result:
> errorInfo: [INTERNAL_ERROR, End_of_file]
> otherConfig: {}
> subtaskOf: com.xensource.xenapi.Task@aaf13f6f
> subtasks: []
>
> 2017-05-30 04:10:17,166 DEBUG [c.c.u.AccountManagerImpl]
> (API-Job-Executor-26:ctx-8ba0012a job-188 ctx-ffe9988e) (logid:fd7a5d83)
> Access granted to Acct[def73ff3-3fbb-11e7-b95a-b2fc35794ac7-admin] to
> Domain:1/ by AffinityGroupAccessChecker
> 2017-05-30 04:10:17,180 ERROR [c.c.a.ApiAsyncJobDispatcher]
> (API-Job-Executor-26:ctx-8ba0012a job-188) (logid:fd7a5d83) Unexpected
> exception while executing
> org.apache.cloudstack.api.command.admin.volume.CreateVolumeCmdByAdmin
> com.cloud.utils.exception.CloudRuntimeException: Failed to create volume: 42
> at
> com.cloud.storage.VolumeApiServiceImpl.createVolume(VolumeApiServiceImpl.java:803)
> at
> com.cloud.storage.VolumeApiServiceImpl.createVolume(VolumeApiServiceImpl.java:175)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:498)
> at
> org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
> at
> org.apache.cloudstack.network.contrail.management.EventUtils$EventInterceptor.invoke(EventUtils.java:107)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
> at
> com.cloud.event.ActionEventInterceptor.invoke(ActionEventInterceptor.java:51)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:168)
> at
> org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
> at
> org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
> at
> org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
> at com.sun.proxy.$Proxy207.createVolume(Unknown Source)
> at
> org.apache.cloudstack.api.command.admin.volume.CreateVolumeCmdByAdmin.execute(CreateVolumeCmdByAdmin.java:42)
> at com.cloud.api.ApiDispatcher.dispatch(ApiDispatcher.java:150)
> at
> com.cloud.api.ApiAsyncJobDispatcher.runJob(ApiAsyncJobDispatcher.java:108)
> at
> org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.runInContext(AsyncJobManagerImpl.java:558)
> at
> org.apache.cloudstack.managed.context.ManagedContextRunnable$1.run(ManagedContextRunnable.java:49)
> at
> org.apache.cloudstack.managed.context.impl.DefaultManagedContext$1.call(DefaultManagedContext.java:56)
> at
> org.apache.cloudstack.managed.context.impl.DefaultManagedContext.callWithContext(DefaultManagedContext.java:103)
> at
> org.apache.cloudstack.managed.context.impl.DefaultManagedContext.runWithContext(DefaultManagedContext.java:53)
> at
> org.apache.cloudstack.managed.context.ManagedContextRunnable.run(ManagedContextRunnable.java:46)
> at
> org.apache.cloudstack.framework.jobs.impl.AsyncJobManagerImpl$5.run(AsyncJobManagerImpl.java:506)
> at
> java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
> at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:748)
> Caused by: com.cloud.utils.exception.CloudRuntimeException: Failed to create
> volume from snapshot:null due to Task failed! Task record:
> uuid: bf2abdea-bea3-36e2-22f0-8fa62985c614
> nameLabel: Async.VDI.copy
> nameDescription:
> allowedOperations: []
> currentOperations: {}
> created: Tue May 30 04:10:10 EDT 2017
> finished: Tue May 30 04:10:16 EDT 2017
> status: failure
> residentOn: com.xensource.xenapi.Host@7a705050
> progress: 1.0
> type: <none/>
> result:
> errorInfo: [INTERNAL_ERROR, End_of_file]
> otherConfig: {}
> subtaskOf: com.xensource.xenapi.Task@aaf13f6f
> subtasks: []
>
> at
> org.apache.cloudstack.engine.orchestration.VolumeOrchestrator.createVolumeFromSnapshot(VolumeOrchestrator.java:439)
> at
> com.cloud.storage.VolumeApiServiceImpl.createVolumeFromSnapshot(VolumeApiServiceImpl.java:825)
> at
> com.cloud.storage.VolumeApiServiceImpl.createVolume(VolumeApiServiceImpl.java:775)
> ... 31 more
> 2017-05-30 04:10:17,181 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl]
> (API-Job-Executor-26:ctx-8ba0012a job-188) (logid:fd7a5d83) Complete async
> job-188, jobStatus: FAILED, resultCode: 530, result:
> org.apache.cloudstack.api.response.ExceptionResponse/null/{"uuidList":[],"errorcode":530,"errortext":"Failed
> to create volume: 42"}
> 2017-05-30 04:10:17,194 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl]
> (API-Job-Executor-26:ctx-8ba0012a job-188) (logid:fd7a5d83) Publish async
> job-188 complete on message bus
> 2017-05-30 04:10:17,194 DEBUG [o.a.c.f.j.i.AsyncJobManagerImpl]
> (API-Job-Executor-26:ctx-8ba0012a job-188) (logid:fd7a5d83) Wake up jobs
> related to job-188
>
> Expected Behavior:
> -------------------------
> It should not be getting deleted while the volume request is in progress. or
> It should give warning message or Alert message as volume create request is
> in progress on the snapshot.
> Below are the details from snapshot and snapshot_store_ref tables.
> ------------------------------------------------------------------------------------------
> mysql> select * from snapshots where id=9\G;
>
> id: 9
> data_center_id: 1
> account_id: 2
> domain_id: 1
> volume_id: 37
> disk_offering_id: 2
> status: Destroyed
> path: NULL
> name: m29snap2
> uuid: f08ff2b5-b889-41c2-bc15-ccc7b94342b8
> snapshot_type: 0
> type_description: MANUAL
> size: 21474836480
> created: 2017-05-29 10:33:13
> removed: NULL
> backup_snap_id: NULL
> swift_id: NULL
> sechost_id: NULL
> prev_snap_id: NULL
> hypervisor_type: XenServer
> version: 2.2
> s3_id: NULL
> min_iops: NULL
> max_iops: NULL
> location_type: NULL
> 1 row in set (0.00 sec)
>
> mysql> select * from snapshot_store_ref where snapshot_id=9\G;
>
> id: 17
> store_id: 1
> snapshot_id: 9
> created: 2017-05-29 10:33:13
> last_updated: NULL
> job_id: NULL
> store_role: Primary
> size: 21474836480
> physical_size: 21474836480
> parent_snapshot_id: 0
> install_path: bf345178-07f7-46c8-ab50-e5ecce67c1ba
> state: Destroyed
> update_count: 2
> ref_cnt: 0
> updated: 2017-05-29 10:33:17
> volume_id: 37
> ==============================================
>
> id: 18
> store_id: 1
> snapshot_id: 9
> created: 2017-05-29 10:33:17
> last_updated: NULL
> job_id: NULL
> store_role: Image
> size: 21474836480
> physical_size: 45056
> parent_snapshot_id: 0
> install_path: snapshots/2/37/8e0f004e-f916-4f4f-895d-8d95eab00463.vhd
> state: Destroyed
> update_count: 4
> ref_cnt: 0
> updated: 2017-05-30 08:10:15
> volume_id: 37
> 2 rows in set (0.00 sec)
>
> [root@localhost primary]# ls bf345178-07f7-46c8-ab50-e5ecce67c1ba.vhd
> bf345178-07f7-46c8-ab50-e5ecce67c1ba.vhd
>
> [root@localhost secondary]# cd snapshots/
> [root@localhost snapshots]# cd 2/37/
> [root@localhost 37]# ls
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)