forked from TencentBlueKing/bk-job
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: 容器化环境支持无损更新 TencentBlueKing#2338
1. k8s环境下支持停止接收流量后延迟一段时间关闭Spring容器,用于无损更新/扩缩容; 2. 基础镜像增加网络调试相关工具。
- Loading branch information
Showing
9 changed files
with
67 additions
and
6 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
.../com/tencent/bk/job/common/consul/config/JobApplicationAvailabilityAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.tencent.bk.job.common.consul.config; | ||
|
||
import org.springframework.boot.availability.ApplicationAvailabilityBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
public class JobApplicationAvailabilityAutoConfiguration { | ||
|
||
@Bean | ||
public ApplicationAvailabilityBean applicationAvailability() { | ||
return new ApplicationAvailabilityBean(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
com.tencent.bk.job.common.consul.config.JobApplicationAvailabilityAutoConfiguration |
23 changes: 23 additions & 0 deletions
23
.../main/java/com/tencent/bk/job/common/k8s/availability/JobApplicationAvailabilityBean.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.tencent.bk.job.common.k8s.availability; | ||
|
||
import com.tencent.bk.job.common.util.ThreadUtils; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.boot.availability.ApplicationAvailabilityBean; | ||
import org.springframework.boot.availability.AvailabilityChangeEvent; | ||
import org.springframework.boot.availability.ReadinessState; | ||
|
||
@Slf4j | ||
public class JobApplicationAvailabilityBean extends ApplicationAvailabilityBean { | ||
@Override | ||
public void onApplicationEvent(AvailabilityChangeEvent<?> event) { | ||
super.onApplicationEvent(event); | ||
if (ReadinessState.REFUSING_TRAFFIC == event.getState()) { | ||
// SpringCloud负载均衡缓存默认为35s,等待调用方缓存刷新后再真正关闭Spring容器 | ||
int waitSeconds = 35; | ||
while (waitSeconds > 0) { | ||
ThreadUtils.sleep(1000); | ||
log.info("wait for GracefulShutdown, {}s left", waitSeconds--); | ||
} | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
...ava/com/tencent/bk/job/common/k8s/config/JobApplicationAvailabilityAutoConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.tencent.bk.job.common.k8s.config; | ||
|
||
import com.tencent.bk.job.common.k8s.availability.JobApplicationAvailabilityBean; | ||
import org.springframework.boot.availability.ApplicationAvailabilityBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration(proxyBeanMethods = false) | ||
public class JobApplicationAvailabilityAutoConfiguration { | ||
|
||
@Bean | ||
public ApplicationAvailabilityBean applicationAvailability() { | ||
return new JobApplicationAvailabilityBean(); | ||
} | ||
|
||
} |
3 changes: 2 additions & 1 deletion
3
src/backend/commons/common-k8s/src/main/resources/META-INF/spring.factories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\ | ||
com.tencent.bk.job.common.k8s.config.K8sServiceInfoServiceAutoConfig | ||
com.tencent.bk.job.common.k8s.config.K8sServiceInfoServiceAutoConfig,\ | ||
com.tencent.bk.job.common.k8s.config.JobApplicationAvailabilityAutoConfiguration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM bkjob/jdk:0.0.2 | ||
FROM bkjob/jdk:0.0.3 | ||
|
||
LABEL maintainer="Tencent BlueKing Job" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters