Do not revert the pod condition if there might be running containers, skip condition update instead.
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/strategicpatch"
|
||||
clientset "k8s.io/client-go/kubernetes"
|
||||
podutil "k8s.io/kubernetes/pkg/api/v1/pod"
|
||||
)
|
||||
|
||||
// PatchPodStatus patches pod status. It returns true and avoids an update if the patch contains no changes.
|
||||
@@ -68,3 +69,13 @@ func preparePatchBytesForPodStatus(namespace, name string, uid types.UID, oldPod
|
||||
}
|
||||
return patchBytes, bytes.Equal(patchBytes, []byte(fmt.Sprintf(`{"metadata":{"uid":%q}}`, uid))), nil
|
||||
}
|
||||
|
||||
// ReplaceOrAppendPodCondition replaces the first pod condition with equal type or appends if there is none
|
||||
func ReplaceOrAppendPodCondition(conditions []v1.PodCondition, condition *v1.PodCondition) []v1.PodCondition {
|
||||
if i, _ := podutil.GetPodConditionFromList(conditions, condition.Type); i >= 0 {
|
||||
conditions[i] = *condition
|
||||
} else {
|
||||
conditions = append(conditions, *condition)
|
||||
}
|
||||
return conditions
|
||||
}
|
||||
|
Reference in New Issue
Block a user