@@ -126,8 +126,8 @@ def _run_main(self, parsed_args, parsed_globals):
126126 def discover_api_version (self ):
127127 """
128128 Parses the KUBERNETES_EXEC_INFO environment variable and returns the
129- API version. If the environment variable is empty, malformed, or
130- invalid, return the v1alpha1 response and print a message to stderr.
129+ API version. If the environment variable is malformed or invalid,
130+ return the v1beta1 response and print a message to stderr.
131131
132132 If the v1alpha1 API is specified explicitly, a message is printed to
133133 stderr with instructions to update.
@@ -139,7 +139,7 @@ def discover_api_version(self):
139139 # "v1beta1" will be removed. At or around that time, EKS will likely
140140 # support v1.22 through v1.28, in which client API version "v1beta1"
141141 # will be supported by all EKS versions.
142- fallback_api_version = ALPHA_API
142+ fallback_api_version = BETA_API
143143
144144 error_prefixes = {
145145 "error" : "Error parsing" ,
@@ -148,16 +148,12 @@ def discover_api_version(self):
148148
149149 exec_info_raw = os .environ .get ("KUBERNETES_EXEC_INFO" , "" )
150150 if not exec_info_raw :
151- # All kube clients should be setting this. Otherewise, we'll return
152- # the fallback and write an error.
153- uni_print (
154- ERROR_MSG_TPL .format (
155- error_prefixes ["empty" ],
156- fallback_api_version ,
157- ),
158- sys .stderr ,
159- )
160- uni_print ("\n " , sys .stderr )
151+ # All kube clients should be setting this, but client-go clients
152+ # (kubectl, kubelet, etc) < 1.20 were not setting this if the API
153+ # version defined in the kubeconfig was not v1alpha1.
154+ #
155+ # This was changed in kubernetes/kubernetes#95489 so that
156+ # KUBERNETES_EXEC_INFO is always provided
161157 return fallback_api_version
162158 try :
163159 exec_info = json .loads (exec_info_raw )
@@ -177,7 +173,7 @@ def discover_api_version(self):
177173 if api_version_raw in FULLY_SUPPORTED_API_VERSIONS :
178174 return api_version_raw
179175 elif api_version_raw in DEPRECATED_API_VERSIONS :
180- uni_print (DEPRECATION_MSG_TPL .format (ALPHA_API ), sys .stderr )
176+ uni_print (DEPRECATION_MSG_TPL .format (api_version_raw ), sys .stderr )
181177 uni_print ("\n " , sys .stderr )
182178 return api_version_raw
183179 else :
0 commit comments