-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Support sku spec upgrade * separate UpgradeReq to workflow * annotate nullable fields
- Loading branch information
Showing
8 changed files
with
153 additions
and
11 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
71 changes: 71 additions & 0 deletions
71
...ntisrx/master/resourcecluster/resourceprovider/ResourceClusterProviderUpgradeRequest.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,71 @@ | ||
/* | ||
* Copyright 2023 Netflix, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.mantisrx.master.resourcecluster.resourceprovider; | ||
|
||
import io.mantisrx.master.resourcecluster.proto.MantisResourceClusterEnvType; | ||
import io.mantisrx.master.resourcecluster.proto.MantisResourceClusterSpec; | ||
import io.mantisrx.master.resourcecluster.proto.UpgradeClusterContainersRequest; | ||
import io.mantisrx.server.master.resourcecluster.ClusterID; | ||
import javax.annotation.Nullable; | ||
import lombok.Builder; | ||
import lombok.Value; | ||
|
||
@Value | ||
@Builder(toBuilder = true) | ||
public class ResourceClusterProviderUpgradeRequest { | ||
ClusterID clusterId; | ||
|
||
String region; | ||
|
||
@Nullable | ||
String optionalImageId; | ||
|
||
@Nullable | ||
String optionalSkuId; | ||
|
||
MantisResourceClusterEnvType optionalEnvType; | ||
|
||
int optionalBatchMaxSize; | ||
|
||
boolean forceUpgradeOnSameImage; | ||
|
||
boolean enableSkuSpecUpgrade; | ||
|
||
@Nullable | ||
MantisResourceClusterSpec resourceClusterSpec; | ||
|
||
public static ResourceClusterProviderUpgradeRequest from( | ||
UpgradeClusterContainersRequest req) { | ||
return from(req, null); | ||
} | ||
|
||
public static ResourceClusterProviderUpgradeRequest from( | ||
UpgradeClusterContainersRequest req, | ||
MantisResourceClusterSpec resourceClusterSpec) { | ||
return ResourceClusterProviderUpgradeRequest.builder() | ||
.clusterId(req.getClusterId()) | ||
.region(req.getRegion()) | ||
.optionalImageId(req.getOptionalImageId()) | ||
.optionalSkuId(req.getOptionalSkuId()) | ||
.optionalEnvType(req.getOptionalEnvType()) | ||
.optionalBatchMaxSize(req.getOptionalBatchMaxSize()) | ||
.forceUpgradeOnSameImage(req.isForceUpgradeOnSameImage()) | ||
.enableSkuSpecUpgrade(req.isEnableSkuSpecUpgrade()) | ||
.resourceClusterSpec(resourceClusterSpec) | ||
.build(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ | |
import io.mantisrx.master.resourcecluster.resourceprovider.ResourceClusterProvider; | ||
import io.mantisrx.master.resourcecluster.resourceprovider.ResourceClusterResponseHandler; | ||
import io.mantisrx.master.resourcecluster.resourceprovider.ResourceClusterStorageProvider; | ||
import io.mantisrx.master.resourcecluster.writable.ResourceClusterSpecWritable; | ||
import io.mantisrx.server.master.resourcecluster.ClusterID; | ||
import io.mantisrx.server.master.resourcecluster.ContainerSkuID; | ||
import java.util.concurrent.CompletableFuture; | ||
|
@@ -468,6 +469,46 @@ public void testUpgradeRequest() { | |
probe.getSystem().stop(resourceClusterActor); | ||
} | ||
|
||
@Test | ||
public void testUpgradeRequestEnableSkuSpecUpgrade() { | ||
TestKit probe = new TestKit(system); | ||
ResourceClusterStorageProvider resStorageProvider = mock(ResourceClusterStorageProvider.class); | ||
ResourceClusterProvider resProvider = mock(ResourceClusterProvider.class); | ||
ResourceClusterResponseHandler responseHandler = mock(ResourceClusterResponseHandler.class); | ||
|
||
UpgradeClusterContainersResponse upgradeRes = | ||
UpgradeClusterContainersResponse.builder().responseCode(ResponseCode.SUCCESS).build(); | ||
when(resProvider.upgradeContainerResource(any())).thenReturn(CompletableFuture.completedFuture( | ||
upgradeRes | ||
)); | ||
|
||
ProvisionResourceClusterRequest provisionReq = buildProvisionRequest(); | ||
when(resStorageProvider.getResourceClusterSpecWritable(any())) | ||
.thenReturn(CompletableFuture.completedFuture( | ||
ResourceClusterSpecWritable.builder() | ||
.clusterSpec(provisionReq.getClusterSpec()) | ||
.id(provisionReq.getClusterId()) | ||
.build())); | ||
|
||
when(resProvider.getResponseHandler()).thenReturn(responseHandler); | ||
|
||
ActorRef resourceClusterActor = system.actorOf( | ||
ResourceClustersHostManagerActor.props(resProvider, resStorageProvider)); | ||
|
||
UpgradeClusterContainersRequest request = UpgradeClusterContainersRequest.builder() | ||
.clusterId(provisionReq.getClusterId()) | ||
.enableSkuSpecUpgrade(true) | ||
.build(); | ||
|
||
resourceClusterActor.tell(request, probe.getRef()); | ||
UpgradeClusterContainersResponse createResp = probe.expectMsgClass(UpgradeClusterContainersResponse.class); | ||
|
||
assertEquals(ResponseCode.SUCCESS, createResp.responseCode); | ||
|
||
verify(resProvider, times(1)).upgradeContainerResource(any()); | ||
probe.getSystem().stop(resourceClusterActor); | ||
} | ||
|
||
private ProvisionResourceClusterRequest buildProvisionRequest() { | ||
return buildProvisionRequest("mantisTestResCluster1", "[email protected]"); | ||
} | ||
|