Bug 1835004

Summary: keepYoungerThan is expecting one integer instead of one String
Product: OpenShift Container Platform Reporter: Odilon Sousa <osousa>
Component: Image RegistryAssignee: Oleg Bulatov <obulatov>
Status: CLOSED ERRATA QA Contact: Wenjing Zheng <wzheng>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 4.4CC: aos-bugs, apjagtap, cblecker, dahernan, palonsor, rh-container, skrenger
Target Milestone: ---   
Target Release: 4.5.0   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Cause: keepYoungerThan is expected to be an integer. It is an integer that defines a minimal image age in nanoseconds. Consequence: It's inconvenient to use nanoseconds to tune the pruner. Fix: Deprecate keepYoungerThan and introduce a new field named keepYoungerThanDuration. Result: keepYoungerThanDuration can be set to "60m" and similar values.
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-07-13 17:37:59 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 Odilon Sousa 2020-05-12 21:26:08 UTC
Description of problem: 

While trying to set keepYoungerThan, the client returns spec.keepYoungerThan in body must be of type integer: "string"

Version-Release number of selected component (if applicable):

Openshift Container Platform 4.4

How reproducible:

$ cat <<EOF >>image-pruner.yaml
apiVersion: imageregistry.operator.openshift.io/v1
kind: ImagePruner
metadata:
  name: imageprunertest
spec:
  schedule: "*/0 * * * *"
  suspend: false
  keepTagRevisions: 3
  keepYoungerThan: 60m
  startingDeadlineSeconds: 60
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 3
EOF

$ oc create -f image-pruner.yaml


Actual results:

The ImagePruner "imageprunertest" is invalid: spec.keepYoungerThan: Invalid value: "string": spec.keepYoungerThan in body must be of type integer: "string"

Expected results:

The object to be created without problem

Additional info:

Comment 5 Wenjing Zheng 2020-05-28 02:49:37 UTC
Below error still return when define like "keepYoungerThan: 60m" with 4.5.0-0.nightly-2020-05-27-174108:
# imagepruners.imageregistry.operator.openshift.io "cluster" was not valid:
# * spec.keepYoungerThan: Invalid value: "string": spec.keepYoungerThan in body must be of type integer: "string"

Below setting can be saved:
spec:
  failedJobsHistoryLimit: 3
  keepTagRevisions: 3
  keepYoungerThan: 60
  schedule: ""
  successfulJobsHistoryLimit: 3
  suspend: false

Comment 6 Wenjing Zheng 2020-05-28 02:55:15 UTC
This config change works:
spec:
  failedJobsHistoryLimit: 3
  keepTagRevisions: 3
  keepYoungerThan: 60
  keepYoungerThanDuration: 60m

I will report a doc bug to deprecate "keepYoungerThan".

Comment 7 Wenjing Zheng 2020-05-28 02:59:23 UTC
If keepYoungerThan is deprecated, can we pop up a warning let user know to use keepYoungerThanDuration when user wants to config keepYoungerThan?

Comment 8 Oleg Bulatov 2020-05-28 10:06:47 UTC
Unfortunately we cannot change the type of keepYoungerThan from an integer to string.

We should replace keepYoungerThan with keepYoungerThanDuration in docs. It's better to almost completely remove keepYoungerThan from documentation, we can just mention that this field exists and shouldn't be used.

Comment 9 Wenjing Zheng 2020-05-28 10:13:33 UTC
(In reply to Oleg Bulatov from comment #8)
> Unfortunately we cannot change the type of keepYoungerThan from an integer
> to string.
> 
> We should replace keepYoungerThan with keepYoungerThanDuration in docs. It's
> better to almost completely remove keepYoungerThan from documentation, we
> can just mention that this field exists and shouldn't be used.

OK, get it, thanks! I will add your suggestion to the doc bug: https://bugzilla.redhat.com/show_bug.cgi?id=1840973 . Feel free to change this bug back to ON_QA.

Comment 10 Wenjing Zheng 2020-05-29 08:04:35 UTC
Verified on 4.5.0-0.nightly-2020-05-29-005153.

Comment 11 errata-xmlrpc 2020-07-13 17:37:59 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2020:2409