mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-25 04:33:26 +00:00
Merge pull request #41571 from php-coder/fix_comments
Automatic merge from submit-queue Minor cleanups Minor improvements: - `ValidateNoNewFinalizers`: remove unused const - Mention that mutation of `spec.initContainers[*].image` field is allowed - Improve godoc comments
This commit is contained in:
commit
3559c067c6
@ -2446,8 +2446,8 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
|
|||||||
specPath := field.NewPath("spec")
|
specPath := field.NewPath("spec")
|
||||||
|
|
||||||
// validate updateable fields:
|
// validate updateable fields:
|
||||||
// 1. containers[*].image
|
// 1. spec.containers[*].image
|
||||||
// 2. initContainers[*].image
|
// 2. spec.initContainers[*].image
|
||||||
// 3. spec.activeDeadlineSeconds
|
// 3. spec.activeDeadlineSeconds
|
||||||
|
|
||||||
containerErrs, stop := ValidateContainerUpdates(newPod.Spec.Containers, oldPod.Spec.Containers, specPath.Child("containers"))
|
containerErrs, stop := ValidateContainerUpdates(newPod.Spec.Containers, oldPod.Spec.Containers, specPath.Child("containers"))
|
||||||
@ -2483,14 +2483,14 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
|
|||||||
|
|
||||||
// handle updateable fields by munging those fields prior to deep equal comparison.
|
// handle updateable fields by munging those fields prior to deep equal comparison.
|
||||||
mungedPod := *newPod
|
mungedPod := *newPod
|
||||||
// munge containers[*].image
|
// munge spec.containers[*].image
|
||||||
var newContainers []api.Container
|
var newContainers []api.Container
|
||||||
for ix, container := range mungedPod.Spec.Containers {
|
for ix, container := range mungedPod.Spec.Containers {
|
||||||
container.Image = oldPod.Spec.Containers[ix].Image
|
container.Image = oldPod.Spec.Containers[ix].Image
|
||||||
newContainers = append(newContainers, container)
|
newContainers = append(newContainers, container)
|
||||||
}
|
}
|
||||||
mungedPod.Spec.Containers = newContainers
|
mungedPod.Spec.Containers = newContainers
|
||||||
// munge initContainers[*].image
|
// munge spec.initContainers[*].image
|
||||||
var newInitContainers []api.Container
|
var newInitContainers []api.Container
|
||||||
for ix, container := range mungedPod.Spec.InitContainers {
|
for ix, container := range mungedPod.Spec.InitContainers {
|
||||||
container.Image = oldPod.Spec.InitContainers[ix].Image
|
container.Image = oldPod.Spec.InitContainers[ix].Image
|
||||||
@ -2510,7 +2510,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
|
|||||||
|
|
||||||
if !apiequality.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) {
|
if !apiequality.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) {
|
||||||
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
|
//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
|
||||||
allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)"))
|
allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)"))
|
||||||
}
|
}
|
||||||
|
|
||||||
return allErrs
|
return allErrs
|
||||||
|
@ -46,14 +46,6 @@ const (
|
|||||||
idErrMsg = "a valid C identifier must"
|
idErrMsg = "a valid C identifier must"
|
||||||
)
|
)
|
||||||
|
|
||||||
func expectPrefix(t *testing.T, prefix string, errs field.ErrorList) {
|
|
||||||
for i := range errs {
|
|
||||||
if f, p := errs[i].Field, prefix; !strings.HasPrefix(f, p) {
|
|
||||||
t.Errorf("expected prefix '%s' for field '%s' (%v)", p, f, errs[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testVolume(name string, namespace string, spec api.PersistentVolumeSpec) *api.PersistentVolume {
|
func testVolume(name string, namespace string, spec api.PersistentVolumeSpec) *api.PersistentVolume {
|
||||||
objMeta := metav1.ObjectMeta{Name: name}
|
objMeta := metav1.ObjectMeta{Name: name}
|
||||||
if namespace != "" {
|
if namespace != "" {
|
||||||
|
@ -21,7 +21,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api"
|
"k8s.io/kubernetes/pkg/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
// mustRunAs implements the GroupStrategy interface
|
// runAsAny implements the GroupStrategy interface.
|
||||||
type runAsAny struct {
|
type runAsAny struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import (
|
|||||||
"k8s.io/kubernetes/pkg/api/helper"
|
"k8s.io/kubernetes/pkg/api/helper"
|
||||||
)
|
)
|
||||||
|
|
||||||
// mustMatchPatterns implements the CapabilitiesStrategy interface
|
// mustMatchPatterns implements the SysctlsStrategy interface
|
||||||
type mustMatchPatterns struct {
|
type mustMatchPatterns struct {
|
||||||
patterns []string
|
patterns []string
|
||||||
}
|
}
|
||||||
|
@ -129,7 +129,7 @@ func GetVolumeFSType(v api.Volume) (extensions.FSType, error) {
|
|||||||
return "", fmt.Errorf("unknown volume type for volume: %#v", v)
|
return "", fmt.Errorf("unknown volume type for volume: %#v", v)
|
||||||
}
|
}
|
||||||
|
|
||||||
// fsTypeToStringSet converts an FSType slice to a string set.
|
// FSTypeToStringSet converts an FSType slice to a string set.
|
||||||
func FSTypeToStringSet(fsTypes []extensions.FSType) sets.String {
|
func FSTypeToStringSet(fsTypes []extensions.FSType) sets.String {
|
||||||
set := sets.NewString()
|
set := sets.NewString()
|
||||||
for _, v := range fsTypes {
|
for _, v := range fsTypes {
|
||||||
|
@ -112,7 +112,6 @@ func ValidateFinalizerName(stringValue string, fldPath *field.Path) field.ErrorL
|
|||||||
}
|
}
|
||||||
|
|
||||||
func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fldPath *field.Path) field.ErrorList {
|
func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fldPath *field.Path) field.ErrorList {
|
||||||
const newFinalizersErrorMsg string = `no new finalizers can be added if the object is being deleted`
|
|
||||||
allErrs := field.ErrorList{}
|
allErrs := field.ErrorList{}
|
||||||
extra := sets.NewString(newFinalizers...).Difference(sets.NewString(oldFinalizers...))
|
extra := sets.NewString(newFinalizers...).Difference(sets.NewString(oldFinalizers...))
|
||||||
if len(extra) != 0 {
|
if len(extra) != 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user