Bug 1324396

Summary: [infrastructure_public_301]Tip info is error when update pod activeDeadlineSeconds with negative value
Product: OpenShift Container Platform Reporter: DeShuai Ma <dma>
Component: NodeAssignee: Jan Chaloupka <jchaloup>
Status: CLOSED NOTABUG QA Contact: Xiaoli Tian <xtian>
Severity: low Docs Contact:
Priority: medium    
Version: 3.2.0CC: aos-bugs, gblomqui, jokerman, mmccomas
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-07-03 15:19:07 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description DeShuai Ma 2016-04-06 08:58:30 UTC
Description of problem:
When update pod activeDeadlineSeconds with negative value, there is two different tip info.

Version-Release number of selected component (if applicable):
openshift v3.2.0.11
kubernetes v1.2.0-36-g4a3f9c5
etcd 2.2.5

How reproducible:
Always

Steps to Reproduce:
1. Create a pod with activeDeadlineSeconds
[root@dhcp-128-7 dma]# oc get pod
NAME              READY     STATUS    RESTARTS   AGE
hello-openshift   1/1       Running   0          31s

2. Update pod's activeDeadlineSeconds with negative value
[root@dhcp-128-7 dma]# oc patch pod/hello-openshift -p '{"spec":{"activeDeadlineSeconds":-5}}'

Actual results:
2.[root@dhcp-128-7 dma]# oc patch pod/hello-openshift -p '{"spec":{"activeDeadlineSeconds":-5}}'
The Pod "hello-openshift" is invalid.

* spec.activeDeadlineSeconds: Invalid value: -5: must be greater than 0
* spec.activeDeadlineSeconds: Invalid value: -5: must be greater than or equal to 0

Expected results:
2.2.[root@dhcp-128-7 dma]# oc patch pod/hello-openshift -p '{"spec":{"activeDeadlineSeconds":-5}}'
The Pod "hello-openshift" is invalid.

* spec.activeDeadlineSeconds: Invalid value: -5: must be greater than 0

Additional info:

Comment 1 Jan Chaloupka 2016-04-08 10:45:19 UTC
From the kubernetes source codes at pkg/api/validation/validation.go inside ValidatePodUpdate:

// validate updated spec.activeDeadlineSeconds.  two types of updates are allowed:
// 1.  from nil to a positive value
// 2.  from a positive value to a lesser, non-negative value

So the expected value is:

 * spec.activeDeadlineSeconds: Invalid value: -5: must be greater than or equal to 0

Looking for the place where

* spec.activeDeadlineSeconds: Invalid value: -5: must be greater than 0

is generated.

Comment 2 Jan Chaloupka 2016-04-08 11:05:13 UTC
The second one is in the same file inside ValidatePodSpec function. Surely, there is an inconsistency.

Comment 3 Jan Chaloupka 2016-04-08 11:19:16 UTC
Find the common control point:

In pkg/registry/pod/strategy.go file, there is ValidateUpdate method that is call for pod updates (actually the only method that calls ValidateUpdate). It looks like this:

func (podStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) field.ErrorList {
        errorList := validation.ValidatePod(obj.(*api.Pod))
        return append(errorList, validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod))...)
}

1. validation.ValidatePod and validation.ValidatePodUpdate are called inside
2. validation.ValidatePod calls validation.ValidatePodSpec method.

So both ValidatePodUpdate and ValidatePodSpec are called. About to create upstream PR.

Comment 4 Jan Chaloupka 2016-04-08 11:53:43 UTC
Based on the v1.podSpec documentation [1], ActiveDeadlineSeconds must be a positive integer. So the expected error message is indeed:

* spec.activeDeadlineSeconds: Invalid value: -5: must be greater than 0

Upstream PR here [2].

[1] http://kubernetes.io/docs/api-reference/v1/definitions/#_v1_podspec
[2] https://github.com/kubernetes/kubernetes/pull/24042

Comment 5 Jan Chaloupka 2016-04-08 12:28:59 UTC
Zero value of activeDeadlineSeconds is intended at this point so both error messages makes sense. The first error message is reported when the pod is created. The second message is reported when the pod is updated. As coincidence when pod is updated the same validation as for pod creation is run.

Comment 7 Greg Blomquist 2019-07-03 15:19:07 UTC
Closing based on comment #5 and no activity in 3 years.