Repository navigation
Commit d26060a
committed
fix: EksPodOperator 401 with cross-account AssumeRole via aws_conn_id
The kubeconfig exec plugin COMMAND template in EksHook had two critical
fragility points that caused 401 Unauthorized when using cross-account
AssumeRole credentials:
1. stderr was merged into stdout via 2>&1, so any Python warnings,
deprecation notices, or log output from eks_get_token contaminated
the stdout that bash token parsing relies on. This caused the
last_line extraction to grab the wrong line, producing empty/
invalid timestamp and token values.
2. No validation that the token was successfully extracted. If parsing
failed, a malformed ExecCredential JSON with an empty token was
sent to the EKS API server, resulting in 401 with an empty user
identity in the audit logs ("user":{}).
Same-account usage worked by accident because default MWAA execution
role credentials were already in the environment, so eks_get_token
produced valid output regardless of credential file sourcing.
Changes:
- Redirect stderr to /dev/null (2>/dev/null) instead of merging
with stdout (2>&1) to ensure clean token output for bash parsing
- Add token validation: exit with error if token extraction fails
- Add error messages to stderr for debugging credential issues
- Add unit tests verifying the COMMAND template structure
Fixes apache#646571 parent b91394a commit d26060a
2 files changed
Lines changed: 47 additions & 2 deletions
File tree
- providers/amazon
- src/airflow/providers/amazon/aws/hooks
- tests/unit/amazon/aws/hooks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
85 | 88 | | |
86 | | - | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | 95 | | |
93 | 96 | | |
94 | | - | |
| 97 | + | |
95 | 98 | | |
96 | 99 | | |
97 | 100 | | |
98 | 101 | | |
| 102 | + | |
99 | 103 | | |
100 | 104 | | |
101 | 105 | | |
| |||
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
107 | 121 | | |
108 | 122 | | |
109 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1273 | 1273 | | |
1274 | 1274 | | |
1275 | 1275 | | |
| 1276 | + | |
| 1277 | + | |
| 1278 | + | |
| 1279 | + | |
| 1280 | + | |
| 1281 | + | |
| 1282 | + | |
| 1283 | + | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
| 1287 | + | |
| 1288 | + | |
| 1289 | + | |
| 1290 | + | |
| 1291 | + | |
| 1292 | + | |
| 1293 | + | |
| 1294 | + | |
| 1295 | + | |
| 1296 | + | |
| 1297 | + | |
| 1298 | + | |
| 1299 | + | |
| 1300 | + | |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
1276 | 1307 | | |
1277 | 1308 | | |
1278 | 1309 | | |
| |||
0 commit comments