Skip to content

Commit

Permalink
Merge branch 'main' into ack-bot/rt-v0.40.0-codegen-v0.40.0
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelhtm authored Dec 16, 2024
2 parents 79278d7 + 8b90acd commit 7c79574
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apis/v1alpha1/ack-generate-metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ api_directory_checksum: 4cfe0b6ec81b65719c1f165983b84116135f5e40
api_version: v1alpha1
aws_sdk_go_version: v1.55.5
generator_config_info:
file_checksum: 6c1343508adb97d2a4ff6f8328b2668356317b3b
file_checksum: 687d1b51c5afe75b62b50c3c32c83d7e6cadc3e3
original_file_name: generator.yaml
last_modification:
reason: API generation
2 changes: 2 additions & 0 deletions apis/v1alpha1/generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ resources:
template_path: hooks/identity_provider_config/sdk_read_one_post_set_output.go.tpl
post_set_resource_identifiers:
template_path: hooks/identity_provider_config/post_set_resource_identifiers.go.tpl
post_populate_resource_from_annotation:
template_path: hooks/identity_provider_config/post_populate_resource_from_annotation.go.tpl
update_operation:
custom_method_name: customUpdate
Cluster:
Expand Down
2 changes: 2 additions & 0 deletions generator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ resources:
template_path: hooks/identity_provider_config/sdk_read_one_post_set_output.go.tpl
post_set_resource_identifiers:
template_path: hooks/identity_provider_config/post_set_resource_identifiers.go.tpl
post_populate_resource_from_annotation:
template_path: hooks/identity_provider_config/post_populate_resource_from_annotation.go.tpl
update_operation:
custom_method_name: customUpdate
Cluster:
Expand Down
8 changes: 8 additions & 0 deletions pkg/resource/identity_provider_config/resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

if f0, f0ok := fields["identityProviderConfigName"]; f0ok {
r.ko.Spec.OIDC = &svcapitypes.OIDCIdentityProviderConfigRequest{
IdentityProviderConfigName: &f0,
}
} else {
return ackerrors.MissingNameIdentifier
}
2 changes: 2 additions & 0 deletions test/e2e/bootstrap_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@
from acktest.bootstrapping import Resources
from acktest.bootstrapping.iam import Role
from acktest.bootstrapping.vpc import VPC
from acktest.bootstrapping.eks import Cluster
from e2e import bootstrap_directory

@dataclass
class BootstrapResources(Resources):
AdoptionCluster: Cluster
ClusterVPC: VPC
ClusterRole: Role
FargatePodRole: Role
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/resources/cluster_adoption.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: eks.services.k8s.aws/v1alpha1
kind: Cluster
metadata:
name: $CLUSTER_ADOPTION_NAME
annotations:
services.k8s.aws/adoption-policy: $ADOPTION_POLICY
services.k8s.aws/adoption-fields: "$ADOPTION_FIELDS"
services.k8s.aws/deletion-policy: retain
2 changes: 2 additions & 0 deletions test/e2e/service_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from acktest.bootstrapping import Resources, BootstrapFailureException
from acktest.bootstrapping.iam import Role
from acktest.bootstrapping.vpc import VPC
from acktest.bootstrapping.eks import Cluster
from e2e import bootstrap_directory
from e2e.bootstrap_resources import BootstrapResources

Expand Down Expand Up @@ -54,6 +55,7 @@ def service_bootstrap() -> Resources:
"eks.amazonaws.com",
),
ClusterVPC=VPC(name_prefix="cluster-vpc", num_public_subnet=num_public_subnet, num_private_subnet=2),
AdoptionCluster=Cluster(name_prefix="adoption-cluster", num_managed_nodes=1)
)

try:
Expand Down
69 changes: 69 additions & 0 deletions test/e2e/tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,37 @@ def simple_cluster_version_minus_2(eks_client):
except:
pass

@pytest.fixture
def adoption_cluster(eks_client):
adopted_cluster = get_bootstrap_resources().AdoptionCluster
cluster_name = adopted_cluster.name
replacements = REPLACEMENT_VALUES.copy()
replacements["CLUSTER_ADOPTION_NAME"] = cluster_name
replacements["ADOPTION_POLICY"] = "adopt"
replacements["ADOPTION_FIELDS"] = f"{{\\\"name\\\": \\\"{cluster_name}\\\"}}"

resource_data = load_eks_resource(
"cluster_adoption",
additional_replacements=replacements,
)
logging.debug(resource_data)

# Create the k8s resource
ref = k8s.CustomResourceReference(
CRD_GROUP, CRD_VERSION, CLUSTER_RESOURCE_PLURAL,
cluster_name, namespace="default",
)
k8s.create_custom_resource(ref, resource_data)
cr = k8s.wait_resource_consumed_by_controller(ref, wait_periods=15)
assert cr is not None
assert k8s.get_resource_exists(ref)

yield (ref, cr)

_, deleted = k8s.delete_custom_resource(ref, 3, 10)
assert deleted


@service_marker
@pytest.mark.canary
class TestCluster:
Expand Down Expand Up @@ -380,3 +411,41 @@ def test_update_cluster_update_policy(self, eks_client, simple_cluster):
# At this point, the cluster should be active again at version 1.28
aws_res = eks_client.describe_cluster(name=cluster_name)
assert aws_res["cluster"]["upgradePolicy"]["supportType"] == "STANDARD"

def test_cluster_adopt_update(self, eks_client, adoption_cluster):
(ref, cr) = adoption_cluster

assert 'spec' in cr
assert 'name' in cr['spec']
cluster_name = cr["spec"]["name"]

wait_for_cluster_active(eks_client, cluster_name)

assert 'upgradePolicy' in cr['spec']
assert 'supportType' in cr['spec']['upgradePolicy']
support_type = cr['spec']['upgradePolicy']['supportType']
if support_type == 'STANDARD':
support_type = 'EXTENDED'
else:
support_type = 'STANDARD'

# Update the cluster name
updates = {
"spec": {
"upgradePolicy": {
"supportType": support_type
}
}
}

k8s.patch_custom_resource(ref, updates)
time.sleep(MODIFY_WAIT_AFTER_SECONDS*2)

# Wait for the updating to become active again
wait_for_cluster_active(eks_client, cluster_name)

# At this point, the cluster should be active again at version 1.28
aws_res = eks_client.describe_cluster(name=cluster_name)
assert aws_res
assert aws_res["cluster"]["upgradePolicy"]["supportType"] == support_type

0 comments on commit 7c79574

Please sign in to comment.