Skip to content

Commit

Permalink
improve: delete service will delete local work data
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandas886 committed Jun 20, 2023
1 parent f551604 commit 9e65ca3
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,39 @@
*/
package org.dromara.cloudeon.processor;

import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.spring.SpringUtil;
import org.dromara.cloudeon.config.CloudeonConfigProp;
import org.dromara.cloudeon.dao.ServiceInstanceRepository;
import org.dromara.cloudeon.entity.ServiceInstanceEntity;
import org.dromara.cloudeon.entity.StackServiceEntity;
import org.dromara.cloudeon.service.DeleteClusterService;
import lombok.NoArgsConstructor;
import org.dromara.cloudeon.utils.Constant;

import java.io.File;

@NoArgsConstructor
public class DeleteServiceDBDataTask extends BaseCloudeonTask {

@Override
public void internalExecute() {
CloudeonConfigProp cloudeonConfigProp = SpringUtil.getBean(CloudeonConfigProp.class);
ServiceInstanceRepository serviceInstanceRepository = SpringUtil.getBean(ServiceInstanceRepository.class);
Integer serviceInstanceId = taskParam.getServiceInstanceId();
ServiceInstanceEntity serviceInstanceEntity = serviceInstanceRepository.findById(serviceInstanceId).get();
String workHome = cloudeonConfigProp.getWorkHome();
String workConfPath = workHome + File.separator + serviceInstanceEntity.getServiceName() ;
String k8sResourceOutputPath = workHome + File.separator + Constant.K8S_RESOURCE_DIR+File.separator+serviceInstanceEntity.getServiceName() ;
DeleteClusterService deleteClusterService = SpringUtil.getBean(DeleteClusterService.class);

log.info("开始删除 {} 服务相关的表数据....", taskParam.getServiceInstanceName());
deleteClusterService.deleteOneService(serviceInstanceId);

log.info("开始删除 {} 服务相关的本地数据 {}", taskParam.getServiceInstanceName(),workConfPath);
log.info("开始删除 {} 服务相关的本地数据 {}", taskParam.getServiceInstanceName(),k8sResourceOutputPath);
FileUtil.del(workConfPath);
FileUtil.del(k8sResourceOutputPath);

}
}

0 comments on commit 9e65ca3

Please sign in to comment.