Commit 79724c6
authored
ensure status is patched on adoption (#218)
Issue [#2682](aws-controllers-k8s/community#2682)
## Changes Made
### reconciler.go:
- **Improved error handling**: Initialize `latest` with `desired.DeepCopy()` to ensure consistent resource state is returned on errors
- **Fixed return values**: Use named return parameters and return appropriate resource state in all error paths
- **Enhanced late initialization**: Separate late initialization result handling to prevent state loss
- **Cleaner variable management**: Removed redundant variable declarations
### util.go:
- **Fixed adoption fields extraction**: Return proper error when annotation is missing instead of empty string
- **Simplified field lookup**: Use direct map access instead of iteration for better performance
- **Corrected JSON unmarshaling**: Fix pointer usage in unmarshaling operation
### reconciler_test.go:
- **Updated test mocks**: Align mock expectations with new resource state handling
- **Fixed condition assertions**: Correct expected condition states for error scenarios
- **Enhanced error path testing**: Better validation of resource states during error conditions
## Impact
- Ensures consistent resource state is always returned from reconciler operations
- Improves error handling reliability and debugging capabilities
- Fixes potential nil pointer issues in error scenarios
- Better test coverage alignment with actual implementation behavior
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.1 parent 981220e commit 79724c6
File tree
4 files changed
+79
-58
lines changed- pkg
- errors
- runtime
4 files changed
+79
-58
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
123 | 123 | | |
124 | 124 | | |
125 | 125 | | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
126 | 131 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
505 | 505 | | |
506 | 506 | | |
507 | 507 | | |
508 | | - | |
509 | | - | |
| 508 | + | |
510 | 509 | | |
511 | 510 | | |
512 | 511 | | |
513 | 512 | | |
514 | 513 | | |
515 | 514 | | |
516 | | - | |
517 | | - | |
518 | 515 | | |
519 | 516 | | |
520 | 517 | | |
521 | 518 | | |
522 | 519 | | |
| 520 | + | |
523 | 521 | | |
524 | 522 | | |
525 | 523 | | |
| |||
528 | 526 | | |
529 | 527 | | |
530 | 528 | | |
531 | | - | |
| 529 | + | |
532 | 530 | | |
533 | 531 | | |
534 | 532 | | |
| |||
543 | 541 | | |
544 | 542 | | |
545 | 543 | | |
546 | | - | |
547 | 544 | | |
548 | | - | |
| 545 | + | |
| 546 | + | |
549 | 547 | | |
550 | 548 | | |
551 | 549 | | |
| |||
554 | 552 | | |
555 | 553 | | |
556 | 554 | | |
557 | | - | |
| 555 | + | |
558 | 556 | | |
559 | 557 | | |
560 | 558 | | |
| |||
579 | 577 | | |
580 | 578 | | |
581 | 579 | | |
582 | | - | |
| 580 | + | |
583 | 581 | | |
584 | 582 | | |
585 | | - | |
| 583 | + | |
586 | 584 | | |
587 | 585 | | |
588 | | - | |
| 586 | + | |
589 | 587 | | |
590 | 588 | | |
591 | | - | |
| 589 | + | |
592 | 590 | | |
593 | 591 | | |
594 | 592 | | |
595 | 593 | | |
596 | | - | |
| 594 | + | |
597 | 595 | | |
598 | 596 | | |
599 | 597 | | |
600 | | - | |
| 598 | + | |
601 | 599 | | |
602 | 600 | | |
603 | 601 | | |
| |||
625 | 623 | | |
626 | 624 | | |
627 | 625 | | |
628 | | - | |
| 626 | + | |
| 627 | + | |
629 | 628 | | |
630 | 629 | | |
631 | | - | |
| 630 | + | |
632 | 631 | | |
633 | 632 | | |
634 | 633 | | |
| |||
670 | 669 | | |
671 | 670 | | |
672 | 671 | | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
673 | 679 | | |
674 | 680 | | |
675 | 681 | | |
| |||
688 | 694 | | |
689 | 695 | | |
690 | 696 | | |
691 | | - | |
| 697 | + | |
692 | 698 | | |
693 | 699 | | |
694 | 700 | | |
| |||
1319 | 1325 | | |
1320 | 1326 | | |
1321 | 1327 | | |
| 1328 | + | |
1322 | 1329 | | |
1323 | 1330 | | |
1324 | 1331 | | |
| |||
1335 | 1342 | | |
1336 | 1343 | | |
1337 | 1344 | | |
1338 | | - | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
1339 | 1348 | | |
1340 | 1349 | | |
1341 | | - | |
1342 | 1350 | | |
1343 | 1351 | | |
1344 | 1352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
252 | 252 | | |
253 | 253 | | |
254 | 254 | | |
255 | | - | |
256 | | - | |
| 255 | + | |
| 256 | + | |
257 | 257 | | |
258 | 258 | | |
259 | 259 | | |
| |||
270 | 270 | | |
271 | 271 | | |
272 | 272 | | |
273 | | - | |
| 273 | + | |
274 | 274 | | |
275 | 275 | | |
276 | 276 | | |
| |||
1495 | 1495 | | |
1496 | 1496 | | |
1497 | 1497 | | |
1498 | | - | |
| 1498 | + | |
1499 | 1499 | | |
1500 | 1500 | | |
1501 | | - | |
| 1501 | + | |
1502 | 1502 | | |
1503 | 1503 | | |
| 1504 | + | |
1504 | 1505 | | |
1505 | 1506 | | |
1506 | 1507 | | |
| |||
1514 | 1515 | | |
1515 | 1516 | | |
1516 | 1517 | | |
| 1518 | + | |
1517 | 1519 | | |
1518 | 1520 | | |
1519 | 1521 | | |
| |||
1603 | 1605 | | |
1604 | 1606 | | |
1605 | 1607 | | |
1606 | | - | |
| 1608 | + | |
1607 | 1609 | | |
1608 | 1610 | | |
1609 | 1611 | | |
| |||
1631 | 1633 | | |
1632 | 1634 | | |
1633 | 1635 | | |
1634 | | - | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
1635 | 1655 | | |
1636 | 1656 | | |
1637 | 1657 | | |
1638 | 1658 | | |
1639 | 1659 | | |
1640 | 1660 | | |
1641 | 1661 | | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
1645 | | - | |
1646 | | - | |
1647 | | - | |
1648 | 1662 | | |
1649 | 1663 | | |
1650 | | - | |
1651 | | - | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
1657 | | - | |
| 1664 | + | |
1658 | 1665 | | |
1659 | 1666 | | |
1660 | 1667 | | |
| |||
1690 | 1697 | | |
1691 | 1698 | | |
1692 | 1699 | | |
1693 | | - | |
| 1700 | + | |
1694 | 1701 | | |
1695 | 1702 | | |
1696 | 1703 | | |
| |||
1704 | 1711 | | |
1705 | 1712 | | |
1706 | 1713 | | |
1707 | | - | |
1708 | | - | |
| 1714 | + | |
| 1715 | + | |
1709 | 1716 | | |
1710 | 1717 | | |
1711 | 1718 | | |
| |||
1715 | 1722 | | |
1716 | 1723 | | |
1717 | 1724 | | |
1718 | | - | |
1719 | | - | |
| 1725 | + | |
| 1726 | + | |
1720 | 1727 | | |
1721 | | - | |
| 1728 | + | |
| 1729 | + | |
1722 | 1730 | | |
1723 | 1731 | | |
1724 | 1732 | | |
| |||
1738 | 1746 | | |
1739 | 1747 | | |
1740 | 1748 | | |
1741 | | - | |
| 1749 | + | |
1742 | 1750 | | |
1743 | 1751 | | |
1744 | 1752 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
211 | | - | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
212 | 215 | | |
213 | | - | |
214 | | - | |
| 216 | + | |
| 217 | + | |
215 | 218 | | |
216 | 219 | | |
217 | 220 | | |
218 | 221 | | |
219 | | - | |
| 222 | + | |
220 | 223 | | |
221 | 224 | | |
222 | | - | |
| 225 | + | |
223 | 226 | | |
224 | 227 | | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
228 | 231 | | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
235 | 235 | | |
236 | 236 | | |
237 | 237 | | |
| |||
0 commit comments