mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
feat(eks): store the cluster upgrade policy and update it through UpdateClusterConfig (#9253)
CreateCluster dropped upgradePolicy, DescribeCluster never returned one, and UpdateClusterConfig refused the member, so Terraform's aws_eks_cluster with upgrade_policy showed a diff on every plan that no apply could fix. CreateCluster now stores upgradePolicy.supportType, EXTENDED when the request names none, as EKS gives new clusters extended support, and DescribeCluster returns it. A cluster stored before reports EXTENDED as well. UpdateClusterConfig takes upgradePolicy as an update type of its own and answers with a Successful UpgradePolicyUpdate whose UpgradePolicy parameter holds the policy as JSON, as AWS records it. A repeated clientRequestToken is matched against it like the other families, and an unknown support type is refused with InvalidParameterException. STANDARD is refused, in AWS's words, for a version past its end of standard support: on CreateCluster, and on UpdateClusterConfig, which turns extended support on at any time but off only in standard support. The end of standard support of each version Floci serves comes from the Amazon EKS Kubernetes release calendar. A cluster that named no version counts as in standard support, as the version AWS gives it is. AWS::EKS::Cluster creates the cluster with its UpgradePolicy and updates it in place. A dropped UpgradePolicy returns the cluster to EXTENDED, a stack rollback restores the policy, and a cluster a stack created before this gets the policy its template declares on the stack's next update. Closes #5640
This commit is contained in:
1 parent
8a9fa27575
commit
b521ee513c
17 files changed
+491
-30
No files matched your search
+7
-2
@@ -318,6 +318,7 @@ class CloudFormationEksIntegrationTest {
|
||||
assertEquals(List.of("api", "audit"), cluster.getList(
|
||||
"cluster.logging.clusterLogging.find { it.enabled == true }.types").stream().sorted().toList());
|
||||
assertEquals("API", cluster.getString("cluster.accessConfig.authenticationMode"));
|
||||
assertEquals("STANDARD", cluster.getString("cluster.upgradePolicy.supportType"));
|
||||
} finally {
|
||||
CfnStackWaits.deleteStack(stack);
|
||||
}
|
||||
@@ -336,6 +337,7 @@ class CloudFormationEksIntegrationTest {
|
||||
assertEquals(true, cluster.getBoolean("cluster.resourcesVpcConfig.endpointPublicAccess"));
|
||||
assertEquals("API_AND_CONFIG_MAP", cluster.getString("cluster.accessConfig.authenticationMode"));
|
||||
assertEquals(List.of(), cluster.getList("cluster.logging.clusterLogging.findAll { it.enabled == true }"));
|
||||
assertEquals("EXTENDED", cluster.getString("cluster.upgradePolicy.supportType"));
|
||||
|
||||
CfnStackWaits.updateStack(client, stack, configStack(true, false), "UPDATE_COMPLETE");
|
||||
assertEquals(id, physicalId(client, stack, "Subject"));
|
||||
@@ -345,6 +347,7 @@ class CloudFormationEksIntegrationTest {
|
||||
assertEquals(List.of("api"),
|
||||
cluster.getList("cluster.logging.clusterLogging.find { it.enabled == true }.types"));
|
||||
assertEquals("API", cluster.getString("cluster.accessConfig.authenticationMode"));
|
||||
assertEquals("STANDARD", cluster.getString("cluster.upgradePolicy.supportType"));
|
||||
} finally {
|
||||
CfnStackWaits.deleteStack(stack);
|
||||
}
|
||||
@@ -405,7 +408,8 @@ class CloudFormationEksIntegrationTest {
|
||||
+ " \"ServiceIpv4Cidr\": \"172.20.0.0/16\"}";
|
||||
|
||||
private static final String SETTINGS = "\"Logging\": {\"ClusterLogging\": {\"EnabledTypes\": ["
|
||||
+ "{\"Type\": \"api\"}, {\"Type\": \"audit\"}]}}, \"AccessConfig\": {\"AuthenticationMode\": \"API\"}";
|
||||
+ "{\"Type\": \"api\"}, {\"Type\": \"audit\"}]}}, \"AccessConfig\": {\"AuthenticationMode\": \"API\"},"
|
||||
+ " \"UpgradePolicy\": {\"SupportType\": \"STANDARD\"}";
|
||||
|
||||
private static String subnet(String id, String cidr, String zone) {
|
||||
return "\"" + id + "\": {\"Type\": \"AWS::EC2::Subnet\", \"Properties\": {\"VpcId\": {\"Ref\": \"Vpc\"},"
|
||||
@@ -421,7 +425,8 @@ class CloudFormationEksIntegrationTest {
|
||||
private static String configStack(boolean updated, boolean fails) {
|
||||
String settings = updated
|
||||
? "\"EndpointPublicAccess\": false, \"EndpointPrivateAccess\": true}, \"Logging\": {\"ClusterLogging\": "
|
||||
+ "{\"EnabledTypes\": [{\"Type\": \"api\"}]}}, \"AccessConfig\": {\"AuthenticationMode\": \"API\"}"
|
||||
+ "{\"EnabledTypes\": [{\"Type\": \"api\"}]}}, \"AccessConfig\": {\"AuthenticationMode\": \"API\"},"
|
||||
+ " \"UpgradePolicy\": {\"SupportType\": \"STANDARD\"}"
|
||||
: "\"EndpointPublicAccess\": true}, \"AccessConfig\": {\"AuthenticationMode\": \"API_AND_CONFIG_MAP\"}";
|
||||
return "{\"Resources\": {"
|
||||
+ "\"Vpc\": {\"Type\": \"AWS::EC2::VPC\", \"Properties\": {\"CidrBlock\": \"10.7.0.0/16\"}},"
|
||||
|
||||
+65
-1
@@ -13,6 +13,8 @@ import io.floci.aws.services.eks.model.CreateClusterRequest;
|
||||
import io.floci.aws.services.eks.model.Logging;
|
||||
import io.floci.aws.services.eks.model.Nodegroup;
|
||||
import io.floci.aws.services.eks.model.OidcIdentity;
|
||||
import io.floci.aws.services.eks.model.UpdateClusterConfigRequest;
|
||||
import io.floci.aws.services.eks.model.UpgradePolicy;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
@@ -31,6 +33,7 @@ import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -92,7 +95,67 @@ class EksCfnProvisionerTest {
|
||||
"prod", event -> { }, before, PropertyChanges.between("AWS::EKS::Cluster", true, before, after));
|
||||
provisioner.provision(r, after, update);
|
||||
assertTrue(provisioner.rollbackUpdate(r));
|
||||
verify(eks, never()).restoreClusterConfig(any(), any(), any(), any());
|
||||
verify(eks, never()).restoreClusterConfig(any(), any(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aDroppedUpgradePolicyReturnsTheClusterToExtendedSupportAndARollbackRestoresIt() throws Exception {
|
||||
Cluster created = new Cluster();
|
||||
created.setName("prod");
|
||||
created.setArn("arn:aws:eks:us-east-1:000000000000:cluster/prod");
|
||||
when(eks.createCluster(any(CreateClusterRequest.class))).thenReturn(created);
|
||||
StackResource r = resource("AWS::EKS::Cluster", "Control");
|
||||
JsonNode before = props("{\"Name\": \"prod\", \"RoleArn\": \"arn:aws:iam::000000000000:role/eks\", "
|
||||
+ "\"UpgradePolicy\": {\"SupportType\": \"STANDARD\"}}");
|
||||
provisioner.provision(r, before, ctx());
|
||||
ArgumentCaptor<CreateClusterRequest> create = ArgumentCaptor.forClass(CreateClusterRequest.class);
|
||||
verify(eks).createCluster(create.capture());
|
||||
assertEquals(new UpgradePolicy("STANDARD"), create.getValue().getUpgradePolicy());
|
||||
|
||||
created.setUpgradePolicy(new UpgradePolicy("STANDARD"));
|
||||
when(eks.describeCluster("prod")).thenReturn(created);
|
||||
JsonNode after = props("{\"Name\": \"prod\", \"RoleArn\": \"arn:aws:iam::000000000000:role/eks\"}");
|
||||
ProvisionContext update = new ProvisionContext(ctx().engine(), "us-east-1", "000000000000", "my-stack",
|
||||
"prod", event -> { }, before, PropertyChanges.between("AWS::EKS::Cluster", true, before, after));
|
||||
provisioner.provision(r, after, update);
|
||||
|
||||
verify(eks).updateClusterConfig("prod",
|
||||
new UpdateClusterConfigRequest(null, null, null, new UpgradePolicy("EXTENDED"), null));
|
||||
assertTrue(provisioner.rollbackUpdate(r));
|
||||
verify(eks).restoreClusterConfig("prod", null, null, null, new UpgradePolicy("STANDARD"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anUnrelatedUpdateStoresThePolicyTheTemplateDeclaresForAClusterThatHoldsNone() throws Exception {
|
||||
Cluster created = new Cluster();
|
||||
created.setName("prod");
|
||||
created.setArn("arn:aws:eks:us-east-1:000000000000:cluster/prod");
|
||||
when(eks.createCluster(any(CreateClusterRequest.class))).thenReturn(created);
|
||||
StackResource r = resource("AWS::EKS::Cluster", "Control");
|
||||
String declared = "\"Name\": \"prod\", \"RoleArn\": \"arn:aws:iam::000000000000:role/eks\", "
|
||||
+ "\"UpgradePolicy\": {\"SupportType\": \"STANDARD\"}, ";
|
||||
JsonNode first = props("{" + declared + "\"Tags\": [{\"Key\": \"team\", \"Value\": \"a\"}]}");
|
||||
provisioner.provision(r, first, ctx());
|
||||
// A cluster created before Floci kept the policy holds none, and reports EXTENDED.
|
||||
created.setTags(new HashMap<>(Map.of("team", "a")));
|
||||
when(eks.describeCluster("prod")).thenReturn(created);
|
||||
|
||||
JsonNode second = props("{" + declared + "\"Tags\": [{\"Key\": \"team\", \"Value\": \"b\"}]}");
|
||||
provisioner.provision(r, second, update(first, second));
|
||||
verify(eks).restoreClusterConfig("prod", null, null, null, new UpgradePolicy("STANDARD"));
|
||||
verify(eks, never()).updateClusterConfig(any(), any());
|
||||
|
||||
// A cluster that holds a policy keeps it, as it keeps one changed outside the stack.
|
||||
created.setUpgradePolicy(new UpgradePolicy("EXTENDED"));
|
||||
JsonNode third = props("{" + declared + "\"Tags\": [{\"Key\": \"team\", \"Value\": \"c\"}]}");
|
||||
provisioner.provision(r, third, update(second, third));
|
||||
verify(eks, times(1)).restoreClusterConfig(any(), any(), any(), any(), any());
|
||||
verify(eks, never()).updateClusterConfig(any(), any());
|
||||
}
|
||||
|
||||
private ProvisionContext update(JsonNode before, JsonNode after) {
|
||||
return new ProvisionContext(ctx().engine(), "us-east-1", "000000000000", "my-stack",
|
||||
"prod", event -> { }, before, PropertyChanges.between("AWS::EKS::Cluster", true, before, after));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -197,6 +260,7 @@ class EksCfnProvisionerTest {
|
||||
return node == null ? null : node.asText();
|
||||
});
|
||||
when(engine.resolveNode(any())).thenAnswer(inv -> inv.getArgument(0));
|
||||
when(engine.omitNoValue(any())).thenAnswer(inv -> inv.getArgument(0));
|
||||
when(engine.resolveStringList(any())).thenAnswer(inv -> {
|
||||
JsonNode node = inv.getArgument(0);
|
||||
List<String> out = new ArrayList<>();
|
||||
|
||||
@@ -268,6 +268,12 @@ class EksEncryptionLoggingIntegrationTest {
|
||||
"{\"resourcesVpcConfig\":{\"endpointPublicAccess\":true},"
|
||||
+ "\"logging\":{\"clusterLogging\":[{\"types\":[\"audit\"],\"enabled\":true}]}}"
|
||||
+ "|400|InvalidParameterException|Only one type of update can be allowed.",
|
||||
"{\"upgradePolicy\":{\"supportType\":\"STANDARD\"},"
|
||||
+ "\"accessConfig\":{\"authenticationMode\":\"API\"}}"
|
||||
+ "|400|InvalidParameterException|Only one type of update can be allowed.",
|
||||
// upgradePolicy: an unknown support type, and none at all
|
||||
"{\"upgradePolicy\":{\"supportType\":\"BOGUS\"}}|400|InvalidParameterException|null",
|
||||
"{\"upgradePolicy\":{}}|400|InvalidParameterException|null",
|
||||
// a number where the model has a boolean, as createCluster refuses it
|
||||
"{\"resourcesVpcConfig\":{\"endpointPublicAccess\":1}}|400|SerializationException|null",
|
||||
// members UpdateClusterConfig does not support here
|
||||
@@ -295,6 +301,83 @@ class EksEncryptionLoggingIntegrationTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClusterGetsExtendedSupportUnlessItAsksForStandardAndAnUpdateChangesIt() {
|
||||
String standard = "it-upgrade-standard-" + UUID.randomUUID();
|
||||
String name = "it-upgrade-policy-" + UUID.randomUUID();
|
||||
try {
|
||||
createClusterFrom(standard, ",\"upgradePolicy\":{\"supportType\":\"STANDARD\"}");
|
||||
createClusterFrom(name, "");
|
||||
given().when().get("/clusters/" + standard).then().statusCode(200)
|
||||
.body("cluster.upgradePolicy.supportType", equalTo("STANDARD"));
|
||||
given().when().get("/clusters/" + name).then().statusCode(200)
|
||||
.body("cluster.upgradePolicy.supportType", equalTo("EXTENDED"));
|
||||
|
||||
String id = given().contentType(JSON)
|
||||
.body("{\"upgradePolicy\":{\"supportType\":\"STANDARD\"}}")
|
||||
.when().post("/clusters/" + name + "/update-config")
|
||||
.then().statusCode(200)
|
||||
.body("update.type", equalTo("UpgradePolicyUpdate"))
|
||||
.body("update.status", equalTo("Successful"))
|
||||
.body("update.params", hasSize(1))
|
||||
.body("update.params[0].type", equalTo("UpgradePolicy"))
|
||||
.body("update.params[0].value", equalTo("{\"supportType\":\"STANDARD\"}"))
|
||||
.extract().path("update.id");
|
||||
given().when().get("/clusters/" + name + "/updates/" + id).then().statusCode(200)
|
||||
.body("update.type", equalTo("UpgradePolicyUpdate"));
|
||||
given().when().get("/clusters/" + name).then().statusCode(200)
|
||||
.body("cluster.upgradePolicy.supportType", equalTo("STANDARD"));
|
||||
} finally {
|
||||
deleteCluster(standard);
|
||||
deleteCluster(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void standardSupportIsRefusedOnAVersionPastItsEndOfStandardSupport() {
|
||||
String name = "it-upgrade-retired-" + UUID.randomUUID();
|
||||
try {
|
||||
given().contentType(JSON)
|
||||
.body("{\"name\":\"" + name + "\",\"roleArn\":\"" + ROLE_ARN + "\",\"version\":\"1.30\","
|
||||
+ "\"upgradePolicy\":{\"supportType\":\"STANDARD\"}}")
|
||||
.when().post("/clusters")
|
||||
.then().statusCode(400).body("__type", equalTo("InvalidParameterException"))
|
||||
.body("message", equalTo("The requested Kubernetes version \"1.30\" is only supported under "
|
||||
+ "extended support. Please change the supportType to extended support to create the "
|
||||
+ "cluster."));
|
||||
createClusterFrom(name, ",\"version\":\"1.30\"");
|
||||
given().contentType(JSON)
|
||||
.body("{\"upgradePolicy\":{\"supportType\":\"STANDARD\"}}")
|
||||
.when().post("/clusters/" + name + "/update-config")
|
||||
.then().statusCode(400).body("__type", equalTo("InvalidParameterException"))
|
||||
.body("message", equalTo("The Kubernetes version \"1.30\" is not in standard support. Please "
|
||||
+ "update the cluster to a version in standard support to change the supportType"));
|
||||
given().when().get("/clusters/" + name).then().statusCode(200)
|
||||
.body("cluster.upgradePolicy.supportType", equalTo("EXTENDED"));
|
||||
} finally {
|
||||
deleteCluster(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClientRequestTokenReusedForAnotherUpgradePolicyIsRefused() {
|
||||
String name = createClusterFrom("it-upgrade-token-" + UUID.randomUUID(), "");
|
||||
try {
|
||||
given().contentType(JSON)
|
||||
.body("{\"clientRequestToken\":\"policy-1\",\"upgradePolicy\":{\"supportType\":\"STANDARD\"}}")
|
||||
.when().post("/clusters/" + name + "/update-config")
|
||||
.then().statusCode(200);
|
||||
given().contentType(JSON)
|
||||
.body("{\"clientRequestToken\":\"policy-1\",\"upgradePolicy\":{\"supportType\":\"EXTENDED\"}}")
|
||||
.when().post("/clusters/" + name + "/update-config")
|
||||
.then().statusCode(400).body("__type", equalTo("InvalidParameterException"));
|
||||
given().when().get("/clusters/" + name).then().statusCode(200)
|
||||
.body("cluster.upgradePolicy.supportType", equalTo("STANDARD"));
|
||||
} finally {
|
||||
deleteCluster(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateConfigWithTheSameClientRequestTokenReturnsTheSameUpdate() {
|
||||
String name = createClusterFrom("it-update-idempotent-" + UUID.randomUUID(), "");
|
||||
|
||||
@@ -52,6 +52,8 @@ import io.floci.aws.services.eks.model.ResourcesVpcConfig;
|
||||
import io.floci.aws.services.eks.model.StorageConfig;
|
||||
import io.floci.aws.services.eks.model.Update;
|
||||
import io.floci.aws.services.eks.model.UpdateClusterConfigRequest;
|
||||
import io.floci.aws.services.eks.model.UpdateParam;
|
||||
import io.floci.aws.services.eks.model.UpgradePolicy;
|
||||
import io.floci.aws.testing.ThreadStates;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -85,6 +87,7 @@ import java.util.stream.Collectors;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.inOrder;
|
||||
@@ -938,7 +941,7 @@ class EksServiceTest {
|
||||
vpc.setEndpointPublicAccess(false);
|
||||
vpc.setPublicAccessCidrs(List.of(cidr));
|
||||
AwsException e = assertThrows(AwsException.class, () -> service.updateClusterConfig(
|
||||
"cidr-cluster", new UpdateClusterConfigRequest(vpc, null, null, null)), cidr);
|
||||
"cidr-cluster", new UpdateClusterConfigRequest(vpc, null, null, null, null)), cidr);
|
||||
assertEquals("InvalidParameterException", e.getErrorCode(), cidr);
|
||||
ResourcesVpcConfig stored = service.describeCluster("cidr-cluster").getResourcesVpcConfig();
|
||||
assertEquals(Boolean.TRUE, stored.getEndpointPublicAccess(), cidr);
|
||||
@@ -947,6 +950,102 @@ class EksServiceTest {
|
||||
verify(addons, never()).recordUpdate(any(), anyString(), any(), any(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
void createClusterGivesExtendedSupportUnlessTheRequestAsksForStandard() {
|
||||
CreateClusterRequest noSupportType = new CreateClusterRequest();
|
||||
noSupportType.setName("policy-default");
|
||||
noSupportType.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
noSupportType.setUpgradePolicy(new UpgradePolicy(null));
|
||||
assertEquals(new UpgradePolicy("EXTENDED"), eksService.createCluster(noSupportType).getUpgradePolicy());
|
||||
|
||||
CreateClusterRequest standard = new CreateClusterRequest();
|
||||
standard.setName("policy-standard");
|
||||
standard.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
standard.setUpgradePolicy(new UpgradePolicy("STANDARD"));
|
||||
eksService.createCluster(standard);
|
||||
assertEquals(new UpgradePolicy("STANDARD"), eksService.describeCluster("policy-standard").getUpgradePolicy());
|
||||
|
||||
CreateClusterRequest bogus = new CreateClusterRequest();
|
||||
bogus.setName("policy-bogus");
|
||||
bogus.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
bogus.setUpgradePolicy(new UpgradePolicy("standard"));
|
||||
AwsException e = assertThrows(AwsException.class, () -> eksService.createCluster(bogus));
|
||||
assertEquals("InvalidParameterException", e.getErrorCode());
|
||||
assertEquals("Invalid supportType 'standard'. Valid values: STANDARD | EXTENDED", e.getMessage());
|
||||
assertFalse(eksService.listClusters().contains("policy-bogus"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void standardSupportIsRefusedForAVersionPastItsEndOfStandardSupport() {
|
||||
CreateClusterRequest create = new CreateClusterRequest();
|
||||
create.setName("policy-retired");
|
||||
create.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
create.setVersion("1.30");
|
||||
create.setUpgradePolicy(new UpgradePolicy("STANDARD"));
|
||||
AwsException refused = assertThrows(AwsException.class, () -> eksService.createCluster(create));
|
||||
assertEquals("InvalidParameterException", refused.getErrorCode());
|
||||
assertEquals("The requested Kubernetes version \"1.30\" is only supported under extended support. "
|
||||
+ "Please change the supportType to extended support to create the cluster.", refused.getMessage());
|
||||
assertFalse(eksService.listClusters().contains("policy-retired"));
|
||||
|
||||
create.setUpgradePolicy(null);
|
||||
eksService.createCluster(create);
|
||||
AwsException update = assertThrows(AwsException.class, () -> eksService.updateClusterConfig("policy-retired",
|
||||
new UpdateClusterConfigRequest(null, null, null, new UpgradePolicy("STANDARD"), null)));
|
||||
assertEquals("InvalidParameterException", update.getErrorCode());
|
||||
assertEquals("The Kubernetes version \"1.30\" is not in standard support. Please update the cluster to a "
|
||||
+ "version in standard support to change the supportType", update.getMessage());
|
||||
assertEquals(new UpgradePolicy("EXTENDED"), eksService.describeCluster("policy-retired").getUpgradePolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
void standardSupportIsAcceptedForAVersionTheCalendarDoesNotListYet() {
|
||||
CreateClusterRequest create = new CreateClusterRequest();
|
||||
create.setName("policy-newest");
|
||||
create.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
create.setVersion("1.38");
|
||||
create.setUpgradePolicy(new UpgradePolicy("STANDARD"));
|
||||
|
||||
assertEquals(new UpgradePolicy("STANDARD"), eksService.createCluster(create).getUpgradePolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
void aClusterStoredBeforeFlociKeptTheUpgradePolicyReportsExtendedSupport() throws Exception {
|
||||
// AWS gave existing clusters extended support too.
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Cluster stored = mapper.readValue("{\"name\":\"old\"}", Cluster.class);
|
||||
|
||||
assertEquals("EXTENDED", mapper.valueToTree(stored).path("upgradePolicy").path("supportType").asText());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateClusterConfigRecordsTheUpgradePolicyAsJsonAndRefusesAnUnknownSupportType() {
|
||||
EksAddonService addons = mock(EksAddonService.class);
|
||||
Update recorded = new Update("u", "Successful", "UpgradePolicyUpdate", List.of(), 0, List.of());
|
||||
when(addons.recordUpdate(any(), anyString(), any(), any(), any())).thenReturn(recorded);
|
||||
EksService service = new EksService(storageFactory, testConfig(), regionResolver, null, ec2Service,
|
||||
new EksOidcService(storageFactory, new ObjectMapper()), mock(EksAccessEntryService.class),
|
||||
mock(EksPodIdentityAssociationService.class), addons);
|
||||
CreateClusterRequest create = new CreateClusterRequest();
|
||||
create.setName("policy-update");
|
||||
create.setRoleArn("arn:aws:iam::000000000000:role/eks-role");
|
||||
service.createCluster(create);
|
||||
|
||||
AwsException e = assertThrows(AwsException.class, () -> service.updateClusterConfig("policy-update",
|
||||
new UpdateClusterConfigRequest(null, null, null, new UpgradePolicy("LONG"), null)));
|
||||
assertEquals("InvalidParameterException", e.getErrorCode());
|
||||
assertEquals(new UpgradePolicy("EXTENDED"), service.describeCluster("policy-update").getUpgradePolicy());
|
||||
verify(addons, never()).recordUpdate(any(), anyString(), any(), any(), any());
|
||||
|
||||
UpdateClusterConfigRequest request =
|
||||
new UpdateClusterConfigRequest(null, null, null, new UpgradePolicy("STANDARD"), null);
|
||||
service.updateClusterConfig("policy-update", request);
|
||||
|
||||
verify(addons).recordUpdate(any(), eq("UpgradePolicyUpdate"),
|
||||
eq(List.of(new UpdateParam("UpgradePolicy", "{\"supportType\":\"STANDARD\"}"))), any(), eq(request));
|
||||
assertEquals(new UpgradePolicy("STANDARD"), service.describeCluster("policy-update").getUpgradePolicy());
|
||||
}
|
||||
|
||||
@Test
|
||||
void updateClusterConfigMovesTheAuthenticationModeOneStepForwardOnly() {
|
||||
EksAddonService addons = mock(EksAddonService.class);
|
||||
@@ -966,7 +1065,7 @@ class EksServiceTest {
|
||||
create.setAccessConfig(new AccessConfig(modes.get(from), null));
|
||||
service.createCluster(create);
|
||||
UpdateClusterConfigRequest request = new UpdateClusterConfigRequest(
|
||||
null, null, new AccessConfig(modes.get(to), null), null);
|
||||
null, null, new AccessConfig(modes.get(to), null), null, null);
|
||||
if (to == from + 1) {
|
||||
service.updateClusterConfig(name, request);
|
||||
assertEquals(modes.get(to), service.describeCluster(name).getAccessConfig()
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package io.floci.aws.services.eks;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class EksVersionCalendarTest {
|
||||
|
||||
@Test
|
||||
void aVersionLeavesStandardSupportAtTheStartOfItsEndDateInUtc() {
|
||||
assertTrue(EksVersionCalendar.inStandardSupport("1.31", Instant.parse("2025-11-25T23:59:59Z")));
|
||||
assertFalse(EksVersionCalendar.inStandardSupport("1.31", Instant.parse("2025-11-26T00:00:00Z")));
|
||||
assertFalse(EksVersionCalendar.inStandardSupport("1.28", Instant.parse("2026-11-23T00:00:00Z")));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aVersionTheCalendarDoesNotListYetIsInStandardSupport() {
|
||||
assertTrue(EksVersionCalendar.inStandardSupport("1.38", Instant.parse("2030-01-01T00:00:00Z")));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user