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

Fix graceful shutdown notify failure #1630

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions .github/actions/scenarios/spring/graceful/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ runs:
grace.rule.enableGraceShutdown: true
grace.rule.enableOfflineNotify: true
grace.rule.warmUpTime: 600
grace.rule.upstreamAddressExpiredTime: 600
servicecomb.service.enableSpringRegister: true
servicecomb.service.preferIpAddress: true
# graceful-rest-provider service port 8443 do not change, it special for springCloud Edgware.SR2 test ssl feature.
Expand Down Expand Up @@ -67,15 +66,24 @@ runs:
bash ./sermant-integration-tests/scripts/checkService.sh http://127.0.0.1:8014/testGraceful 60
- name: test graceful up
shell: bash
run: mvn test -Dsermant.integration.test.type=GRACEFUL -Dgraceful.test.type=up --file sermant-integration-tests/spring-test/pom.xml
- name: test graceful down
run: |
mvn test -Dsermant.integration.test.type=GRACEFUL_FEIGN -Dgraceful.test.type=up --file sermant-integration-tests/spring-test/pom.xml
mvn test -Dsermant.integration.test.type=GRACEFUL_REST -Dgraceful.test.type=up --file sermant-integration-tests/spring-test/pom.xml
- name: test rest graceful down
shell: bash
run: |
jps -l | grep graceful-feign-provider | awk '{print $1}' | xargs -n 1 kill
jps -l | grep graceful-rest-provider | awk '{print $1}' | xargs -n 1 kill
echo "========start test graceful======="
echo "========start test rest graceful======="
jps -l
mvn test -Dsermant.integration.test.type=GRACEFUL_REST -Dgraceful.test.type=down --file sermant-integration-tests/spring-test/pom.xml
- name: test feign graceful down
shell: bash
run: |
mvn test -Dsermant.integration.test.type=GRACEFUL_FEIGN -Ddown.request.count=100 -Dgraceful.test.type=down --file sermant-integration-tests/spring-test/pom.xml
jps -l | grep graceful-feign-provider | awk '{print $1}' | xargs -n 1 kill
echo "========start test feign graceful======="
jps -l
mvn test -Dsermant.integration.test.type=GRACEFUL -Dgraceful.test.type=down --file sermant-integration-tests/spring-test/pom.xml
mvn test -Dsermant.integration.test.type=GRACEFUL_FEIGN -Dgraceful.test.type=down --file sermant-integration-tests/spring-test/pom.xml
- name: exit
if: always()
uses: ./.github/actions/common/exit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author zhouss
* @since 2022-11-15
*/
@EnabledIfSystemProperty(named = "sermant.integration.test.type", matches = "GRACEFUL")
@EnabledIfSystemProperty(named = "sermant.integration.test.type", matches = "GRACEFUL_FEIGN")
public class FeignGracefulTest extends GracefulTest {
@Override
protected String getBaseUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public abstract class GracefulTest {

private static final int UP_REQUEST_COUNT = 500;

private static final int DOWN_REQUEST_COUNT = 1000;
private static final String DOWN_REQUEST_COUNT = "1000";

private final String url = getBaseUrl();

Expand Down Expand Up @@ -104,7 +104,7 @@ public void testGracefulDown() {
return;
}
try {
for (int i = 0; i < DOWN_REQUEST_COUNT; i++) {
for (int i = 0; i < getDownRequestCount(); i++) {
RequestUtils.get(buildUrl("testGraceful"), Collections.emptyMap(), String.class);
}
} catch (Exception exception) {
Expand All @@ -113,6 +113,10 @@ public void testGracefulDown() {
}
}

private int getDownRequestCount() {
return Integer.parseInt(EnvUtils.getEnv("down.request.count", DOWN_REQUEST_COUNT));
}

private void statistic(Map<String, Integer> statisticMap) {
final String port = RequestUtils.get(buildUrl("testGraceful"), Collections.emptyMap(),
String.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* @author zhouss
* @since 2022-11-15
*/
@EnabledIfSystemProperty(named = "sermant.integration.test.type", matches = "GRACEFUL")
@EnabledIfSystemProperty(named = "sermant.integration.test.type", matches = "GRACEFUL_REST")
public class RestGracefulTest extends GracefulTest {
@Override
protected String getBaseUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,6 @@ public class GraceConfig implements PluginConfig, Cloneable {
*/
private long upstreamAddressExpiredTime = GraceConstants.UPSTREAM_ADDRESS_DEFAULT_EXPIRED_TIME;

/**
* Cache the wait time of notifying upstream addresses
*/
private long waitNotifyTime = GraceConstants.WAIT_NOTIFY_TIME;

/**
* Correct the relevant switch attributes according to the aggregation switch,
* and turn on all functions of elegant online and offline with one click
Expand Down Expand Up @@ -267,14 +262,6 @@ public void setUpstreamAddressExpiredTime(long upstreamAddressExpiredTime) {
this.upstreamAddressExpiredTime = upstreamAddressExpiredTime;
}

public long getWaitNotifyTime() {
return waitNotifyTime;
}

public void setWaitNotifyTime(long waitNotifyTime) {
this.waitNotifyTime = waitNotifyTime;
}

/**
* Check whether the preheating parameter is valid
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ public class GraceConstants {
*/
public static final long UPSTREAM_ADDRESS_DEFAULT_EXPIRED_TIME = 60L;

/**
* The default wait time of notifying upstream addresses
*/
public static final long WAIT_NOTIFY_TIME = 20L;

/**
* Maximum port
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import io.sermant.core.plugin.subscribe.DefaultGroupConfigSubscriber;
import io.sermant.core.service.dynamicconfig.common.DynamicConfigEvent;
import io.sermant.core.service.dynamicconfig.common.DynamicConfigListener;
import io.sermant.registry.entity.GraceShutdownHook;

import java.util.Locale;
import java.util.logging.Logger;
Expand Down Expand Up @@ -66,9 +65,6 @@ private void fixGrace() {
// and this configuration has the highest priority
final GraceConfig graceConfig = PluginConfigManager.getPluginConfig(GraceConfig.class);
graceConfig.fixGraceSwitch();
if (graceConfig.isEnableSpring() && graceConfig.isEnableGraceShutdown()) {
Runtime.getRuntime().addShutdownHook(new GraceShutdownHook());
}
}

/**
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private static void refreshWithSpringLb(String serviceName, Collection<String> r
"Can not refresh service [%s] instance cache with spring loadbalancer!", curServiceName));
return;
}
LOGGER.fine(String.format(Locale.ENGLISH,
LOGGER.info(String.format(Locale.ENGLISH,
"Start refresh target service [%s] spring loadbalancer instance cache!", curServiceName));
final Optional<Object> cacheOptional = ReflectUtils.invokeMethod(loadBalancerCacheManager, "getCache",
new Class[]{String.class}, new Object[]{GraceConstants.SPRING_CACHE_MANAGER_LOADBALANCER_CACHE_NAME});
Expand All @@ -112,7 +112,7 @@ private static void refreshWithSpringLb(String serviceName, Collection<String> r

private static void refreshWithRibbon(Object loadbalancer) {
final Optional<Object> serviceName = ReflectUtils.getFieldValue(loadbalancer, "name");
LOGGER.fine(String.format(Locale.ENGLISH,
LOGGER.info(String.format(Locale.ENGLISH,
"Start refresh target service [%s] ribbon instance cache!", serviceName.orElse("unKnow service")));
ReflectUtils.invokeMethod(loadbalancer, "updateListOfServers", null, null);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@

package io.sermant.registry.grace.interceptors;

import io.sermant.registry.config.GraceConfig;
import io.sermant.registry.config.RegisterConfig;
import io.sermant.registry.services.GraceService;

import io.sermant.core.plugin.agent.entity.ExecuteContext;
import io.sermant.core.plugin.config.PluginConfigManager;
import io.sermant.core.plugin.service.PluginServiceManager;
import io.sermant.registry.config.GraceConfig;
import io.sermant.registry.config.RegisterConfig;
import io.sermant.registry.services.GraceService;

import org.junit.After;
import org.junit.Assert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@

package io.sermant.registry.inject.grace;

import io.sermant.core.plugin.config.PluginConfigManager;
import io.sermant.core.plugin.service.PluginServiceManager;
import io.sermant.registry.config.GraceConfig;
import io.sermant.registry.config.grace.GraceConstants;
import io.sermant.registry.config.grace.GraceContext;
import io.sermant.registry.services.GraceService;

import io.sermant.core.plugin.config.PluginConfigManager;
import io.sermant.core.plugin.service.PluginServiceManager;

import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
Expand Down
Loading
Loading