Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,22 @@ private void updateEdgeStatus(String user, List<EnvResource> hostList) {

}

/**
* If NoteBook is started within scheduler interface, the edge node should be RUNNING
* @param user
* @return true or false
*/
public Boolean isEdgeNodeRunning(String user) {
LOGGER.trace("Verify if the edge node is stopped for user {}", user);
boolean isNodeRunning = true;
Optional<Document> edgeNode = getEdgeNode(user);
if (edgeNode.isPresent()) {
String edgeStatus = edgeNode.get().getString(EDGE_STATUS);
isNodeRunning =edgeStatus.equals(RUNNING.toString());
}
return isNodeRunning;
}

private void updateEdgeStatus(String user, Document edge, String instanceId, EnvResource r) {
final String oldStatus = edge.getString(EDGE_STATUS);
LOGGER.trace("Update EDGE status for user {} with instance_id {} from {} to {}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@
import com.epam.datalab.auth.UserInfo;
import com.epam.datalab.backendapi.annotation.*;
import com.epam.datalab.backendapi.conf.SelfServiceApplicationConfiguration;
import com.epam.datalab.backendapi.dao.ComputationalDAO;
import com.epam.datalab.backendapi.dao.ExploratoryDAO;
import com.epam.datalab.backendapi.dao.GitCredsDAO;
import com.epam.datalab.backendapi.dao.ImageExploratoryDAO;
import com.epam.datalab.backendapi.dao.*;
import com.epam.datalab.backendapi.domain.*;
import com.epam.datalab.backendapi.resources.dto.ExploratoryCreatePopUp;
import com.epam.datalab.backendapi.service.*;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,11 @@ private void startExploratory(SchedulerJobData schedulerJobData) {
final String user = schedulerJobData.getUser();
final String exploratoryName = schedulerJobData.getExploratoryName();
final String project = schedulerJobData.getProject();
log.debug("Starting exploratory {} for user {} by scheduler", exploratoryName, user);
log.info("Trying to start the exploratory {} for user {} by scheduler", exploratoryName, user);
if (!envDAO.isEdgeNodeRunning(user)) {
log.warn("The edge node of {} is not started for user {}", exploratoryName, user);
return;
}
exploratoryService.start(securityService.getServiceAccountInfo(user), exploratoryName, project, String.format(AUDIT_MESSAGE, exploratoryName));
if (schedulerJobData.getJobDTO().isSyncStartRequired()) {
log.trace("Starting computational for exploratory {} for user {} by scheduler", exploratoryName, user);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.epam.datalab.auth.UserInfo;
import com.epam.datalab.backendapi.dao.ComputationalDAO;
import com.epam.datalab.backendapi.dao.EnvDAO;
import com.epam.datalab.backendapi.dao.ExploratoryDAO;
import com.epam.datalab.backendapi.dao.SchedulerJobDAO;
import com.epam.datalab.backendapi.service.ComputationalService;
Expand Down Expand Up @@ -100,6 +101,8 @@ public class SchedulerJobServiceImplTest {
private ExploratoryService exploratoryService;
@Mock
private ComputationalService computationalService;
@Mock
private EnvDAO envDAO;

@InjectMocks
private SchedulerJobServiceImpl schedulerJobService;
Expand Down Expand Up @@ -706,7 +709,7 @@ public void testStartExploratoryByScheduler() {
LocalTime.now().truncatedTo(ChronoUnit.MINUTES)
)));
when(securityService.getServiceAccountInfo(anyString())).thenReturn(getUserInfo());

when(envDAO.isEdgeNodeRunning(USER)).thenReturn(true);
schedulerJobService.startExploratoryByScheduler();

verify(securityService).getServiceAccountInfo(USER);
Expand All @@ -732,7 +735,7 @@ public void testStartExploratoryBySchedulerWithSyncComputationalStart() {
when(computationalDAO.findComputationalResourcesWithStatus(anyString(), anyString(),
anyString(), any(UserInstanceStatus.class))).thenReturn(singletonList(getComputationalResource(
DataEngineType.SPARK_STANDALONE, true)));

when(envDAO.isEdgeNodeRunning(USER)).thenReturn(true);
schedulerJobService.startExploratoryByScheduler();

verify(securityService, times(2)).getServiceAccountInfo(USER);
Expand All @@ -759,7 +762,7 @@ public void testStartExploratoryBySchedulerWithSyncComputationalStartDataEngine(
when(computationalDAO.findComputationalResourcesWithStatus(anyString(), anyString(),
anyString(), any(UserInstanceStatus.class))).thenReturn(singletonList(getComputationalResource(
DataEngineType.CLOUD_SERVICE, true)));

when(envDAO.isEdgeNodeRunning(USER)).thenReturn(true);
schedulerJobService.startExploratoryByScheduler();

verify(securityService).getServiceAccountInfo(USER);
Expand All @@ -784,7 +787,7 @@ public void testStartExploratoryBySchedulerWithSyncComputationalStartOnExplorato
when(computationalDAO.findComputationalResourcesWithStatus(anyString(), anyString(),
anyString(), any(UserInstanceStatus.class))).thenReturn(singletonList(getComputationalResource(
DataEngineType.SPARK_STANDALONE, false)));

when(envDAO.isEdgeNodeRunning(USER)).thenReturn(true);
schedulerJobService.startExploratoryByScheduler();

verify(securityService).getServiceAccountInfo(USER);
Expand Down