|
@@ -109,7 +109,6 @@ public class ProjectUtil {
|
|
String key = "pod:" + podName + ":node";
|
|
String key = "pod:" + podName + ":node";
|
|
// 先删除 redis key
|
|
// 先删除 redis key
|
|
RedisUtil.deleteByKey(stringRedisTemplate, "pod:" + podName + ":node");
|
|
RedisUtil.deleteByKey(stringRedisTemplate, "pod:" + podName + ":node");
|
|
- RedisUtil.deleteByKey(stringRedisTemplate, "pod:" + podName + ":cpu");
|
|
|
|
KubernetesUtil.deletePod(apiClient, kubernetesConfiguration.getNamespace(), podName);
|
|
KubernetesUtil.deletePod(apiClient, kubernetesConfiguration.getNamespace(), podName);
|
|
|
|
|
|
log.info("deletePod() 等待 pod " + podName + " 的资源释放完成。");
|
|
log.info("deletePod() 等待 pod " + podName + " 的资源释放完成。");
|
|
@@ -176,7 +175,9 @@ public class ProjectUtil {
|
|
@SneakyThrows
|
|
@SneakyThrows
|
|
public void createNextPod3(String projectId, String nodeName, String lastPodName) {
|
|
public void createNextPod3(String projectId, String nodeName, String lastPodName) {
|
|
//1 删除上一个 pod 和 redis 键值对 和 旧的 yaml 文件
|
|
//1 删除上一个 pod 和 redis 键值对 和 旧的 yaml 文件
|
|
|
|
+ String cpuOrderString = stringRedisTemplate.opsForValue().get("pod:" + lastPodName + ":cpu");
|
|
deletePod(lastPodName);
|
|
deletePod(lastPodName);
|
|
|
|
+ RedisUtil.deleteByKey(stringRedisTemplate, "pod:" + lastPodName + ":cpu");
|
|
//2 获取新的 yaml 信息
|
|
//2 获取新的 yaml 信息
|
|
final Set<String> yamlPathCacheKeySet = RedisUtil.getKeySetByPrefix(stringRedisTemplate, "project:" + projectId + ":node:" + nodeName + ":yaml");
|
|
final Set<String> yamlPathCacheKeySet = RedisUtil.getKeySetByPrefix(stringRedisTemplate, "project:" + projectId + ":node:" + nodeName + ":yaml");
|
|
if (CollectionUtil.isEmpty(yamlPathCacheKeySet)) {
|
|
if (CollectionUtil.isEmpty(yamlPathCacheKeySet)) {
|
|
@@ -187,7 +188,7 @@ public class ProjectUtil {
|
|
final String yamlPathCacheKey = new ArrayList<>(yamlPathCacheKeySet).get(0);
|
|
final String yamlPathCacheKey = new ArrayList<>(yamlPathCacheKeySet).get(0);
|
|
final String absolutePath = stringRedisTemplate.opsForValue().get(yamlPathCacheKey);
|
|
final String absolutePath = stringRedisTemplate.opsForValue().get(yamlPathCacheKey);
|
|
// 修改 cpu 编号
|
|
// 修改 cpu 编号
|
|
- String cpuOrderString = stringRedisTemplate.opsForValue().get("pod:" + lastPodName + ":cpu");
|
|
|
|
|
|
+
|
|
Optional.ofNullable(cpuOrderString).orElseThrow(() -> new RuntimeException("createNextPod2() pod " + lastPodName + " 缓存的 cpu 编号为空。"));
|
|
Optional.ofNullable(cpuOrderString).orElseThrow(() -> new RuntimeException("createNextPod2() pod " + lastPodName + " 缓存的 cpu 编号为空。"));
|
|
final String read = FileUtil.read(absolutePath);
|
|
final String read = FileUtil.read(absolutePath);
|
|
final String replace = read.replace("cpu-order", "\"" + cpuOrderString + "\"");
|
|
final String replace = read.replace("cpu-order", "\"" + cpuOrderString + "\"");
|