Commit 6836d43
committed
Fix stale resource cache, specific-name targeting, and add sync_resources
Three bugs fixed and one new feature added:
1. salt '*' test.ping was incorrectly dispatching to resources when
targeting a specific minion by name (e.g. salt 'minion' test.ping).
_resolve_resource_targets now only dispatches to resources for wildcard
glob patterns (* ? [). The master-side _augment_with_resources guard
is updated consistently.
2. Removing a resource type from the pillar and running sync_all left
stale resource IDs in the master cache indefinitely, causing phantom
entries in salt '*' output. Three co-operating fixes:
- _discover_resources now distinguishes "no resources key in pillar"
(preserve opts for config-file deployments) from "resources key
present but empty" (authoritative removal — clear opts).
- _register_resources_with_master no longer short-circuits on an empty
resource dict; it always sends the registration so the master cache
is overwritten with the current (possibly empty) state.
- pillar_refresh re-discovers resources and re-registers with the
master after successfully compiling a new pillar, so a sync_all
picks up removals without requiring a minion restart.
3. _augment_with_resources had no error handling; a cache driver failure
would propagate into check_minions and silently discard all PKI-based
minion IDs. Cache errors are now caught, logged, and degraded
gracefully.
New: saltutil.sync_resources / refresh_resources — explicit resource
sync modelled after sync_modules/refresh_modules. sync_all now includes
ret["resources"] and fires a resource_refresh event that triggers
_discover_resources + _register_resources_with_master on the minion.1 parent bfcbe05 commit 6836d43
5 files changed
Lines changed: 245 additions & 59 deletions
File tree
- salt
- modules
- utils
- tests/pytests/unit
- utils
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
556 | 556 | | |
557 | 557 | | |
558 | 558 | | |
559 | | - | |
560 | | - | |
561 | | - | |
562 | | - | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
563 | 569 | | |
564 | 570 | | |
565 | 571 | | |
566 | 572 | | |
567 | | - | |
568 | | - | |
569 | | - | |
570 | | - | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
571 | 576 | | |
| 577 | + | |
572 | 578 | | |
573 | 579 | | |
574 | 580 | | |
| |||
3340 | 3346 | | |
3341 | 3347 | | |
3342 | 3348 | | |
| 3349 | + | |
| 3350 | + | |
| 3351 | + | |
| 3352 | + | |
3343 | 3353 | | |
3344 | 3354 | | |
3345 | | - | |
3346 | | - | |
3347 | 3355 | | |
3348 | 3356 | | |
3349 | 3357 | | |
| |||
3459 | 3467 | | |
3460 | 3468 | | |
3461 | 3469 | | |
| 3470 | + | |
| 3471 | + | |
| 3472 | + | |
| 3473 | + | |
| 3474 | + | |
| 3475 | + | |
3462 | 3476 | | |
3463 | 3477 | | |
3464 | 3478 | | |
| |||
3678 | 3692 | | |
3679 | 3693 | | |
3680 | 3694 | | |
| 3695 | + | |
| 3696 | + | |
| 3697 | + | |
3681 | 3698 | | |
3682 | 3699 | | |
3683 | 3700 | | |
| |||
4440 | 4457 | | |
4441 | 4458 | | |
4442 | 4459 | | |
4443 | | - | |
4444 | | - | |
| 4460 | + | |
| 4461 | + | |
4445 | 4462 | | |
4446 | | - | |
| 4463 | + | |
| 4464 | + | |
| 4465 | + | |
4447 | 4466 | | |
4448 | 4467 | | |
4449 | 4468 | | |
| |||
4479 | 4498 | | |
4480 | 4499 | | |
4481 | 4500 | | |
4482 | | - | |
4483 | | - | |
| 4501 | + | |
| 4502 | + | |
| 4503 | + | |
| 4504 | + | |
| 4505 | + | |
| 4506 | + | |
| 4507 | + | |
| 4508 | + | |
| 4509 | + | |
| 4510 | + | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
4484 | 4514 | | |
4485 | 4515 | | |
4486 | 4516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
402 | 402 | | |
403 | 403 | | |
404 | 404 | | |
405 | | - | |
| 405 | + | |
| 406 | + | |
406 | 407 | | |
407 | | - | |
408 | | - | |
409 | | - | |
410 | | - | |
411 | | - | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
412 | 412 | | |
413 | 413 | | |
414 | 414 | | |
415 | 415 | | |
416 | 416 | | |
417 | 417 | | |
418 | 418 | | |
419 | | - | |
420 | | - | |
421 | | - | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
422 | 423 | | |
423 | | - | |
424 | | - | |
425 | | - | |
426 | | - | |
427 | | - | |
428 | 424 | | |
429 | | - | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
430 | 432 | | |
431 | | - | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
441 | | - | |
442 | | - | |
443 | | - | |
444 | | - | |
445 | | - | |
446 | | - | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
451 | 464 | | |
452 | 465 | | |
453 | 466 | | |
| |||
1258 | 1271 | | |
1259 | 1272 | | |
1260 | 1273 | | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
1261 | 1277 | | |
1262 | 1278 | | |
1263 | 1279 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
798 | 798 | | |
799 | 799 | | |
800 | 800 | | |
801 | | - | |
802 | | - | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
803 | 808 | | |
804 | | - | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
805 | 819 | | |
806 | 820 | | |
807 | 821 | | |
808 | 822 | | |
809 | 823 | | |
810 | 824 | | |
811 | 825 | | |
812 | | - | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
813 | 836 | | |
814 | 837 | | |
815 | 838 | | |
| |||
861 | 884 | | |
862 | 885 | | |
863 | 886 | | |
864 | | - | |
865 | 887 | | |
866 | | - | |
| 888 | + | |
867 | 889 | | |
868 | 890 | | |
869 | 891 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
60 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
61 | 62 | | |
62 | 63 | | |
63 | 64 | | |
64 | | - | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
0 commit comments