From e13fb4842b6a857f685536a4214382c0fff852b9 Mon Sep 17 00:00:00 2001 From: Mark Beacom <7315957+mbeacom@users.noreply.github.com> Date: Tue, 14 Feb 2023 10:07:51 -0500 Subject: [PATCH] Fix #37 - Remove deprecated API handling until it can be less misleading --- README.md | 2 +- eksupgrade/src/S3Files/deprecatedApi | 100 --------------------------- eksupgrade/src/preflight_module.py | 57 +-------------- 3 files changed, 2 insertions(+), 157 deletions(-) delete mode 100644 eksupgrade/src/S3Files/deprecatedApi diff --git a/README.md b/README.md index edd0d24..35c294a 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ There are a number of version compatibility constraints, health checks, etc., be 7. Pod Security Policy - Eks privileged role has to be checked to be present with the current pod security policy. 8. cluster addons - The cluster addons like kube-proxy, VPC CNI and CoreDNS are essential for running various services across the cluster and sometimes there are certain variable parameters present by them which have been customized by the users end as per the functionality the cluster supports which have to captured while upgrading and then added during the upgrade for the services to continue working smoothly as before. 9. Pod Disruption Budget - The existence of PDB has to be checked in the cluster and minimum and maximum available with it has to be taken into account while upgrading. -10. Horizontal Pod and Cluster Autoscaler - As the other components are upgraded to the compatible image version, a check firstly to check of these are present and then to upgrade them to compatible version with respect to the control plane. Deprecated API check - With every new version release there are a certain set of API which get deprecated and so a check for the resources running over them has to be done so that they do not break post upgrade +10. Horizontal Pod and Cluster Autoscaler - As the other components are upgraded to the compatible image version, a check firstly to check of these are present and then to upgrade them to compatible version with respect to the control plane. ### Cluster Upgrade diff --git a/eksupgrade/src/S3Files/deprecatedApi b/eksupgrade/src/S3Files/deprecatedApi deleted file mode 100644 index 48086ca..0000000 --- a/eksupgrade/src/S3Files/deprecatedApi +++ /dev/null @@ -1,100 +0,0 @@ -{ - "1.16": { - "ExtensionsV1beta1Api()": { - "NetworkingV1Api()": "networkpolicies", - "PolicyV1beta1Api()": "podsecuritypolicies", - "AppsV1Api()": "replicasets" - }, - "AppsV1beta2Api()": { - "AppsV1Api()": "replicasets" - }, - "AppsV1beta1Api()": { - "AppsV1Api()": "deployments" - } - }, - "1.18": { - "ExtensionsV1beta1Api()": { - "NetworkingV1Api()": "networkpolicies", - "PolicyV1beta1Api()": "podsecuritypolicies", - "AppsV1Api()": "replicasets" - }, - "all-resources": { - "apps/v1beta1": "apps/v1", - "apps/v1beta2": "apps/v1" - } - }, - "1.17": { - "all-resources": { - "rbac.authorization.k8s.io/v1alpha1": "rbac.authorization.k8s.io/v1", - "rbac.authorization.k8s.io/v1beta1": "rbac.authorization.k8s.io/v1" - } - }, - "1.19": { - "all-resources": { - "Apiextensions.k8s.io/v1beta1": "apiextensions.k8s.io/v1", - "Autoscaling/v2beta1": "autoscaling/v2beta2 ", - "Coordination.k8s.io/v1beta1": "v1 ", - "Authentication.k8s.io/v1beta1": "v1" - } - }, - "1.20": { - "all-resources": { - "metrics/resource/v1alpha1": "metrics/resource" - } - }, - "1.21": { - "all-resources": { - "audit.k8s.io/v1beta1": "audit.k8s.io/v1", - "audit.k8s.io/v1alpha1": "audit.k8s.io/v1 ", - "discovery.k8s.io/v1beta1": "discovery.k8s.io/v1", - "batch/v2alpha1" : "permanent" - } - }, - "1.22": { - "all-resources": { - "admissionregistration.k8s.io/v1beta1": "admissionregistration.k8s.io/v1", - "apiextensions.k8s.io/v1beta1": "apiextensions.k8s.io/v1", - "apiregistration.k8s.io/v1beta1": "apiregistration.k8s.io/v1", - "authentication.k8s.io/v1beta1": "authentication.k8s.io/v1", - "authorization.k8s.io/v1beta1": "authorization.k8s.io/v1", - "certificates.k8s.io/v1beta1": "certificates.k8s.io/v1", - "coordination.k8s.io/v1beta1": "coordination.k8s.io/v1", - "extensions/v1beta1": "networking.k8s.io/v1", - "networking.k8s.io/v1beta1": "networking.k8s.io/v1", - "rbac.authorization.k8s.io/v1beta1": " rbac.authorization.k8s.io/v1 ", - "scheduling.k8s.io/v1beta1": "scheduling.k8s.io/v1", - "storage.k8s.io/v1beta1": "storage.k8s.io/v1" - } - }, - "1.23": { - "all-resources": {} - }, - "1.24": { - "all-resources": {} - }, - "1.25": { - "all-resources": { - "batch/v1beta1": "batch/v1", - "discovery.k8s.io/v1beta1": "discovery.k8s.io/v1", - "events.k8s.io/v1beta1": "events.k8s.io/v1", - "autoscaling/v2beta1": "autoscaling/v2", - "policy/v1beta1": "policy/v1", - "node.k8s.io/v1beta1": "node.k8s.io/v1" - } - }, - "1.26": { - "flowcontrol.apiserver.k8s.io/v1beta1": "flowcontrol.apiserver.k8s.io/v1beta3", - "autoscaling/v2beta2": "autoscaling/v2" - }, - "1.27": { - "storage.k8s.io/v1beta1": "storage.k8s.io/v1" - }, - "1.28": { - "all-resources": {} - }, - "1.29": { - "all-resources": { - "flowcontrol.apiserver.k8s.io/v1beta2": "flowcontrol.apiserver.k8s.io/v1beta3" - } - } - } diff --git a/eksupgrade/src/preflight_module.py b/eksupgrade/src/preflight_module.py index dfc3167..d823a8c 100644 --- a/eksupgrade/src/preflight_module.py +++ b/eksupgrade/src/preflight_module.py @@ -140,8 +140,7 @@ def get_cluster_version( horizontal_auto_scaler(errors, cluster_name, region, report, customer_report) cluster_auto_scaler(errors, cluster_name, region, report, customer_report) - if report["cluster"]["version"] != "1.21" and update_version: - deprecated_api_check(errors, cluster_name, region, report, customer_report, update_version) + # TODO: Revisit deprecation checks. Disabled due to confusing or misleading results per GH Issue #37. if email: logger.info("Delivering report via Email...") @@ -829,56 +828,6 @@ def horizontal_auto_scaler(errors, cluster_name, region, report, customer_report report["preflight_status"] = False -def deprecated_api_check(errors, cluster_name, region, report, customer_report, update_version): - loading_config(cluster_name, region) - with open("eksupgrade/src/S3Files/deprecatedApi", "r", encoding="utf-8") as f: - deprecated_api = json.load(f) - - logger.info("Checking for any deprecated API being used....") - customer_report["deprecated Api"] = [] - try: - dict = deprecated_api[update_version] - for key in dict.keys(): - if key == "all-resources": - for k in dict[key].keys(): - if dict[key][k] == "permanent": - customer_report["deprecated Api"].append(f"{k} API has been deprecated permanently ") - logger.info("%s API has been deprecated permanently", k) - else: - customer_report["deprecated Api"].append( - f"{k} API has been deprecated use {dict[key][k]} instead" - ) - logger.info("%s API has been deprecated use %s instead", k, dict[key][k]) - else: - deprecated_resource = [] - new_resource = [] - v1 = eval(key) - res = v1.get_api_resources() - for resource in res.resources: - deprecated_resource.append(resource.name) - for k in dict[key].keys(): - v2 = eval(k) - ret = v2.get_api_resources() - for resource in ret.resources: - new_resource.append(resource.name) - if dict[key][k] in deprecated_resource and dict[key][k] not in new_resource: - customer_report["deprecated Api"].append( - f"Resource {dict[key][k]} is present in deprecated API {key} to be shifted to {k}" - ) - errors.append( - f"Resource {dict[key][k]} is present in deprecated API {key} to be shifted to {k}" - ) - logger.info( - "Resource %s is present in deprecated API %s to be shifted to %s", dict[key][k], key, k - ) - logger.info("Deprecated Api check completed") - except Exception as e: - errors.append(f"Deprecated API check failed {e}") - customer_report["deprecated Api"].append("Deprecated API check failed") - logger.error("Deprecated API check failed - Error: %s", e) - report["preflight_status"] = False - - def cmk_key_check(errors, cluster_name, region, cluster, report, customer_report): loading_config(cluster_name, region) cmk = boto3.client("kms", region_name=region) @@ -1182,10 +1131,6 @@ def send_email(preflight, cluster_name, region, report, customer_report, email): htmlStart = htmlStart + "
  • " + str(s) + "
  • " htmlStart = htmlStart + "" htmlStart = htmlStart + "cluster version" + customer_report["cluster version"] + "" - if "deprecated Api" in customer_report.keys(): - htmlStart = ( - htmlStart + "deprecated Api" + str(customer_report["deprecated Api"]) + "" - ) htmlStart = ( htmlStart + "horizontal auto scaler"