Commit 1a7df26
committed
fix: prevent mkdef from creating partial objects on validation error
Add preflight validation to defmk that runs before any destructive
operations. Objects that fail only_if, groups-required, or group-
specific checks are removed from FINALATTRS before the OBJ loop,
preventing data loss from failed forced replacements and partial
object creation.
Semantics:
- mkdef is per-object atomic. In a multi-object command, valid objects
are created and invalid ones are rejected (command returns non-zero).
- Command-level errors (e.g. from setFINALattrs) block ALL objects.
Per-object preflight failures only block that specific object.
- mkdef -f: old object deleted only after replacement passes preflight.
- chdef: unchanged. Partial update semantics preserved.
DBobjUtils.pm:
- Add preflight_validate_mkdef() — checks only_if, groups requirement,
dynamic group attrs/wherevals, static group members+-w conflict.
Detects dynamic groups via both opt_d and grouptype=dynamic.
- Fix setobjdefs only_if main loop to check group inheritance, not
just the post-loop error handler. Ensures inherited attrs are written.
- Remove dead if(0) block (disabled since 2009 refactor).
DBobjectdefs.pm:
- Separate command-level errors from per-object preflight failures.
- Call preflight unconditionally. Failed objects removed per-object.
- Command-level errors clear all FINALATTRS (whole-command atomic).
- Empty-FINALATTRS early return for no-attributes case.
Note: CLI attribute name validation is not in scope. Unknown attrs
passed on the command line (not via -z) are silently ignored by
setFINALattrs — this is pre-existing behavior.
Fixes xcat2#3706
Fixes xcat2#27651 parent f006dc6 commit 1a7df26
3 files changed
Lines changed: 190 additions & 7 deletions
File tree
- perl-xCAT/xCAT
- xCAT-server/lib/xcat/plugins
- xCAT-test/autotest/testcase/mkdef
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1032 | 1032 | | |
1033 | 1033 | | |
1034 | 1034 | | |
1035 | | - | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
1036 | 1045 | | |
1037 | 1046 | | |
1038 | 1047 | | |
| |||
1063 | 1072 | | |
1064 | 1073 | | |
1065 | 1074 | | |
1066 | | - | |
| 1075 | + | |
| 1076 | + | |
| 1077 | + | |
| 1078 | + | |
| 1079 | + | |
| 1080 | + | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
| 1084 | + | |
| 1085 | + | |
1067 | 1086 | | |
1068 | 1087 | | |
1069 | 1088 | | |
| |||
2782 | 2801 | | |
2783 | 2802 | | |
2784 | 2803 | | |
| 2804 | + | |
| 2805 | + | |
| 2806 | + | |
| 2807 | + | |
| 2808 | + | |
| 2809 | + | |
| 2810 | + | |
| 2811 | + | |
| 2812 | + | |
| 2813 | + | |
| 2814 | + | |
| 2815 | + | |
| 2816 | + | |
| 2817 | + | |
| 2818 | + | |
| 2819 | + | |
| 2820 | + | |
| 2821 | + | |
| 2822 | + | |
| 2823 | + | |
| 2824 | + | |
| 2825 | + | |
| 2826 | + | |
| 2827 | + | |
| 2828 | + | |
| 2829 | + | |
| 2830 | + | |
| 2831 | + | |
| 2832 | + | |
| 2833 | + | |
| 2834 | + | |
| 2835 | + | |
| 2836 | + | |
| 2837 | + | |
| 2838 | + | |
| 2839 | + | |
| 2840 | + | |
| 2841 | + | |
| 2842 | + | |
| 2843 | + | |
| 2844 | + | |
| 2845 | + | |
| 2846 | + | |
| 2847 | + | |
| 2848 | + | |
| 2849 | + | |
| 2850 | + | |
| 2851 | + | |
2785 | 2852 | | |
2786 | 2853 | | |
2787 | 2854 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1671 | 1671 | | |
1672 | 1672 | | |
1673 | 1673 | | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
| 1677 | + | |
| 1678 | + | |
| 1679 | + | |
1674 | 1680 | | |
1675 | 1681 | | |
1676 | 1682 | | |
| 1683 | + | |
| 1684 | + | |
| 1685 | + | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
1677 | 1692 | | |
1678 | 1693 | | |
1679 | 1694 | | |
1680 | 1695 | | |
1681 | 1696 | | |
1682 | | - | |
1683 | | - | |
1684 | | - | |
| 1697 | + | |
| 1698 | + | |
1685 | 1699 | | |
1686 | 1700 | | |
1687 | 1701 | | |
1688 | 1702 | | |
| 1703 | + | |
| 1704 | + | |
1689 | 1705 | | |
1690 | 1706 | | |
1691 | 1707 | | |
| |||
1699 | 1715 | | |
1700 | 1716 | | |
1701 | 1717 | | |
1702 | | - | |
1703 | | - | |
| 1718 | + | |
| 1719 | + | |
1704 | 1720 | | |
1705 | 1721 | | |
1706 | 1722 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
| 524 | + | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
| 593 | + | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
0 commit comments