Skip to content

Commit 9487fb3

Browse files
committed
fix(sdk-extension-aws): fix AwsEksResourceDetector on EKS Access Entries API clusters
Replace aws-auth ConfigMap HTTP check with JWT iss claim decode. Clusters using the Access Entries API do not have aws-auth, causing HTTP 404 and silent empty resource. Pod service-account token iss always contains oidc.eks on EKS. Decoded locally, no network call required.
1 parent 7f107df commit 9487fb3

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

  • sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3030

3131
### Fixed
3232

33+
- `opentelemetry-sdk-extension-aws`: Fix `AwsEksResourceDetector` on clusters using the EKS Access Entries API mode where the `aws-auth` ConfigMap is absent; `_is_eks` now decodes the pod service-account JWT `iss` claim instead of querying the Kubernetes API.
34+
([#5080](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/5080))
3335
- `opentelemetry-docker-tests`: Replace deprecated `SpanAttributes` from `opentelemetry.semconv.trace` with `opentelemetry.semconv._incubating.attributes`
3436
([#4339](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/4339))
3537
- `opentelemetry-instrumentation-confluent-kafka`: Skip `recv` span creation when `poll()` returns no message or `consume()` returns an empty list, avoiding empty spans on idle polls

sdk-extension/opentelemetry-sdk-extension-aws/src/opentelemetry/sdk/extension/aws/resource/eks.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import base64
1516
import json
1617
import logging
1718
import os
@@ -32,6 +33,7 @@
3233

3334
_TOKEN_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/token"
3435
_CERT_PATH = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt"
36+
_EKS_OIDC_ISSUER = "oidc.eks."
3537

3638

3739
def _aws_http_request(method, path, cred_value):
@@ -60,11 +62,17 @@ def _get_k8s_cred_value():
6062

6163

6264
def _is_eks(cred_value):
63-
return _aws_http_request(
64-
_GET_METHOD,
65-
"/api/v1/namespaces/kube-system/configmaps/aws-auth",
66-
cred_value,
67-
)
65+
parts = cred_value.removeprefix("Bearer ").split(".")
66+
if len(parts) != 3:
67+
return False
68+
try:
69+
seg = parts[1]
70+
payload = json.loads(
71+
base64.urlsafe_b64decode(seg + "=" * (-len(seg) % 4))
72+
)
73+
except Exception:
74+
return False
75+
return _EKS_OIDC_ISSUER in payload.get("iss", "")
6876

6977

7078
def _get_cluster_info(cred_value):

0 commit comments

Comments
 (0)