Skip to content

Commit 7c79574

Browse files
authored
Merge branch 'main' into ack-bot/rt-v0.40.0-codegen-v0.40.0
2 parents 79278d7 + 8b90acd commit 7c79574

File tree

9 files changed

+102
-1
lines changed

9 files changed

+102
-1
lines changed

apis/v1alpha1/ack-generate-metadata.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ api_directory_checksum: 4cfe0b6ec81b65719c1f165983b84116135f5e40
77
api_version: v1alpha1
88
aws_sdk_go_version: v1.55.5
99
generator_config_info:
10-
file_checksum: 6c1343508adb97d2a4ff6f8328b2668356317b3b
10+
file_checksum: 687d1b51c5afe75b62b50c3c32c83d7e6cadc3e3
1111
original_file_name: generator.yaml
1212
last_modification:
1313
reason: API generation

apis/v1alpha1/generator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ resources:
147147
template_path: hooks/identity_provider_config/sdk_read_one_post_set_output.go.tpl
148148
post_set_resource_identifiers:
149149
template_path: hooks/identity_provider_config/post_set_resource_identifiers.go.tpl
150+
post_populate_resource_from_annotation:
151+
template_path: hooks/identity_provider_config/post_populate_resource_from_annotation.go.tpl
150152
update_operation:
151153
custom_method_name: customUpdate
152154
Cluster:

generator.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ resources:
147147
template_path: hooks/identity_provider_config/sdk_read_one_post_set_output.go.tpl
148148
post_set_resource_identifiers:
149149
template_path: hooks/identity_provider_config/post_set_resource_identifiers.go.tpl
150+
post_populate_resource_from_annotation:
151+
template_path: hooks/identity_provider_config/post_populate_resource_from_annotation.go.tpl
150152
update_operation:
151153
custom_method_name: customUpdate
152154
Cluster:

pkg/resource/identity_provider_config/resource.go

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
if f0, f0ok := fields["identityProviderConfigName"]; f0ok {
3+
r.ko.Spec.OIDC = &svcapitypes.OIDCIdentityProviderConfigRequest{
4+
IdentityProviderConfigName: &f0,
5+
}
6+
} else {
7+
return ackerrors.MissingNameIdentifier
8+
}

test/e2e/bootstrap_resources.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,12 @@
1919
from acktest.bootstrapping import Resources
2020
from acktest.bootstrapping.iam import Role
2121
from acktest.bootstrapping.vpc import VPC
22+
from acktest.bootstrapping.eks import Cluster
2223
from e2e import bootstrap_directory
2324

2425
@dataclass
2526
class BootstrapResources(Resources):
27+
AdoptionCluster: Cluster
2628
ClusterVPC: VPC
2729
ClusterRole: Role
2830
FargatePodRole: Role
+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: eks.services.k8s.aws/v1alpha1
2+
kind: Cluster
3+
metadata:
4+
name: $CLUSTER_ADOPTION_NAME
5+
annotations:
6+
services.k8s.aws/adoption-policy: $ADOPTION_POLICY
7+
services.k8s.aws/adoption-fields: "$ADOPTION_FIELDS"
8+
services.k8s.aws/deletion-policy: retain

test/e2e/service_bootstrap.py

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from acktest.bootstrapping import Resources, BootstrapFailureException
2020
from acktest.bootstrapping.iam import Role
2121
from acktest.bootstrapping.vpc import VPC
22+
from acktest.bootstrapping.eks import Cluster
2223
from e2e import bootstrap_directory
2324
from e2e.bootstrap_resources import BootstrapResources
2425

@@ -54,6 +55,7 @@ def service_bootstrap() -> Resources:
5455
"eks.amazonaws.com",
5556
),
5657
ClusterVPC=VPC(name_prefix="cluster-vpc", num_public_subnet=num_public_subnet, num_private_subnet=2),
58+
AdoptionCluster=Cluster(name_prefix="adoption-cluster", num_managed_nodes=1)
5759
)
5860

5961
try:

test/e2e/tests/test_cluster.py

+69
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,37 @@ def simple_cluster_version_minus_2(eks_client):
139139
except:
140140
pass
141141

142+
@pytest.fixture
143+
def adoption_cluster(eks_client):
144+
adopted_cluster = get_bootstrap_resources().AdoptionCluster
145+
cluster_name = adopted_cluster.name
146+
replacements = REPLACEMENT_VALUES.copy()
147+
replacements["CLUSTER_ADOPTION_NAME"] = cluster_name
148+
replacements["ADOPTION_POLICY"] = "adopt"
149+
replacements["ADOPTION_FIELDS"] = f"{{\\\"name\\\": \\\"{cluster_name}\\\"}}"
150+
151+
resource_data = load_eks_resource(
152+
"cluster_adoption",
153+
additional_replacements=replacements,
154+
)
155+
logging.debug(resource_data)
156+
157+
# Create the k8s resource
158+
ref = k8s.CustomResourceReference(
159+
CRD_GROUP, CRD_VERSION, CLUSTER_RESOURCE_PLURAL,
160+
cluster_name, namespace="default",
161+
)
162+
k8s.create_custom_resource(ref, resource_data)
163+
cr = k8s.wait_resource_consumed_by_controller(ref, wait_periods=15)
164+
assert cr is not None
165+
assert k8s.get_resource_exists(ref)
166+
167+
yield (ref, cr)
168+
169+
_, deleted = k8s.delete_custom_resource(ref, 3, 10)
170+
assert deleted
171+
172+
142173
@service_marker
143174
@pytest.mark.canary
144175
class TestCluster:
@@ -380,3 +411,41 @@ def test_update_cluster_update_policy(self, eks_client, simple_cluster):
380411
# At this point, the cluster should be active again at version 1.28
381412
aws_res = eks_client.describe_cluster(name=cluster_name)
382413
assert aws_res["cluster"]["upgradePolicy"]["supportType"] == "STANDARD"
414+
415+
def test_cluster_adopt_update(self, eks_client, adoption_cluster):
416+
(ref, cr) = adoption_cluster
417+
418+
assert 'spec' in cr
419+
assert 'name' in cr['spec']
420+
cluster_name = cr["spec"]["name"]
421+
422+
wait_for_cluster_active(eks_client, cluster_name)
423+
424+
assert 'upgradePolicy' in cr['spec']
425+
assert 'supportType' in cr['spec']['upgradePolicy']
426+
support_type = cr['spec']['upgradePolicy']['supportType']
427+
if support_type == 'STANDARD':
428+
support_type = 'EXTENDED'
429+
else:
430+
support_type = 'STANDARD'
431+
432+
# Update the cluster name
433+
updates = {
434+
"spec": {
435+
"upgradePolicy": {
436+
"supportType": support_type
437+
}
438+
}
439+
}
440+
441+
k8s.patch_custom_resource(ref, updates)
442+
time.sleep(MODIFY_WAIT_AFTER_SECONDS*2)
443+
444+
# Wait for the updating to become active again
445+
wait_for_cluster_active(eks_client, cluster_name)
446+
447+
# At this point, the cluster should be active again at version 1.28
448+
aws_res = eks_client.describe_cluster(name=cluster_name)
449+
assert aws_res
450+
assert aws_res["cluster"]["upgradePolicy"]["supportType"] == support_type
451+

0 commit comments

Comments
 (0)