-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
control-service: improve jobs synchronizer error handling
Why As part of VEP-2272, we need to introduce a process for synchronizing data jobs from the database to Kubernetes. In the event of a data job deployment failure (due to user or platform errors), the current implementation attempts to deploy the data job during every synchronization cycle. What We have added a data job deployment status field to the desired_data_job_deployment table. This status is used to determine whether the deployment failed in the previous cycle and should be skipped in the current one. Testing done Unit tests Signed-off-by: Miroslav Ivanov miroslavi@vmware.com
- Loading branch information
1 parent
7ae16f5
commit ab3c4b2
Showing
8 changed files
with
114 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
.../db/migration/V20231002143000__add_column_status_to_desired_data_job_deployment_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
alter table if exists desired_data_job_deployment | ||
add column if not exists status varchar; |
62 changes: 62 additions & 0 deletions
62
...rol_service/src/test/java/com/vmware/taurus/service/deploy/DeploymentServiceV2TestIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2021-2023 VMware, Inc. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.vmware.taurus.service.deploy; | ||
|
||
import com.vmware.taurus.ControlplaneApplication; | ||
import com.vmware.taurus.service.model.*; | ||
import io.kubernetes.client.openapi.ApiException; | ||
import org.junit.jupiter.api.Test; | ||
import org.mockito.Mockito; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.mock.mockito.MockBean; | ||
|
||
import java.io.IOException; | ||
|
||
@SpringBootTest(classes = ControlplaneApplication.class) | ||
public class DeploymentServiceV2TestIT { | ||
|
||
@Autowired | ||
private DeploymentServiceV2 deploymentService; | ||
|
||
@MockBean | ||
private DeploymentProgress deploymentProgress; | ||
|
||
@MockBean | ||
private JobImageBuilder jobImageBuilder; | ||
|
||
@Test | ||
public void updateDeployment_withDesiredDeploymentStatusUserError_shouldSkipDeployment() throws IOException, InterruptedException, ApiException { | ||
updateDeployment(DeploymentStatus.USER_ERROR, 0); | ||
} | ||
|
||
@Test | ||
public void updateDeployment_withDesiredDeploymentStatusPlatformError_shouldSkipDeployment() throws IOException, InterruptedException, ApiException { | ||
updateDeployment(DeploymentStatus.PLATFORM_ERROR, 0); | ||
} | ||
|
||
@Test | ||
public void updateDeployment_withDesiredDeploymentStatusSuccess_shouldStartDeployment() throws IOException, InterruptedException, ApiException { | ||
updateDeployment(DeploymentStatus.SUCCESS, 1); | ||
} | ||
|
||
@Test | ||
public void updateDeployment_withDesiredDeploymentStatusNone_shouldStartDeployment() throws IOException, InterruptedException, ApiException { | ||
updateDeployment(DeploymentStatus.NONE, 1); | ||
} | ||
|
||
private void updateDeployment(DeploymentStatus deploymentStatus, int deploymentProgressStartedInvocations) throws IOException, InterruptedException, ApiException { | ||
DesiredDataJobDeployment desiredDataJobDeployment = new DesiredDataJobDeployment(); | ||
desiredDataJobDeployment.setStatus(deploymentStatus); | ||
DataJob dataJob = new DataJob(); | ||
dataJob.setJobConfig(new JobConfig()); | ||
Mockito.when(jobImageBuilder.buildImage(Mockito.any(), Mockito.any(), Mockito.any(), Mockito.any())).thenReturn(false); | ||
|
||
deploymentService.updateDeployment(dataJob, desiredDataJobDeployment, new ActualDataJobDeployment(), true, true); | ||
|
||
Mockito.verify(deploymentProgress, Mockito.times(deploymentProgressStartedInvocations)).started(dataJob.getJobConfig(), desiredDataJobDeployment); | ||
} | ||
} |