feat: add log for ContainerService

This commit is contained in:
tjq 2023-07-12 20:45:38 +08:00
parent 00228f3b3e
commit 67a22e8b7e
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,10 @@
package tech.powerjob.common.exception;
/**
* ImpossibleException
*
* @author tjq
* @since 2023/7/12
*/
public class ImpossibleException extends RuntimeException {
}

View File

@ -26,6 +26,7 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import tech.powerjob.common.OmsConstant;
import tech.powerjob.common.exception.ImpossibleException;
import tech.powerjob.common.model.DeployedContainerInfo;
import tech.powerjob.common.model.GitRepoInfo;
import tech.powerjob.common.request.ServerDeployContainerRequest;
@ -149,6 +150,8 @@ public class ContainerService {
*/
public String uploadContainerJarFile(MultipartFile file) throws IOException {
log.info("[ContainerService] start to uploadContainerJarFile, fileName={},size={}", file.getName(), file.getSize());
String workerDirStr = OmsFileUtils.genTemporaryWorkPath();
String tmpFileStr = workerDirStr + "tmp.jar";
@ -175,9 +178,14 @@ public class ContainerService {
}
FileUtils.moveFile(tmpFile, finalFile);
log.info("[ContainerService] uploadContainerJarFile successfully,md5={}", md5);
return md5;
}finally {
} catch (Throwable t) {
log.error("[ContainerService] uploadContainerJarFile failed!", t);
ExceptionUtils.rethrow(t);
throw new ImpossibleException();
} finally {
CommonUtils.executeIgnoreException(() -> FileUtils.forceDelete(workerDir));
}
}