Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1088] support graceful upper and down #1089

Merged
merged 6 commits into from
Nov 3, 2023
Merged

[#1088] support graceful upper and down #1089

merged 6 commits into from
Nov 3, 2023

Conversation

chengyouling
Copy link
Collaborator

No description provided.

@codecov-commenter
Copy link

codecov-commenter commented Nov 1, 2023

Codecov Report

Attention: 14 lines in your changes are missing coverage. Please review.

Comparison is base (2f248ce) 0.00% compared to head (970be40) 0.00%.

❗ Current head 970be40 differs from pull request most recent head 7430a73. Consider uploading reports for the commit 7430a73 to get more accurate results

Additional details and impacted files
@@          Coverage Diff           @@
##           master   #1089   +/-   ##
======================================
  Coverage    0.00%   0.00%           
======================================
  Files         117     119    +2     
  Lines        2276    2290   +14     
  Branches      194     196    +2     
======================================
- Misses       2276    2290   +14     
Files Coverage Δ
...mon/configration/dynamic/GovernanceProperties.java 0.00% <ø> (ø)
...graceful/ServicecombGracefulAutoConfiguration.java 0.00% <0.00%> (ø)
...iscovery/graceful/ServicecombGracefulEndpoint.java 0.00% <0.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -42,6 +42,10 @@
<groupId>com.huaweicloud</groupId>
<artifactId>spring-cloud-huawei-router</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be provided scope.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@ConditionalOnNacosDiscoveryEnabled
public class NacosGracefulAutoConfiguration {
@Bean
@ConditionalOnProperty(value = GovernanceProperties.NACOS_GRASEFUL_UPPER_DOWN, havingValue = "true")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if actuator relate class exists and enable on demand

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 59 to 65
if (GovernanceProperties.GRASEFUL_STATUS_UPPER.equalsIgnoreCase(status)) {
nacosDiscoveryProperties.setRegisterEnabled(true);
nacosAutoServiceRegistration.start();
} else if (GovernanceProperties.GRASEFUL_STATUS_DOWN.equalsIgnoreCase(status)) {
nacosServiceRegistry.deregister(nacosRegistration);
} else {
LOGGER.warn("status input " + status + " is not a valid value.");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can registration be started/deploy for multi times? This case should carefully tested.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add isRegistry for condition

return;
}
if (GovernanceProperties.GRASEFUL_STATUS_UPPER.equalsIgnoreCase(status)) {
nacosDiscoveryProperties.setRegisterEnabled(true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RegisterEnabled 可能产生二义性。 用户配置了这个配置项, 目的是不启用注册中心,还是需要使用这个特性? 在这个特性之前是前者。 所以使用该配置项, 会丢失特性

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

registerEnabled是false的时候,AbstractAutoServiceRegistration的start方法中在第一个isEnabled()条件判断处直接返回,不会更新registion中的端口号,需要重新启动start方法去完成注册。

@@ -56,13 +60,14 @@ public void gracefulUpperAndDown(@Nullable String status) {
if (StringUtils.isEmpty(status)) {
return;
}
if (GovernanceProperties.GRASEFUL_STATUS_UPPER.equalsIgnoreCase(status)) {
if (!isRegistry.get() && GovernanceProperties.GRASEFUL_STATUS_UPPER.equalsIgnoreCase(status)) {
Copy link
Collaborator

@liubao68 liubao68 Nov 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use getAndSet here and check GovernanceProperties.GRASEFUL_STATUS_UPPER.equalsIgnoreCase(status) first

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

nacosServiceRegistry.deregister(nacosRegistration);
} else {
LOGGER.warn("status input " + status + " is not a valid value.");
LOGGER.warn("operation not allow, status: " + status);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is not allowed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@liubao68 liubao68 merged commit 15b689a into master Nov 3, 2023
1 check passed
@chengyouling chengyouling deleted the master-graceful branch November 8, 2023 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants