Commit c4b0b4a
committed
lib/resourcemerge: change SecurityContext reconcile
to handle securityContext changes differently. Since d9f6718, if a
securityContext is not explicitly specified in the manifest the
resource's securityContext will remain unchanged and it will
continue to use the securityContext setting of the currently running
resource (if there is one). We're not sure of the exact reason the
logic was originally developed in this manner but this change joins
a series of similar previous tightenings, including
openshift@02bb9ba
(lib/resourcemerge/core: Clear env and envFrom if unset in
manifest, 2021-04-20, openshift#549) and
openshift@ca299b8
(lib/resourcemerge: remove ports which are no longer required,
2020-02-13, openshift#322).
Reconciliation has been changed such that the entire securityContext
structure, or any sub field of it, will be cleared if not specified
in the manifest. This change affects Deployments, Jobs, and
DaemonSets. It affects the securityContext found in both a PodSpec
and a Container. Since the functions setInt64Ptr and setBoolPtr
have been changed the impact is wide affecting ServiceAccounts, the
PodSpec fields ShareProcessNamespace and
TerminationGracePeriodSeconds, and the Job fields
ActiveDeadlineSeconds and ManualSelector.
For example, prior to this change assume Deployment machine-api-operator
is running on the cluster with the following:
securityContext:
runAsNonRoot: true
runAsUser: 65534
and during an upgrade the Deployment machine-api-operator no longer
specifies a securityContext. The resulting upgraded Deployment
machine-api-operator will still have the original securityContext:
securityContext:
runAsNonRoot: true
runAsUser: 65534
Similarly, there is no way to remove, or clear, a securityContext
field such as runAsUser. You can only modify it.
After this change the above scenario will correctly result in the
Deployment machine-api-operator not specifying securityContext
upon upgrade completion.
The changes apply to both the SecurityContext within a Container
and the PodSecurityContext within a PodSpec.1 parent e0c9203 commit c4b0b4a
3 files changed
+91
-27
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| |||
466 | 466 | | |
467 | 467 | | |
468 | 468 | | |
469 | | - | |
470 | | - | |
| 469 | + | |
471 | 470 | | |
472 | 471 | | |
473 | | - | |
474 | | - | |
| 472 | + | |
475 | 473 | | |
476 | 474 | | |
477 | 475 | | |
| |||
490 | 488 | | |
491 | 489 | | |
492 | 490 | | |
493 | | - | |
494 | | - | |
| 491 | + | |
495 | 492 | | |
496 | 493 | | |
497 | | - | |
498 | | - | |
| 494 | + | |
499 | 495 | | |
500 | 496 | | |
501 | 497 | | |
| |||
619 | 615 | | |
620 | 616 | | |
621 | 617 | | |
622 | | - | |
623 | | - | |
| 618 | + | |
624 | 619 | | |
625 | 620 | | |
626 | | - | |
627 | | - | |
| 621 | + | |
628 | 622 | | |
629 | 623 | | |
630 | 624 | | |
| |||
676 | 670 | | |
677 | 671 | | |
678 | 672 | | |
679 | | - | |
680 | | - | |
| 673 | + | |
681 | 674 | | |
682 | 675 | | |
683 | | - | |
684 | | - | |
| 676 | + | |
685 | 677 | | |
686 | 678 | | |
687 | 679 | | |
| |||
734 | 726 | | |
735 | 727 | | |
736 | 728 | | |
737 | | - | |
738 | | - | |
| 729 | + | |
739 | 730 | | |
740 | 731 | | |
741 | | - | |
742 | | - | |
| 732 | + | |
743 | 733 | | |
744 | 734 | | |
745 | 735 | | |
| |||
774 | 764 | | |
775 | 765 | | |
776 | 766 | | |
777 | | - | |
778 | | - | |
| 767 | + | |
779 | 768 | | |
780 | 769 | | |
781 | | - | |
782 | | - | |
| 770 | + | |
783 | 771 | | |
784 | 772 | | |
785 | 773 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
| 38 | + | |
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| |||
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 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 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
47 | 113 | | |
48 | 114 | | |
49 | 115 | | |
| |||
1559 | 1625 | | |
1560 | 1626 | | |
1561 | 1627 | | |
| 1628 | + | |
| 1629 | + | |
| 1630 | + | |
| 1631 | + | |
| 1632 | + | |
| 1633 | + | |
| 1634 | + | |
| 1635 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| 17 | + | |
| 18 | + | |
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
| |||
0 commit comments