Repository navigation
Commit 277f01c
authored
Fix KubernetesPodOperator to forward pod log levels to Airflow task logs (#64829)
* Fix KubernetesPodOperator to forward pod log levels to Airflow task logs
Previously all pod container output was logged at INFO level regardless
of the original log level. Now ERROR, WARNING, DEBUG, CRITICAL prefixes
are detected and forwarded at the correct Python logging level.
closes: #64820
* Fix _log_message to use log.info() for INFO level messages
Use self.log.info() for INFO-level messages and self.log.log(level, ...)
only for non-INFO levels, restoring backward compatibility with existing
tests that mock log.info directly.
* Address review feedback: simplify log dispatch and add level detection to async path
- Consolidate if/else in _log_message to a single self.log.log(level, msg) call
- Apply _parse_log_level() in AsyncPodManager.fetch_container_logs_before_current_sec()
so deferrable/async task logs are also forwarded at the correct level instead of always INFO
- Update test to assert self.log.log() instead of self.log.info() for async path
* Fix test assertions for log level detection
- Add missing assert_called_once() in test_log_message_defaults_to_info_for_plain_lines
for consistency with test_log_message_uses_detected_log_level
- Use _parse_log_level() to derive expected level in async test assertions
instead of hardcoding logging.INFO, matching what production code does
* Fix system test assertions broken by log.log() change
test_volume_mount and test_log_output_configurations were asserting
log.info() calls, but _log_message now always uses self.log.log(level, ...)
Update both tests to assert log.log() calls instead.1 parent 6c598e2 commit 277f01c
3 files changed
Lines changed: 90 additions & 14 deletions
File tree
- kubernetes-tests/tests/kubernetes_tests
- providers/cncf/kubernetes
- src/airflow/providers/cncf/kubernetes/utils
- tests/unit/cncf/kubernetes/utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
554 | 554 | | |
555 | 555 | | |
556 | 556 | | |
557 | | - | |
| 557 | + | |
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| |||
1480 | 1480 | | |
1481 | 1481 | | |
1482 | 1482 | | |
1483 | | - | |
| 1483 | + | |
1484 | 1484 | | |
1485 | 1485 | | |
1486 | 1486 | | |
| |||
1489 | 1489 | | |
1490 | 1490 | | |
1491 | 1491 | | |
1492 | | - | |
1493 | | - | |
| 1492 | + | |
| 1493 | + | |
1494 | 1494 | | |
1495 | 1495 | | |
1496 | 1496 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
24 | 25 | | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
| |||
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
77 | 106 | | |
78 | 107 | | |
79 | 108 | | |
| |||
436 | 465 | | |
437 | 466 | | |
438 | 467 | | |
439 | | - | |
| 468 | + | |
440 | 469 | | |
441 | 470 | | |
442 | 471 | | |
| 472 | + | |
443 | 473 | | |
444 | 474 | | |
445 | | - | |
446 | 475 | | |
447 | | - | |
| 476 | + | |
448 | 477 | | |
449 | 478 | | |
450 | | - | |
| 479 | + | |
451 | 480 | | |
452 | 481 | | |
453 | 482 | | |
| |||
1180 | 1209 | | |
1181 | 1210 | | |
1182 | 1211 | | |
1183 | | - | |
| 1212 | + | |
| 1213 | + | |
1184 | 1214 | | |
1185 | 1215 | | |
1186 | 1216 | | |
| |||
1190 | 1220 | | |
1191 | 1221 | | |
1192 | 1222 | | |
1193 | | - | |
| 1223 | + | |
| 1224 | + | |
1194 | 1225 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| 39 | + | |
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
| |||
153 | 154 | | |
154 | 155 | | |
155 | 156 | | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
156 | 199 | | |
157 | 200 | | |
158 | 201 | | |
| |||
1503 | 1546 | | |
1504 | 1547 | | |
1505 | 1548 | | |
1506 | | - | |
| 1549 | + | |
1507 | 1550 | | |
1508 | 1551 | | |
1509 | 1552 | | |
1510 | 1553 | | |
1511 | 1554 | | |
1512 | 1555 | | |
1513 | | - | |
| 1556 | + | |
1514 | 1557 | | |
1515 | | - | |
1516 | | - | |
| 1558 | + | |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
1517 | 1562 | | |
1518 | 1563 | | |
1519 | 1564 | | |
| |||
0 commit comments