Bug 1619617 - [mQ2LO7pl]No warning when set invalid value for podRetention
Summary: [mQ2LO7pl]No warning when set invalid value for podRetention
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Build
Version: 3.11.0
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 3.11.0
Assignee: Adam Kaplan
QA Contact: Wenjing Zheng
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-08-21 10:09 UTC by Wenjing Zheng
Modified: 2018-08-23 14:27 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-08-23 14:27:15 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Wenjing Zheng 2018-08-21 10:09:09 UTC
Description of problem:
No warning if set invalid value for podRetention when create with below settings:
        podTemplate(
          cloud: 'openshift',
          label: label,
          inheritFrom: 'nodejs',
          podRetention: 123,
          containers: [



Version-Release number of selected component (if applicable):
v3.11.0-0.19.0

How reproducible:
always

Steps to Reproduce:
1.Set a pod template with invalid podRetention value
2.Create with it
3.Start a pipeline build

Actual results:
The buildconfig can be created 

Expected results:
There should be a warning to warn podRetention is invalid to be created, not wait until build is failed and found this error in build log.

Additional info:

Comment 1 Wenjing Zheng 2018-08-21 10:11:35 UTC
Build also failed when the value is Never(), will succeed when it is never(). Can they be consistent with jenkins cosole display list?

Comment 2 Adam Kaplan 2018-08-22 19:39:12 UTC
Can you please provide the error from the Jenkins console and/or the build pod?

Comment 3 Wenjing Zheng 2018-08-23 09:45:12 UTC
It warns below in build pod log, it is more convenient when user can be forbidden to create with invalid value for podRetention:
OpenShift Build wzheng1/nodejs-oom-pipeline-onfailure-1
[Pipeline] podTemplate
[Pipeline] // podTemplate
[Pipeline] End of Pipeline
java.lang.ClassCastException: class org.csanchez.jenkins.plugins.kubernetes.pipeline.PodTemplateStep.setPodRetention() expects class org.csanchez.jenkins.plugins.kubernetes.pod.retention.PodRetention but received class java.lang.Integer
	at org.jenkinsci.plugins.structs.describable.DescribableModel.coerce(DescribableModel.java:417)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.injectSetters(DescribableModel.java:361)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:284)
	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:205)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:150)
	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:120)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
Caused: java.lang.IllegalArgumentException: Could not instantiate {cloud=openshift, label=nodejs-oom-onfailure, inheritFrom=nodejs, podRetention=123, containers=[@containerTemplate(name=jnlp,image=docker.io/openshift/jenkins-agent-nodejs-8-centos7:v3.11,resourceRequestMemory=16Mi,resourceLimitMemory=16Mi)]} for PodTemplateStep(label: String, name: String, activeDeadlineSeconds?: int, annotations?: PodAnnotation(key: String, value: String)[], cloud?: String, containers?: ContainerTemplate(name?: String, image?: String, alwaysPullImage?: boolean, args?: String, command?: String, envVars?: TemplateEnvVar{ContainerEnvVar(key: String, value: String) | KeyValueEnvVar(key: String, value: String) | PodEnvVar(key: String, value: String) | SecretEnvVar(key: String, secretName: String, secretKey: String)}[], livenessProbe?: ContainerLivenessProbe(execArgs: String, timeoutSeconds: int, initialDelaySeconds: int, failureThreshold: int, periodSeconds: int, successThreshold: int), ports?: PortMapping(name?: String, containerPort?: int, hostPort?: int)[], privileged?: boolean, resourceLimitCpu?: String, resourceLimitMemory?: String, resourceRequestCpu?: String, resourceRequestMemory?: String, shell?: String, ttyEnabled?: boolean, workingDir?: String)[], envVars?: TemplateEnvVar{ContainerEnvVar(key: String, value: String) | KeyValueEnvVar(key: String, value: String) | PodEnvVar(key: String, value: String) | SecretEnvVar(key: String, secretName: String, secretKey: String)}[], idleMinutes?: int, imagePullSecrets?: String[], inheritFrom?: String, instanceCap?: int, namespace?: String, nodeSelector?: String, nodeUsageMode?: String, podRetention?: PodRetention{Always() | Default() | Never() | OnFailure()}, serviceAccount?: String, slaveConnectTimeout?: int, volumes?: PodVolume{ConfigMapVolume(mountPath: String, configMapName: String) | EmptyDirVolume(mountPath: String, memory: boolean) | HostPathVolume(hostPath: String, mountPath: String) | NfsVolume(serverAddress: String, serverPath: String, readOnly: boolean, mountPath: String) | PersistentVolumeClaim(mountPath: String, claimName: String, readOnly: boolean) | SecretVolume(mountPath: String, secretName: String)}[], workingDir?: String, workspaceVolume?: WorkspaceVolume{EmptyDirWorkspaceVolume(memory: boolean) | HostPathWorkspaceVolume(hostPath: String) | NfsWorkspaceVolume(serverAddress: String, serverPath: String, readOnly: boolean) | PersistentVolumeClaimWorkspaceVolume(claimName: String, readOnly: boolean)}, yaml?: String)
	at org.jenkinsci.plugins.structs.describable.DescribableModel.instantiate(DescribableModel.java:287)
	at org.jenkinsci.plugins.workflow.steps.StepDescriptor.newInstance(StepDescriptor.java:201)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:205)
	at org.jenkinsci.plugins.workflow.cps.DSL.invokeMethod(DSL.java:150)
	at org.jenkinsci.plugins.workflow.cps.CpsScript.invokeMethod(CpsScript.java:108)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)
	at groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1213)
	at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1022)
	at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:42)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:157)
	at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:133)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:120)
	at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:155)
	at org.kohsuke.groovy.sandbox.impl.Checker.checkedCall(Checker.java:159)
	at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.methodCall(SandboxInvoker.java:17)
	at WorkflowScript.run(WorkflowScript:9)
	at ___cps.transform___(Native Method)
	at com.cloudbees.groovy.cps.impl.ContinuationGroup.methodCall(ContinuationGroup.java:57)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:109)
	at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:82)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
	at com.cloudbees.groovy.cps.impl.ClosureBlock.eval(ClosureBlock.java:46)
	at com.cloudbees.groovy.cps.Next.step(Next.java:83)
	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
	at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
	at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:122)
	at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:261)
	at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:19)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:35)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable$1.call(SandboxContinuable.java:32)
	at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.GroovySandbox.runInSandbox(GroovySandbox.java:108)
	at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:32)
	at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:174)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:331)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$100(CpsThreadGroup.java:82)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:243)
	at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:231)
	at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:64)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:131)
	at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28)
	at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:59)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

Comment 4 Adam Kaplan 2018-08-23 14:27:15 UTC
The kubernetes plugin does not validate any fields on the pipeline PodTemplate object.

Reported as improvement upstream: https://issues.jenkins-ci.org/browse/JENKINS-53205


Note You need to log in before you can comment on or make changes to this bug.