YARN-8204. Added a flag to disable YARN service upgrade.
Contributed by Chandni Singh
(cherry picked from commit 14b47990af
)
This commit is contained in:
parent
90a31dc61c
commit
0e19c0dd72
|
@ -74,6 +74,7 @@ import org.apache.hadoop.yarn.service.containerlaunch.ClasspathConstructor;
|
||||||
import org.apache.hadoop.yarn.service.containerlaunch.JavaCommandLineBuilder;
|
import org.apache.hadoop.yarn.service.containerlaunch.JavaCommandLineBuilder;
|
||||||
import org.apache.hadoop.yarn.service.exceptions.BadClusterStateException;
|
import org.apache.hadoop.yarn.service.exceptions.BadClusterStateException;
|
||||||
import org.apache.hadoop.yarn.service.exceptions.BadConfigException;
|
import org.apache.hadoop.yarn.service.exceptions.BadConfigException;
|
||||||
|
import org.apache.hadoop.yarn.service.exceptions.ErrorStrings;
|
||||||
import org.apache.hadoop.yarn.service.exceptions.SliderException;
|
import org.apache.hadoop.yarn.service.exceptions.SliderException;
|
||||||
import org.apache.hadoop.yarn.service.provider.AbstractClientProvider;
|
import org.apache.hadoop.yarn.service.provider.AbstractClientProvider;
|
||||||
import org.apache.hadoop.yarn.service.provider.ProviderUtils;
|
import org.apache.hadoop.yarn.service.provider.ProviderUtils;
|
||||||
|
@ -224,6 +225,12 @@ public class ServiceClient extends AppAdminClient implements SliderExitCodes,
|
||||||
|
|
||||||
public int initiateUpgrade(Service service) throws YarnException,
|
public int initiateUpgrade(Service service) throws YarnException,
|
||||||
IOException {
|
IOException {
|
||||||
|
boolean upgradeEnabled = getConfig().getBoolean(
|
||||||
|
YARN_SERVICE_UPGRADE_ENABLED,
|
||||||
|
YARN_SERVICE_UPGRADE_ENABLED_DEFAULT);
|
||||||
|
if (!upgradeEnabled) {
|
||||||
|
throw new YarnException(ErrorStrings.SERVICE_UPGRADE_DISABLED);
|
||||||
|
}
|
||||||
Service persistedService =
|
Service persistedService =
|
||||||
ServiceApiUtil.loadService(fs, service.getName());
|
ServiceApiUtil.loadService(fs, service.getName());
|
||||||
if (!StringUtils.isEmpty(persistedService.getId())) {
|
if (!StringUtils.isEmpty(persistedService.getId())) {
|
||||||
|
|
|
@ -127,6 +127,13 @@ public class YarnServiceConf {
|
||||||
public static final String YARN_SERVICE_CONTAINER_HEALTH_THRESHOLD_PREFIX =
|
public static final String YARN_SERVICE_CONTAINER_HEALTH_THRESHOLD_PREFIX =
|
||||||
YARN_SERVICE_PREFIX + "container-health-threshold.";
|
YARN_SERVICE_PREFIX + "container-health-threshold.";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Upgrade feature enabled for services.
|
||||||
|
*/
|
||||||
|
public static final String YARN_SERVICE_UPGRADE_ENABLED =
|
||||||
|
"yarn.service.upgrade.enabled";
|
||||||
|
public static final boolean YARN_SERVICE_UPGRADE_ENABLED_DEFAULT = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The container health threshold percent when explicitly set for a specific
|
* The container health threshold percent when explicitly set for a specific
|
||||||
* component or globally for all components, will schedule a health check
|
* component or globally for all components, will schedule a health check
|
||||||
|
|
|
@ -39,4 +39,6 @@ public interface ErrorStrings {
|
||||||
"Too many arguments";
|
"Too many arguments";
|
||||||
String ERROR_DUPLICATE_ENTRY = "Duplicate entry for ";
|
String ERROR_DUPLICATE_ENTRY = "Duplicate entry for ";
|
||||||
|
|
||||||
|
String SERVICE_UPGRADE_DISABLED = "Service upgrade is disabled.";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -375,6 +375,7 @@ public class TestYarnNativeServices extends ServiceTestUtils {
|
||||||
@Test(timeout = 200000)
|
@Test(timeout = 200000)
|
||||||
public void testUpgrade() throws Exception {
|
public void testUpgrade() throws Exception {
|
||||||
setupInternal(NUM_NMS);
|
setupInternal(NUM_NMS);
|
||||||
|
getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
|
||||||
ServiceClient client = createClient(getConf());
|
ServiceClient client = createClient(getConf());
|
||||||
|
|
||||||
Service service = createExampleApplication();
|
Service service = createExampleApplication();
|
||||||
|
|
|
@ -39,6 +39,8 @@ import org.apache.hadoop.yarn.service.api.records.Component;
|
||||||
import org.apache.hadoop.yarn.service.api.records.Container;
|
import org.apache.hadoop.yarn.service.api.records.Container;
|
||||||
import org.apache.hadoop.yarn.service.api.records.Service;
|
import org.apache.hadoop.yarn.service.api.records.Service;
|
||||||
import org.apache.hadoop.yarn.service.api.records.ServiceState;
|
import org.apache.hadoop.yarn.service.api.records.ServiceState;
|
||||||
|
import org.apache.hadoop.yarn.service.conf.YarnServiceConf;
|
||||||
|
import org.apache.hadoop.yarn.service.exceptions.ErrorStrings;
|
||||||
import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
|
import org.apache.hadoop.yarn.service.utils.ServiceApiUtil;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
|
@ -66,10 +68,27 @@ public class TestServiceClient {
|
||||||
public ServiceTestUtils.ServiceFSWatcher rule =
|
public ServiceTestUtils.ServiceFSWatcher rule =
|
||||||
new ServiceTestUtils.ServiceFSWatcher();
|
new ServiceTestUtils.ServiceFSWatcher();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testUpgradeDisabledByDefault() throws Exception {
|
||||||
|
Service service = createService();
|
||||||
|
ServiceClient client = MockServiceClient.create(rule, service, false);
|
||||||
|
|
||||||
|
//upgrade the service
|
||||||
|
service.setVersion("v2");
|
||||||
|
try {
|
||||||
|
client.initiateUpgrade(service);
|
||||||
|
} catch (YarnException ex) {
|
||||||
|
Assert.assertEquals(ErrorStrings.SERVICE_UPGRADE_DISABLED,
|
||||||
|
ex.getMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Assert.fail();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testActionServiceUpgrade() throws Exception {
|
public void testActionServiceUpgrade() throws Exception {
|
||||||
Service service = createService();
|
Service service = createService();
|
||||||
ServiceClient client = MockServiceClient.create(rule, service);
|
ServiceClient client = MockServiceClient.create(rule, service, true);
|
||||||
|
|
||||||
//upgrade the service
|
//upgrade the service
|
||||||
service.setVersion("v2");
|
service.setVersion("v2");
|
||||||
|
@ -85,7 +104,7 @@ public class TestServiceClient {
|
||||||
@Test
|
@Test
|
||||||
public void testActionCompInstanceUpgrade() throws Exception {
|
public void testActionCompInstanceUpgrade() throws Exception {
|
||||||
Service service = createService();
|
Service service = createService();
|
||||||
MockServiceClient client = MockServiceClient.create(rule, service);
|
MockServiceClient client = MockServiceClient.create(rule, service, true);
|
||||||
|
|
||||||
//upgrade the service
|
//upgrade the service
|
||||||
service.setVersion("v2");
|
service.setVersion("v2");
|
||||||
|
@ -127,7 +146,7 @@ public class TestServiceClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
static MockServiceClient create(ServiceTestUtils.ServiceFSWatcher rule,
|
static MockServiceClient create(ServiceTestUtils.ServiceFSWatcher rule,
|
||||||
Service service)
|
Service service, boolean enableUpgrade)
|
||||||
throws IOException, YarnException {
|
throws IOException, YarnException {
|
||||||
MockServiceClient client = new MockServiceClient();
|
MockServiceClient client = new MockServiceClient();
|
||||||
|
|
||||||
|
@ -163,7 +182,8 @@ public class TestServiceClient {
|
||||||
client.setFileSystem(rule.getFs());
|
client.setFileSystem(rule.getFs());
|
||||||
client.setYarnClient(yarnClient);
|
client.setYarnClient(yarnClient);
|
||||||
client.service = service;
|
client.service = service;
|
||||||
|
rule.getConf().setBoolean(YarnServiceConf.YARN_SERVICE_UPGRADE_ENABLED,
|
||||||
|
enableUpgrade);
|
||||||
client.init(rule.getConf());
|
client.init(rule.getConf());
|
||||||
client.start();
|
client.start();
|
||||||
client.actionCreate(service);
|
client.actionCreate(service);
|
||||||
|
|
Loading…
Reference in New Issue