Skip to content

Commit

Permalink
Merge pull request #8817 from sawyersong2/feat_8811_1.11
Browse files Browse the repository at this point in the history
feat: 修复kubernetes构建容器ID格式兼容 #8811
  • Loading branch information
irwinsun authored May 16, 2023
2 parents 1a1c8b0 + 6d29549 commit a8e1898
Showing 1 changed file with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.annotation.Value
import org.springframework.stereotype.Service
import java.util.Locale
import java.util.stream.Collectors

@Service("kubernetesContainerService")
Expand Down Expand Up @@ -203,7 +204,7 @@ class KubernetesContainerService @Autowired constructor(
KubernetesDockerRegistry(host, userName, password)
}

val builderName = getOnlyName(userId)
val builderName = getBuilderName()
val taskId = kubernetesBuilderClient.createBuilder(
buildId = buildId,
vmSeqId = vmSeqId,
Expand Down Expand Up @@ -405,13 +406,8 @@ class KubernetesContainerService @Autowired constructor(
return DispatchTaskResp(kubernetesJobClient.buildAndPushImage(userId, info))
}

private fun getOnlyName(userId: String): String {
val subUserId = if (userId.length > 14) {
userId.substring(0 until 14)
} else {
userId
}
return "${subUserId.replace("_", "-")}${System.currentTimeMillis()}-" +
RandomStringUtils.randomAlphabetic(8).toLowerCase()
private fun getBuilderName(): String {
return "build${System.currentTimeMillis()}-" +
RandomStringUtils.randomAlphabetic(8).lowercase(Locale.getDefault())
}
}

0 comments on commit a8e1898

Please sign in to comment.