Skip to content

Commit

Permalink
feat:handle container in pause status
Browse files Browse the repository at this point in the history
  • Loading branch information
newgene committed May 21, 2023
1 parent 050b8c9 commit 42c9580
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions biothings/hub/dataload/dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -2051,15 +2051,19 @@ def prepare_remote_container(self):
self.logger.exception(err)
raise DockerContainerException("Docker APIError when trying to get the container")

if self.container.status != "running":
if self.container.status == "pause":
self.logger.info('Unpause the container "%s" ...', self.CONTAINER_NAME)
self.container.unpause()
self.logger.info('The container "%s" is unpaused!', self.CONTAINER_NAME)
elif self.container.status != "running":
self.logger.info('Waiting for the container "%s"to run ...', self.CONTAINER_NAME)
self.container.start()
self.logger.info('The container "%s" is starting ...', self.CONTAINER_NAME)
count = 0
while self.container.status not in ["running", "exited"] and count < self.TIMEOUT:
count += 1
self.container.reload() # Load this object from the server again and update attrs with the new data
time.sleep(1)
count = 0
while self.container.status not in ["running", "exited"] and count < self.TIMEOUT:
count += 1
self.container.reload() # Load this object from the server again and update attrs with the new data
time.sleep(1)
self.logger.info('The container "%s" is now running!', self.CONTAINER_NAME)
self.container.reload()
if self.container.status == "exited":
Expand Down Expand Up @@ -2248,7 +2252,7 @@ def delete_or_restore_container(self):
if not self.KEEP_CONTAINER:
self.logger.warning(
f'The container is pre-existing, "{self.container.name}", but "keep_container" is set to False. '
'We will ignore the "keep_container" setting, will not remove the container.'
'We will ignore the "keep_container" setting, and won\'t remove the container.'
)
if self.container.status == self.ORIGINAL_CONTAINER_STATUS:
# container is in the original status, do nothing
Expand Down

0 comments on commit 42c9580

Please sign in to comment.