Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Mismatch on Owner id for windows ami #93

Merged
merged 3 commits into from
Mar 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 7 additions & 20 deletions eksupgrade/src/eks_get_image_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,18 @@ def image_type(node_type: str, image_id: str, region: str) -> Optional[str]:
"""Return the image location."""
ec2_client = boto3.client("ec2", region_name=region)
node_type = node_type.lower()
filters = [
{"Name": "is-public", "Values": ["true"]},
]

if node_type == "amazon linux 2":
filters = [
{"Name": "owner-id", "Values": ["602401143452"]},
{"Name": "name", "Values": ["amazon-eks-node-*"]},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": ["amazon-eks-node-*"]})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should change this to pull from the SSM parameters since this is the recommended approach. There may exist a newer AMI available based on these filters, but it may not be meant for consumption for various reasons (if the AMI is being recalled, etc.)

elif node_type == "ubuntu":
filters = [
{"Name": "owner-id", "Values": ["099720109477"]},
{"Name": "name", "Values": ["ubuntu-eks/k8s_*"]},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": ["ubuntu-eks/k8s_*"]})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can remove Ubuntu

elif node_type == "bottlerocket":
filters = [
{"Name": "owner-id", "Values": ["092701018921"]},
{"Name": "name", "Values": ["bottlerocket-aws-k8s-*"]},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": ["bottlerocket-aws-k8s-*"]})
elif node_type == "windows":
filters = [
{"Name": "owner-id", "Values": ["801119661308"]},
{"Name": "name", "Values": ["Windows_Server-*-English-*-EKS_Optimized-*"]},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": ["Windows_Server-*-English-*-EKS_Optimized-*"]})
else:
echo_warning(f"Node type: {node_type} is unsupported - Image ID: {image_id}")
return None
Expand Down
29 changes: 6 additions & 23 deletions eksupgrade/src/preflight_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -830,33 +830,16 @@ def security_group_check(errors, cluster_name, region, cluster, report, customer

# Check if the AMI is custom
def iscustomami(node_type, Presentversion, image_id, region):
filters = [{"Name": "is-public", "Values": ["true"]}]

if node_type == "Amazon Linux 2":
filters = [
{"Name": "owner-id", "Values": ["602401143452"]},
{"Name": "name", "Values": ["amazon-eks-node-{version}*".format(version=Presentversion)]},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": [f"amazon-eks-node-{Presentversion}*"]})
elif "ubuntu" in node_type.lower():
filters = [
{"Name": "owner-id", "Values": ["099720109477"]},
{"Name": "name", "Values": ["ubuntu-eks/k8s_{version}*".format(version=Presentversion)]},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": [f"ubuntu-eks/k8s_{Presentversion}*"]})
elif "bottlerocket" in node_type.lower():
filters = [
{"Name": "owner-id", "Values": ["092701018921"]},
{"Name": "name", "Values": ["bottlerocket-aws-k8s-{version}*".format(version=Presentversion)]},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": [f"bottlerocket-aws-k8s-{Presentversion}*"]})
elif "windows" in node_type.lower():
filters = [
{"Name": "owner-id", "Values": ["801119661308"]},
{
"Name": "name",
"Values": ["Windows_Server-*-English-*-EKS_Optimized-{version}*".format(version=Presentversion)],
},
{"Name": "is-public", "Values": ["true"]},
]
filters.append({"Name": "name", "Values": [f"Windows_Server-*-English-*-EKS_Optimized-{Presentversion}*"]})
else:
return True

Expand Down