Skip to content
Snippets Groups Projects
Commit c76d186e authored by Lukasz Lopatowski's avatar Lukasz Lopatowski
Browse files

Some methods and classes renaming

parent ed7e46c4
No related branches found
No related tags found
2 merge requests!273Release 1.8.0 update,!268Resolve "Add application instance scaling support"
Pipeline #95414 passed
Showing
with 284 additions and 129 deletions
......@@ -28,12 +28,13 @@ To run the nmaas Platform on a dedicated machine, perform the following steps:
+ *--Dlogback.configurationFile* specifying the name of logger configuration file (located in the same directory as the jar file) to be loaded instead of the built-in one. Please be advised that you have to add that parameter before the *-jar* parameter.
+ *--spring.config.name* specifying the name of the properties file (located in the same directory as the jar file) to be loaded instead of the built-in one.
### Swagger documentation of the nmaas Platform REST API
### OpenAPI documentation of the nmaas Platform REST API
nmaas Platform by default exposes two endpoints documenting the REST API:
+ */api-docs/spec* - Open API specification of the API
+ */api-docs/ui.html* - Swagger UI
The Swagger endpoint can be disabled in properties file.
These endpoints can be disabled in properties file.
### Populating nmaas Platform database with initial data
......
package net.geant.nmaas.nmservice.deployment;
import net.geant.nmaas.nmservice.deployment.exceptions.ContainerCheckFailedException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotVerifyNmServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotVerifyServiceException;
import net.geant.nmaas.orchestration.Identifier;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@ExtendWith(SpringExtension.class)
@SpringBootTest
public class NmServiceVerificationTest {
@Mock
private ContainerOrchestrator orchestrator;
@Mock
private ApplicationEventPublisher applicationEventPublisher;
private final ContainerOrchestrator orchestrator = mock(ContainerOrchestrator.class);
private final ApplicationEventPublisher eventPublisher = mock(ApplicationEventPublisher.class);
private NmServiceDeploymentCoordinator provider;
@BeforeEach
void setup() {
provider = new NmServiceDeploymentCoordinator(orchestrator, applicationEventPublisher);
provider = new NmServiceDeploymentCoordinator(orchestrator, eventPublisher);
provider.serviceDeploymentCheckMaxWaitTime = 5;
provider.serviceDeploymentCheckInternal = 1;
}
......@@ -55,7 +48,7 @@ public class NmServiceVerificationTest {
@Test
void shouldVerifyDeploymentFailure() {
assertThrows(CouldNotVerifyNmServiceException.class, () -> {
assertThrows(CouldNotVerifyServiceException.class, () -> {
when(orchestrator.checkService(any()))
.thenReturn(false)
.thenReturn(false)
......@@ -68,7 +61,7 @@ public class NmServiceVerificationTest {
@Test
void shouldThrowExceptionWhenUnexpectedErrorOccurs() {
assertThrows(CouldNotVerifyNmServiceException.class, () -> {
assertThrows(CouldNotVerifyServiceException.class, () -> {
when(orchestrator.checkService(any())).thenThrow(new ContainerCheckFailedException(""));
provider.verifyService(Identifier.newInstance("id"));
});
......
......@@ -9,7 +9,7 @@ import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.en
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.entities.KubernetesTemplate;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.entities.ServiceAccessMethodType;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.entities.ServiceStorageVolumeType;
import net.geant.nmaas.nmservice.deployment.exceptions.NmServiceRequestVerificationException;
import net.geant.nmaas.nmservice.deployment.exceptions.ServiceRequestVerificationException;
import net.geant.nmaas.orchestration.Identifier;
import net.geant.nmaas.orchestration.entities.AppAccessMethod;
import net.geant.nmaas.orchestration.entities.AppDeployment;
......@@ -121,7 +121,7 @@ class ServiceDeploymentWithKubernetesTest {
AppDeployment appDeployment = appDeployment(null);
appDeploymentSpec.setSupportedDeploymentEnvironments(Collections.emptyList());
appDeploymentSpec.setKubernetesTemplate(new KubernetesTemplate());
assertThrows(NmServiceRequestVerificationException.class, () -> {
assertThrows(ServiceRequestVerificationException.class, () -> {
orchestrator.verifyDeploymentEnvironmentSupportAndBuildNmServiceInfo(null, appDeployment, appDeploymentSpec);
});
}
......
......@@ -3,12 +3,12 @@ package net.geant.nmaas.nmservice.deployment;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.entities.KubernetesTemplate;
import net.geant.nmaas.nmservice.deployment.exceptions.ContainerCheckFailedException;
import net.geant.nmaas.nmservice.deployment.exceptions.ContainerOrchestratorInternalErrorException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotDeployNmServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotDeployServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotPrepareEnvironmentException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRemoveNmServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRestartNmServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRemoveServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRestartServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotUpgradeKubernetesServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.NmServiceRequestVerificationException;
import net.geant.nmaas.nmservice.deployment.exceptions.ServiceRequestVerificationException;
import net.geant.nmaas.orchestration.AppComponentDetails;
import net.geant.nmaas.orchestration.AppComponentLogs;
import net.geant.nmaas.orchestration.AppUiAccessDetails;
......@@ -35,10 +35,10 @@ public interface ContainerOrchestrator {
* Verifies if currently used container orchestrator is on the list of supported deployment environments specified
* for NM service being requested and if so creates proper NM service info object.
*
* @param deploymentId unique identifier of service deployment
* @param appDeployment deployment details provided by user
* @param deploymentId unique identifier of service deployment
* @param appDeployment deployment details provided by user
* @param appDeploymentSpec additional information specific to given application deployment
* @throws NmServiceRequestVerificationException if current deployment environment is not supported by the application
* @throws ServiceRequestVerificationException if current deployment environment is not supported by the application
*/
void verifyDeploymentEnvironmentSupportAndBuildNmServiceInfo(Identifier deploymentId, AppDeployment appDeployment, AppDeploymentSpec appDeploymentSpec);
......@@ -47,7 +47,7 @@ public interface ContainerOrchestrator {
* running services and other constraints.
*
* @param deploymentId unique identifier of service deployment
* @throws NmServiceRequestVerificationException if service deployment is currently not possible
* @throws ServiceRequestVerificationException if service deployment is currently not possible
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
*/
void verifyRequestAndObtainInitialDeploymentDetails(Identifier deploymentId);
......@@ -55,9 +55,9 @@ public interface ContainerOrchestrator {
/**
* Executes all initial configuration steps in order to enable further deployment of the NM service.
*
* @param deploymentId unique identifier of service deployment
* @param deploymentId unique identifier of service deployment
* @param configFileRepositoryRequired indicates if GitLab instance is required during deployment
* @throws CouldNotPrepareEnvironmentException if any of the environment preparation steps failed
* @throws CouldNotPrepareEnvironmentException if any of the environment preparation steps failed
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
*/
void prepareDeploymentEnvironment(Identifier deploymentId, boolean configFileRepositoryRequired);
......@@ -66,7 +66,7 @@ public interface ContainerOrchestrator {
* Performs the actual NM service containers deployment.
*
* @param deploymentId unique identifier of service deployment
* @throws CouldNotDeployNmServiceException if any of the service deployment steps failed
* @throws CouldNotDeployServiceException if any of the service deployment steps failed
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
*/
void deployNmService(Identifier deploymentId);
......@@ -75,9 +75,9 @@ public interface ContainerOrchestrator {
* Checks if NM service was successfully deployed and is running.
*
* @param deploymentId unique identifier of service deployment
* @throws ContainerCheckFailedException if some unexpected issue occurred during service deployment status check
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
* @return <code>true</code> if service was deployed successfully
* @throws ContainerCheckFailedException if some unexpected issue occurred during service deployment status check
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
*/
boolean checkService(Identifier deploymentId);
......@@ -110,8 +110,8 @@ public interface ContainerOrchestrator {
/**
* Retrieves logs from deployed service component.
*
* @param deploymentId unique identifier of service deployment
* @param serviceComponentName name of service component from which logs should be retrieved
* @param deploymentId unique identifier of service deployment
* @param serviceComponentName name of service component from which logs should be retrieved
* @param serviceSubComponentName name of service subcomponent (added if required)
* @return service component logs
* @throws ContainerOrchestratorInternalErrorException if access details are not available for any reason
......@@ -122,7 +122,7 @@ public interface ContainerOrchestrator {
* Triggers all the required actions to remove given NM service from the system.
*
* @param deploymentId unique identifier of service deployment
* @throws CouldNotRemoveNmServiceException if any of the service removal steps failed
* @throws CouldNotRemoveServiceException if any of the service removal steps failed
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
*/
void removeNmService(Identifier deploymentId);
......@@ -131,7 +131,7 @@ public interface ContainerOrchestrator {
* Triggers all the required actions to restart given NM service.
*
* @param deploymentId unique identifier of service deployment
* @throws CouldNotRestartNmServiceException if any of the service restart steps failed
* @throws CouldNotRestartServiceException if any of the service restart steps failed
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
*/
void restartNmService(Identifier deploymentId);
......@@ -139,11 +139,25 @@ public interface ContainerOrchestrator {
/**
* Triggers all the required actions to upgrade given NM service.
*
* @param deploymentId unique identifier of service deployment
* @param deploymentId unique identifier of service deployment
* @param kubernetesTemplate Helm chart information of the desired application version
* @throws CouldNotUpgradeKubernetesServiceException if any of the service restart steps failed
* @throws CouldNotUpgradeKubernetesServiceException if any of the service restart steps failed
* @throws ContainerOrchestratorInternalErrorException if some internal problem occurred during execution
*/
void upgradeKubernetesService(Identifier deploymentId, KubernetesTemplate kubernetesTemplate);
/**
* Pauses given service in order to save resources (such service can be resumed)
*
* @param deploymentId unique identifier of service deployment
*/
void pauseNmService(Identifier deploymentId);
/**
* Resumes given service
*
* @param deploymentId unique identifier of service deployment
*/
void resumeNmService(Identifier deploymentId);
}
......@@ -3,10 +3,22 @@ package net.geant.nmaas.nmservice.deployment;
import lombok.RequiredArgsConstructor;
import net.geant.nmaas.kubernetes.KubernetesClientSetupException;
import net.geant.nmaas.nmservice.NmServiceDeploymentStateChangeEvent;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.KServiceOperationsManager;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.entities.KubernetesTemplate;
import net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState;
import net.geant.nmaas.nmservice.deployment.exceptions.*;
import net.geant.nmaas.nmservice.deployment.exceptions.ContainerCheckFailedException;
import net.geant.nmaas.nmservice.deployment.exceptions.ContainerOrchestratorInternalErrorException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotDeployServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotPrepareEnvironmentException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRemoveServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRestartServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRetrieveServiceAccessDetailsException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRetrieveServiceComponentLogsException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRetrieveServiceComponentsException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotScaleDownServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotScaleUpServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotUpgradeKubernetesServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotVerifyServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.ServiceRequestVerificationException;
import net.geant.nmaas.orchestration.AppComponentDetails;
import net.geant.nmaas.orchestration.AppComponentLogs;
import net.geant.nmaas.orchestration.AppUiAccessDetails;
......@@ -23,7 +35,32 @@ import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.*;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.DEPLOYED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.DEPLOYMENT_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.DEPLOYMENT_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.ENVIRONMENT_PREPARATION_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.ENVIRONMENT_PREPARATION_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.ENVIRONMENT_PREPARED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.REMOVAL_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.REMOVAL_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.REMOVED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.REQUEST_VERIFICATION_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.REQUEST_VERIFIED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.RESTARTED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.RESTART_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.RESTART_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.SCALED_DOWN;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.SCALED_UP;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.SCALE_DOWN_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.SCALE_DOWN_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.SCALE_UP_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.SCALE_UP_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.UPGRADED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.UPGRADE_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.UPGRADE_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.VERIFICATION_FAILED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.VERIFICATION_INITIATED;
import static net.geant.nmaas.nmservice.deployment.entities.NmServiceDeploymentState.VERIFIED;
/**
* Default implementation of the {@link NmServiceDeploymentProvider}. Coordinates NM service deployment workflow and
......@@ -35,8 +72,6 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
private final ContainerOrchestrator orchestrator;
private final ApplicationEventPublisher applicationEventPublisher;
private final KServiceOperationsManager kserviceOperationsManager;
@Value("${nmaas.service.deployment.check.interval}")
int serviceDeploymentCheckInternal;
......@@ -53,7 +88,7 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
notifyStateChangeListeners(deploymentId, REQUEST_VERIFIED);
} catch (Exception e) {
notifyStateChangeListeners(deploymentId, REQUEST_VERIFICATION_FAILED, e.getMessage());
throw new NmServiceRequestVerificationException(e.getMessage());
throw new ServiceRequestVerificationException(e.getMessage());
}
}
......@@ -78,10 +113,10 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
notifyStateChangeListeners(deploymentId, DEPLOYMENT_INITIATED);
orchestrator.deployNmService(deploymentId);
notifyStateChangeListeners(deploymentId, DEPLOYED);
} catch (CouldNotDeployNmServiceException
} catch (CouldNotDeployServiceException
| ContainerOrchestratorInternalErrorException e) {
notifyStateChangeListeners(deploymentId, DEPLOYMENT_FAILED, e.getMessage());
throw new CouldNotDeployNmServiceException("NM Service deployment failed -> " + e.getMessage());
throw new CouldNotDeployServiceException("NM Service deployment failed -> " + e.getMessage());
}
}
......@@ -104,7 +139,7 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
} catch (ContainerCheckFailedException
| ContainerOrchestratorInternalErrorException e) {
notifyStateChangeListeners(deploymentId, VERIFICATION_FAILED, e.getMessage());
throw new CouldNotVerifyNmServiceException("NM Service deployment verification failed -> " + e.getMessage());
throw new CouldNotVerifyServiceException("NM Service deployment verification failed -> " + e.getMessage());
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
......@@ -116,7 +151,7 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
try {
return orchestrator.serviceAccessDetails(deploymentId);
} catch (ContainerOrchestratorInternalErrorException e) {
throw new CouldNotRetrieveNmServiceAccessDetailsException("Exception thrown during access details retrieval -> " + e.getMessage());
throw new CouldNotRetrieveServiceAccessDetailsException("Exception thrown during access details retrieval -> " + e.getMessage());
}
}
......@@ -131,7 +166,7 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
try {
return orchestrator.serviceComponents(deploymentId);
} catch (ContainerOrchestratorInternalErrorException e) {
throw new CouldNotRetrieveNmServiceComponentsException("Exception thrown during components retrieval -> " + e.getMessage());
throw new CouldNotRetrieveServiceComponentsException("Exception thrown during components retrieval -> " + e.getMessage());
}
}
......@@ -140,7 +175,7 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
try {
return orchestrator.serviceComponentLogs(deploymentId, serviceComponentName, serviceSubComponentName);
} catch (ContainerOrchestratorInternalErrorException e) {
throw new CouldNotRetrieveNmServiceComponentLogsException("Exception thrown during component logs retrieval -> " + e.getMessage());
throw new CouldNotRetrieveServiceComponentLogsException("Exception thrown during component logs retrieval -> " + e.getMessage());
}
}
......@@ -151,10 +186,10 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
notifyStateChangeListeners(deploymentId, REMOVAL_INITIATED);
orchestrator.removeNmService(deploymentId);
notifyStateChangeListeners(deploymentId, REMOVED);
} catch (CouldNotRemoveNmServiceException
} catch (CouldNotRemoveServiceException
| ContainerOrchestratorInternalErrorException e) {
notifyStateChangeListeners(deploymentId, REMOVAL_FAILED, e.getMessage());
throw new CouldNotRemoveNmServiceException("NM Service removal failed -> " + e.getMessage());
throw new CouldNotRemoveServiceException("NM Service removal failed -> " + e.getMessage());
}
}
......@@ -165,39 +200,41 @@ public class NmServiceDeploymentCoordinator implements NmServiceDeploymentProvid
notifyStateChangeListeners(deploymentId, RESTART_INITIATED);
orchestrator.restartNmService(deploymentId);
notifyStateChangeListeners(deploymentId, RESTARTED);
} catch (CouldNotRestartNmServiceException
} catch (CouldNotRestartServiceException
| ContainerOrchestratorInternalErrorException e) {
notifyStateChangeListeners(deploymentId, RESTART_FAILED, e.getMessage());
throw new CouldNotRestartNmServiceException("NM Service restart failed -> " + e.getMessage());
throw new CouldNotRestartServiceException("NM Service restart failed -> " + e.getMessage());
}
}
@Override
public void scaleDown(Identifier deploymentId){
try{
@Loggable(LogLevel.DEBUG)
public void pauseService(Identifier deploymentId) {
try {
notifyStateChangeListeners(deploymentId, SCALE_DOWN_INITIATED);
kserviceOperationsManager.scaleDeployment(deploymentId, 0);
orchestrator.pauseNmService(deploymentId);
notifyStateChangeListeners(deploymentId, SCALED_DOWN);
} catch (KubernetesClientSetupException e) {
notifyStateChangeListeners(deploymentId, SCALE_DOWN_FAILED, e.getMessage());
throw new CouldNotScaleDownNmServiceException("NM Service scale down failed -> " + e.getMessage());
throw new CouldNotScaleDownServiceException("Service scale down failed -> " + e.getMessage());
}
}
@Override
public void scaleUp(Identifier deploymentId){
try{
@Loggable(LogLevel.TRACE)
public void resumeService(Identifier deploymentId) {
try {
notifyStateChangeListeners(deploymentId, SCALE_UP_INITIATED);
kserviceOperationsManager.scaleDeployment(deploymentId, 1);
orchestrator.resumeNmService(deploymentId);
notifyStateChangeListeners(deploymentId, SCALED_UP);
} catch (KubernetesClientSetupException e) {
notifyStateChangeListeners(deploymentId, SCALE_UP_FAILED, e.getMessage());
throw new CouldNotScaleUpNmServiceException("NM Service scale up failed -> " + e.getMessage());
throw new CouldNotScaleUpServiceException("Service scale up failed -> " + e.getMessage());
}
}
@Override
@Loggable(LogLevel.DEBUG)
public void upgradeKubernetesService(Identifier deploymentId, AppUpgradeMode mode, Identifier targetApplicationId, KubernetesTemplate kubernetesTemplate) {
try {
notifyStateChangeListeners(deploymentId, UPGRADE_INITIATED);
......
package net.geant.nmaas.nmservice.deployment;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.entities.KubernetesTemplate;
import net.geant.nmaas.nmservice.deployment.exceptions.*;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotDeployServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotPrepareEnvironmentException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRemoveServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRestartServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRetrieveServiceAccessDetailsException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotScaleDownServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotScaleUpServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotUpgradeKubernetesServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotVerifyServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.ServiceRequestVerificationException;
import net.geant.nmaas.orchestration.AppComponentDetails;
import net.geant.nmaas.orchestration.AppComponentLogs;
import net.geant.nmaas.orchestration.AppUiAccessDetails;
......@@ -19,19 +28,19 @@ import java.util.Map;
public interface NmServiceDeploymentProvider {
/**
* Creates new object representing the NM service deployment and verifies if the request can be executed.
* Creates new object representing the service deployment and verifies if the request can be executed.
*
* @param deploymentId unique identifier of service deployment
* @param appDeployment application deployment details provided by user
* @param deploymentId unique identifier of service deployment
* @param appDeployment application deployment details provided by user
* @param appDeploymentSpec additional information specific to given application deployment
* @throws NmServiceRequestVerificationException if service can't be deployed or some input parameters are missing
* @throws ServiceRequestVerificationException if service can't be deployed or some input parameters are missing
*/
void verifyRequest(Identifier deploymentId, AppDeployment appDeployment, AppDeploymentSpec appDeploymentSpec);
/**
* Coordinates deployment environment preparation (delegates tasks to attached {@link ContainerOrchestrator}).
*
* @param deploymentId unique identifier of service deployment
* @param deploymentId unique identifier of service deployment
* @param configFileRepositoryRequired indicates if GitLab instance is required during deployment
* @throws CouldNotPrepareEnvironmentException if environment couldn't be prepared for some reason
*/
......@@ -41,7 +50,7 @@ public interface NmServiceDeploymentProvider {
* Coordinates service deployment (delegates tasks to attached {@link ContainerOrchestrator}).
*
* @param deploymentId unique identifier of service deployment
* @throws CouldNotDeployNmServiceException if NM service couldn't be deployed for some reason
* @throws CouldNotDeployServiceException if service couldn't be deployed for some reason
*/
void deployService(Identifier deploymentId);
......@@ -49,7 +58,7 @@ public interface NmServiceDeploymentProvider {
* Coordinates service deployment verification (delegates tasks to attached {@link ContainerOrchestrator}).
*
* @param deploymentId unique identifier of service deployment
* @throws CouldNotVerifyNmServiceException if NM service deployment verification failed
* @throws CouldNotVerifyServiceException if service deployment verification failed
*/
void verifyService(Identifier deploymentId);
......@@ -58,7 +67,7 @@ public interface NmServiceDeploymentProvider {
*
* @param deploymentId unique identifier of service deployment
* @return service access details
* @throws CouldNotRetrieveNmServiceAccessDetailsException if access details are not available for any reason
* @throws CouldNotRetrieveServiceAccessDetailsException if access details are not available for any reason
*/
AppUiAccessDetails serviceAccessDetails(Identifier deploymentId);
......@@ -74,7 +83,7 @@ public interface NmServiceDeploymentProvider {
* Coordinates service removal (delegates tasks to attached {@link ContainerOrchestrator}).
*
* @param deploymentId unique identifier of service deployment
* @throws CouldNotRemoveNmServiceException if NM service couldn't be removed for some reason
* @throws CouldNotRemoveServiceException if service couldn't be removed for some reason
*/
void removeService(Identifier deploymentId);
......@@ -82,17 +91,17 @@ public interface NmServiceDeploymentProvider {
* Coordinates service restart (delegates tasks to attached {@link ContainerOrchestrator}).
*
* @param deploymentId unique identifier of service deployment
* @throws CouldNotRestartNmServiceException if NM service couldn't be restarted for some reason
* @throws CouldNotRestartServiceException if service couldn't be restarted for some reason
*/
void restartService(Identifier deploymentId);
/**
* Coordinates service upgrade to specified version (delegates tasks to attached {@link ContainerOrchestrator}).
*
* @param deploymentId unique identifier of service deployment
* @param mode application upgrade mode
* @param deploymentId unique identifier of service deployment
* @param mode application upgrade mode
* @param targetApplicationId target application identifier
* @param kubernetesTemplate Helm chart information of the desired application version
* @param kubernetesTemplate Helm chart information of the desired application version
* @throws CouldNotUpgradeKubernetesServiceException if service couldn't be upgraded for some reason
*/
void upgradeKubernetesService(Identifier deploymentId, AppUpgradeMode mode, Identifier targetApplicationId, KubernetesTemplate kubernetesTemplate);
......@@ -108,21 +117,23 @@ public interface NmServiceDeploymentProvider {
/**
* Retrieves logs from given service component.
*
* @param deploymentId unique identifier of service deployment
* @param serviceComponentName name of service component from which logs should be retrieved
* @param deploymentId unique identifier of service deployment
* @param serviceComponentName name of service component from which logs should be retrieved
* @param serviceSubComponentName name of service subcomponent (added if required)
* @return {@link AppComponentLogs} object containing application logs
*/
AppComponentLogs serviceComponentLogs(Identifier deploymentId, String serviceComponentName, String serviceSubComponentName);
/**
* @param deploymentId unique identifier of service deployment
* @throws CouldNotScaleDownNmServiceException if NM service couldn't be scaled for some reason
* @throws CouldNotScaleDownServiceException if service couldn't be paused for some reason
*/
void scaleDown(Identifier deploymentId);
void pauseService(Identifier deploymentId);
/**
* @param deploymentId unique identifier of service deployment
* @throws CouldNotScaleUpNmServiceException if NM service couldn't be scaled for some reason
* @throws CouldNotScaleUpServiceException if service couldn't be resumed for some reason
*/
void scaleUp(Identifier deploymentId);
void resumeService(Identifier deploymentId);
}
......@@ -5,6 +5,7 @@ import net.geant.nmaas.orchestration.Identifier;
public interface KServiceOperationsManager {
void restartService(Identifier deploymentId);
void scaleDeployment(Identifier deploymentId, int replicas);
}
......@@ -4,13 +4,13 @@ import com.google.common.base.Strings;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.geant.nmaas.externalservices.kubernetes.KubernetesClusterIngressManager;
import net.geant.nmaas.gitlab.GitLabManager;
import net.geant.nmaas.gitlab.exceptions.GitLabInvalidConfigurationException;
import net.geant.nmaas.kubernetes.KubernetesApiJanitorService;
import net.geant.nmaas.kubernetes.remote.RemoteClusterManagementService;
import net.geant.nmaas.kubernetes.remote.RemoteClusterMonitoringService;
import net.geant.nmaas.kubernetes.remote.entities.IngressControllerConfigOption;
import net.geant.nmaas.kubernetes.remote.entities.KCluster;
import net.geant.nmaas.gitlab.GitLabManager;
import net.geant.nmaas.gitlab.exceptions.GitLabInvalidConfigurationException;
import net.geant.nmaas.kubernetes.KubernetesApiJanitorService;
import net.geant.nmaas.nmservice.deployment.ContainerOrchestrator;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.components.cluster.KClusterCheckException;
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.components.helm.HelmChartIngressVariable;
......@@ -26,12 +26,12 @@ import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.ja
import net.geant.nmaas.nmservice.deployment.containerorchestrators.kubernetes.janitor.JanitorService;
import net.geant.nmaas.nmservice.deployment.exceptions.ContainerCheckFailedException;
import net.geant.nmaas.nmservice.deployment.exceptions.ContainerOrchestratorInternalErrorException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotDeployNmServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotDeployServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotPrepareEnvironmentException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRemoveNmServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRestartNmServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRemoveServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotRestartServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.CouldNotUpgradeKubernetesServiceException;
import net.geant.nmaas.nmservice.deployment.exceptions.NmServiceRequestVerificationException;
import net.geant.nmaas.nmservice.deployment.exceptions.ServiceRequestVerificationException;
import net.geant.nmaas.orchestration.AppComponentDetails;
import net.geant.nmaas.orchestration.AppComponentLogs;
import net.geant.nmaas.orchestration.AppUiAccessDetails;
......@@ -103,15 +103,15 @@ public class KubernetesManager implements ContainerOrchestrator {
checkArgument(appDeploymentSpec.getAccessMethods() != null && !appDeploymentSpec.getAccessMethods().isEmpty(),
"Service access methods cannot be null");
} catch (IllegalArgumentException iae) {
throw new NmServiceRequestVerificationException(iae.getMessage());
throw new ServiceRequestVerificationException(iae.getMessage());
}
if (Objects.nonNull(appDeployment.getRemoteClusterId())) {
if (!remoteClusterManager.clusterExists(appDeployment.getRemoteClusterId())) {
throw new NmServiceRequestVerificationException(String.format("Remote cluster with id %s doesn't exist", appDeployment.getRemoteClusterId()));
throw new ServiceRequestVerificationException(String.format("Remote cluster with id %s doesn't exist", appDeployment.getRemoteClusterId()));
} else {
if (!remoteClusterMonitor.clusterAvailable(appDeployment.getRemoteClusterId())) {
throw new NmServiceRequestVerificationException(String.format("Remote cluster with id %s is currently unavailable", appDeployment.getRemoteClusterId()));
throw new ServiceRequestVerificationException(String.format("Remote cluster with id %s is currently unavailable", appDeployment.getRemoteClusterId()));
}
}
}
......@@ -261,7 +261,7 @@ public class KubernetesManager implements ContainerOrchestrator {
} catch (InvalidDeploymentIdException | InvalidConfigurationException ex) {
throw new ContainerOrchestratorInternalErrorException(serviceNotFoundMessage(ex.getMessage()));
} catch (KServiceManipulationException e) {
throw new CouldNotDeployNmServiceException(e.getMessage());
throw new CouldNotDeployServiceException(e.getMessage());
}
}
......@@ -452,7 +452,7 @@ public class KubernetesManager implements ContainerOrchestrator {
} catch (InvalidDeploymentIdException idie) {
throw new ContainerOrchestratorInternalErrorException(serviceNotFoundMessage(idie.getMessage()));
} catch (KServiceManipulationException e) {
throw new CouldNotRemoveNmServiceException(e.getMessage());
throw new CouldNotRemoveServiceException(e.getMessage());
}
}
......@@ -464,7 +464,7 @@ public class KubernetesManager implements ContainerOrchestrator {
} catch (InvalidDeploymentIdException idie) {
throw new ContainerOrchestratorInternalErrorException(serviceNotFoundMessage(idie.getMessage()));
} catch (KServiceManipulationException e) {
throw new CouldNotRestartNmServiceException(e.getMessage());
throw new CouldNotRestartServiceException(e.getMessage());
}
}
......@@ -538,6 +538,24 @@ public class KubernetesManager implements ContainerOrchestrator {
}
}
@Override
public void pauseNmService(Identifier deploymentId) {
try {
serviceOperationsManager.scaleDeployment(deploymentId, 0);
} catch (InvalidDeploymentIdException idie) {
throw new ContainerOrchestratorInternalErrorException(serviceNotFoundMessage(idie.getMessage()));
}
}
@Override
public void resumeNmService(Identifier deploymentId) {
try {
serviceOperationsManager.scaleDeployment(deploymentId, 1);
} catch (InvalidDeploymentIdException idie) {
throw new ContainerOrchestratorInternalErrorException(serviceNotFoundMessage(idie.getMessage()));
}
}
private static String serviceNotFoundMessage(String exceptionMessage) {
return String.format("Service not found in repository -> Invalid deployment id %s", exceptionMessage);
}
......
......@@ -37,13 +37,12 @@ public class DefaultKServiceOperationsManager implements KServiceOperationsManag
@Loggable(LogLevel.INFO)
public void scaleDeployment(Identifier deploymentId, int replicas) throws KubernetesClientSetupException {
KubernetesNmServiceInfo serviceInfo = repositoryManager.loadService(deploymentId);
final String namespace = namespaceService.namespace(serviceInfo.getDomain());
final String kubernetesDeploymentName =
Stream.of(serviceInfo.getDescriptiveDeploymentId().getValue(), serviceInfo.getKubernetesTemplate().getMainDeploymentName())
.filter(Objects::nonNull)
.collect(Collectors.joining("-"));
kubernetesApiClientService.scaleDeployment(serviceInfo.getRemoteCluster(), namespace, kubernetesDeploymentName, replicas);
final String namespace = namespaceService.namespace(serviceInfo.getDomain());
final String kubernetesDeploymentName =
Stream.of(serviceInfo.getDescriptiveDeploymentId().getValue(), serviceInfo.getKubernetesTemplate().getMainDeploymentName())
.filter(Objects::nonNull)
.collect(Collectors.joining("-"));
kubernetesApiClientService.scaleDeployment(serviceInfo.getRemoteCluster(), namespace, kubernetesDeploymentName, replicas);
}
}
\ No newline at end of file
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotDeployNmServiceException extends RuntimeException {
public class CouldNotDeployServiceException extends RuntimeException {
public CouldNotDeployNmServiceException(String message) {
public CouldNotDeployServiceException(String message) {
super(message);
}
public CouldNotDeployNmServiceException(String message, Throwable cause) {
public CouldNotDeployServiceException(String message, Throwable cause) {
super(message, cause);
}
......
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotRemoveNmServiceException extends RuntimeException {
public class CouldNotRemoveServiceException extends RuntimeException {
public CouldNotRemoveNmServiceException(String message) {
public CouldNotRemoveServiceException(String message) {
super(message);
}
public CouldNotRemoveNmServiceException(String message, Throwable cause) {
public CouldNotRemoveServiceException(String message, Throwable cause) {
super(message, cause);
}
......
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotVerifyNmServiceException extends RuntimeException {
public class CouldNotRestartServiceException extends RuntimeException {
public CouldNotVerifyNmServiceException(String message) {
public CouldNotRestartServiceException(String message) {
super(message);
}
public CouldNotVerifyNmServiceException(String message, Throwable cause) {
public CouldNotRestartServiceException(String message, Throwable cause) {
super(message, cause);
}
......
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotRetrieveNmServiceAccessDetailsException extends RuntimeException {
public CouldNotRetrieveNmServiceAccessDetailsException(String message) {
super(message);
}
public CouldNotRetrieveNmServiceAccessDetailsException(String message, Throwable cause) {
super(message, cause);
}
}
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotRetrieveNmServiceComponentLogsException extends RuntimeException {
public CouldNotRetrieveNmServiceComponentLogsException(String message) {
super(message);
}
public CouldNotRetrieveNmServiceComponentLogsException(String message, Throwable cause) {
super(message, cause);
}
}
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotRetrieveNmServiceComponentsException extends RuntimeException {
public class CouldNotRetrieveServiceAccessDetailsException extends RuntimeException {
public CouldNotRetrieveNmServiceComponentsException(String message) {
public CouldNotRetrieveServiceAccessDetailsException(String message) {
super(message);
}
public CouldNotRetrieveNmServiceComponentsException(String message, Throwable cause) {
public CouldNotRetrieveServiceAccessDetailsException(String message, Throwable cause) {
super(message, cause);
}
......
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotRetrieveServiceComponentLogsException extends RuntimeException {
public CouldNotRetrieveServiceComponentLogsException(String message) {
super(message);
}
public CouldNotRetrieveServiceComponentLogsException(String message, Throwable cause) {
super(message, cause);
}
}
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotRetrieveServiceComponentsException extends RuntimeException {
public CouldNotRetrieveServiceComponentsException(String message) {
super(message);
}
public CouldNotRetrieveServiceComponentsException(String message, Throwable cause) {
super(message, cause);
}
}
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotScaleUpNmServiceException extends RuntimeException {
public class CouldNotScaleDownServiceException extends RuntimeException {
public CouldNotScaleUpNmServiceException(String message) {
public CouldNotScaleDownServiceException(String message) {
super(message);
}
}
package net.geant.nmaas.nmservice.deployment.exceptions;
public class NmServiceRequestVerificationException extends RuntimeException {
public class CouldNotScaleUpServiceException extends RuntimeException {
public NmServiceRequestVerificationException(String message) {
public CouldNotScaleUpServiceException(String message) {
super(message);
}
}
package net.geant.nmaas.nmservice.deployment.exceptions;
public class CouldNotRestartNmServiceException extends RuntimeException {
public class CouldNotVerifyServiceException extends RuntimeException {
public CouldNotRestartNmServiceException(String message) {
public CouldNotVerifyServiceException(String message) {
super(message);
}
public CouldNotRestartNmServiceException(String message, Throwable cause) {
public CouldNotVerifyServiceException(String message, Throwable cause) {
super(message, cause);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment