YARN-8204. Added a flag to disable YARN service upgrade.
Contributed by Chandni Singh
This commit is contained in:
parent
9ab3f97089
commit
14b47990af
|
@ -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.exceptions.BadClusterStateException;
|
||||
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.provider.AbstractClientProvider;
|
||||
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,
|
||||
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 =
|
||||
ServiceApiUtil.loadService(fs, service.getName());
|
||||
if (!StringUtils.isEmpty(persistedService.getId())) {
|
||||
|
|
|
@ -127,6 +127,13 @@ public class YarnServiceConf {
|
|||
public static final String YARN_SERVICE_CONTAINER_HEALTH_THRESHOLD_PREFIX =
|
||||
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
|
||||
* component or globally for all components, will schedule a health check
|
||||
|
|
|
@ -39,4 +39,6 @@ public interface ErrorStrings {
|
|||
"Too many arguments";
|
||||
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)
|
||||
public void testUpgrade() throws Exception {
|
||||
setupInternal(NUM_NMS);
|
||||
getConf().setBoolean(YARN_SERVICE_UPGRADE_ENABLED, true);
|
||||
ServiceClient client = createClient(getConf());
|
||||
|
||||
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.Service;
|
||||
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.junit.Assert;
|
||||
import org.junit.Rule;
|
||||
|
@ -66,10 +68,27 @@ public class TestServiceClient {
|
|||
public ServiceTestUtils.ServiceFSWatcher rule =
|
||||
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
|
||||
public void testActionServiceUpgrade() throws Exception {
|
||||
Service service = createService();
|
||||
ServiceClient client = MockServiceClient.create(rule, service);
|
||||
ServiceClient client = MockServiceClient.create(rule, service, true);
|
||||
|
||||
//upgrade the service
|
||||
service.setVersion("v2");
|
||||
|
@ -85,7 +104,7 @@ public class TestServiceClient {
|
|||
@Test
|
||||
public void testActionCompInstanceUpgrade() throws Exception {
|
||||
Service service = createService();
|
||||
MockServiceClient client = MockServiceClient.create(rule, service);
|
||||
MockServiceClient client = MockServiceClient.create(rule, service, true);
|
||||
|
||||
//upgrade the service
|
||||
service.setVersion("v2");
|
||||
|
@ -127,7 +146,7 @@ public class TestServiceClient {
|
|||
}
|
||||
|
||||
static MockServiceClient create(ServiceTestUtils.ServiceFSWatcher rule,
|
||||
Service service)
|
||||
Service service, boolean enableUpgrade)
|
||||
throws IOException, YarnException {
|
||||
MockServiceClient client = new MockServiceClient();
|
||||
|
||||
|
@ -163,7 +182,8 @@ public class TestServiceClient {
|
|||
client.setFileSystem(rule.getFs());
|
||||
client.setYarnClient(yarnClient);
|
||||
client.service = service;
|
||||
|
||||
rule.getConf().setBoolean(YarnServiceConf.YARN_SERVICE_UPGRADE_ENABLED,
|
||||
enableUpgrade);
|
||||
client.init(rule.getConf());
|
||||
client.start();
|
||||
client.actionCreate(service);
|
||||
|
|
Loading…
Reference in New Issue