You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by dy...@apache.org on 2022/09/02 14:34:16 UTC

[incubator-datalab] branch DATALAB-3001 created (now 7ce5759f4)

This is an automated email from the ASF dual-hosted git repository.

dyankiv pushed a change to branch DATALAB-3001
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git


      at 7ce5759f4 fix image status is stuck on terminating

This branch includes the following new commits:

     new 7ce5759f4 fix image status is stuck on terminating

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org


[incubator-datalab] 01/01: fix image status is stuck on terminating

Posted by dy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dyankiv pushed a commit to branch DATALAB-3001
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 7ce5759f41287767bb50c540d5299bbc70cb4f0d
Author: Denys Yankiv <de...@gmail.com>
AuthorDate: Fri Sep 2 17:34:04 2022 +0300

    fix image status is stuck on terminating
---
 .../src/general/scripts/aws/common_terminate_notebook_image.py       | 3 +++
 .../src/general/scripts/azure/common_terminate_notebook_image.py     | 3 +++
 .../src/general/scripts/gcp/common_terminate_notebook_image.py       | 3 +++
 .../java/com/epam/datalab/backendapi/resources/ImageResource.java    | 1 -
 .../java/com/epam/datalab/backendapi/dao/ImageExploratoryDAO.java    | 2 +-
 .../com/epam/datalab/backendapi/dao/ImageExploratoryDAOImpl.java     | 5 ++---
 .../epam/datalab/backendapi/resources/callback/ImageCallback.java    | 2 +-
 .../com/epam/datalab/backendapi/service/ImageExploratoryService.java | 3 +--
 .../datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java | 4 ++--
 9 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py b/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py
index 98d6dfa92..140f15a27 100644
--- a/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py
+++ b/infrastructure-provisioning/src/general/scripts/aws/common_terminate_notebook_image.py
@@ -49,6 +49,9 @@ if __name__ == "__main__":
 
         with open("/root/result.json", 'w') as result:
             res = {"notebook_image_name": image_conf['full_image_name'],
+                   "endpoint": image_conf['endpoint_name'],
+                   "project": image_conf['project_name'],
+                   "imageName": image_conf['image_name'],
                    "status": "terminated",
                    "Action": "Delete existing notebook image"}
             result.write(json.dumps(res))
diff --git a/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py b/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py
index 0ef0d4e54..06df201a8 100644
--- a/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py
+++ b/infrastructure-provisioning/src/general/scripts/azure/common_terminate_notebook_image.py
@@ -51,6 +51,9 @@ if __name__ == "__main__":
 
         with open("/root/result.json", 'w') as result:
             res = {"notebook_image_name": image_conf['full_image_name'],
+                   "endpoint": image_conf['endpoint_name'],
+                   "project": image_conf['project_name'],
+                   "imageName": image_conf['image_name'],
                    "status": "terminated",
                    "Action": "Delete existing notebook image"}
             result.write(json.dumps(res))
diff --git a/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py b/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py
index 7ff8d2472..83efb9edb 100644
--- a/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py
+++ b/infrastructure-provisioning/src/general/scripts/gcp/common_terminate_notebook_image.py
@@ -52,6 +52,9 @@ if __name__ == "__main__":
             GCPActions.remove_image(image_conf['expected_secondary_image_name'])
         with open("/root/result.json", 'w') as result:
             res = {"notebook_image_name": image_conf['expected_primary_image_name'],
+                   "endpoint": image_conf['endpoint_name'],
+                   "project": image_conf['project_name'],
+                   "imageName": image_conf['image_name'],
                    "status": "terminated",
                    "Action": "Delete existing notebook image"}
             result.write(json.dumps(res))
diff --git a/services/provisioning-service/src/main/java/com/epam/datalab/backendapi/resources/ImageResource.java b/services/provisioning-service/src/main/java/com/epam/datalab/backendapi/resources/ImageResource.java
index 1e4347431..d6484bd50 100644
--- a/services/provisioning-service/src/main/java/com/epam/datalab/backendapi/resources/ImageResource.java
+++ b/services/provisioning-service/src/main/java/com/epam/datalab/backendapi/resources/ImageResource.java
@@ -63,7 +63,6 @@ public class ImageResource extends DockerService implements DockerCommands {
     @Path("/terminate")
     public Response terminateImage(@Auth UserInfo ui, ExploratoryImageDTO image) throws JsonProcessingException{
         final String uuid = DockerCommands.generateUUID();
-        log.info("terminate image dto {}",image);
 
         folderListenerExecutor.start(configuration.getImagesDirectory(), configuration.getResourceStatusPollTimeout(),
                 new ImageCreateCallbackHandler(selfService, uuid, DockerAction.TERMINATE_IMAGE, image));
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAO.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAO.java
index 068d5ed94..65ab9755a 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAO.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAO.java
@@ -37,7 +37,7 @@ public interface ImageExploratoryDAO {
     void updateImageFields(Image image);
 
     void updateImageStatus(String user, String imageName, String project, String endpoint, ImageStatus status);
-    void updateImageStatus(String fullName, ImageStatus status);
+    void updateImageStatus(String imageName, String projectName, String endpoint, ImageStatus status);
 
     List<ImageInfoRecord> getImages(String user, String dockerImage, String project, String endpoint, ImageStatus... statuses);
 
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAOImpl.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAOImpl.java
index a1106c58d..688a02f17 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAOImpl.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ImageExploratoryDAOImpl.java
@@ -78,10 +78,9 @@ public class ImageExploratoryDAOImpl extends BaseDAO implements ImageExploratory
         final Bson condition = userImageCondition(user, imageName, project, endpoint);
         updateOne(MongoCollections.IMAGES, condition, set(STATUS,status.toString()));
     }
-
     @Override
-    public void updateImageStatus(String fullName, ImageStatus status) {
-        updateOne(MongoCollections.IMAGES, eq(IMAGE_FULL_NAME, fullName), set(STATUS,status.toString()));
+    public void updateImageStatus(String imageName, String projectName, String endpoint, ImageStatus status) {
+        updateOne(MongoCollections.IMAGES, and(eq(IMAGE_NAME, imageName), eq(PROJECT, projectName), eq(ENDPOINT, endpoint)), set(STATUS,status.toString()));
     }
 
     @Override
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/callback/ImageCallback.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/callback/ImageCallback.java
index e05cd810d..a604bfce4 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/callback/ImageCallback.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/callback/ImageCallback.java
@@ -52,7 +52,7 @@ public class ImageCallback {
         log.debug("Updating status of image {} for user {} to {}", dto.getName(), dto.getUser(), dto);
         requestId.remove(dto.getRequestId());
         if(dto.getImageCreateDTO().getStatus() == ImageStatus.TERMINATED){
-            imageExploratoryService.finishTerminateImage(dto.getImageCreateDTO().getExternalName());
+            imageExploratoryService.finishTerminateImage(dto.getName(), dto.getProject(), dto.getEndpoint());
         } else {
             imageExploratoryService.finishImageCreate(getImage(dto), dto.getExploratoryName(), dto.getImageCreateDTO()
                     .getIp());
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java
index 889aa8f44..e368ae471 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ImageExploratoryService.java
@@ -33,8 +33,7 @@ public interface ImageExploratoryService {
     String createImage(UserInfo user, String project, String exploratoryName, String imageName, String imageDescription, String info);
 
     void terminateImage(UserInfo user, String project, String endpoint, String imageName);
-
-    void finishTerminateImage(String fullImageName);
+    void finishTerminateImage(String imageName, String projectName, String endpoint);
 
     void finishImageCreate(Image image, String exploratoryName, String newNotebookIp);
 
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java
index b86ad1f02..fe0af1fb4 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ImageExploratoryServiceImpl.java
@@ -164,8 +164,8 @@ public class ImageExploratoryServiceImpl implements ImageExploratoryService {
     }
 
     @Override
-    public void finishTerminateImage(String fullImageName) {
-        imageExploratoryDao.updateImageStatus(fullImageName, ImageStatus.TERMINATED);
+    public void finishTerminateImage(String imageName, String projectName, String endpoint) {
+        imageExploratoryDao.updateImageStatus(imageName, projectName, endpoint, ImageStatus.TERMINATED);
     }
 
     @Override


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org