Bug 1957521

Summary: CDI Operator not interpreting custom cert params correctly
Product: Container Native Virtualization (CNV) Reporter: Michael Henriksen <mhenriks>
Component: StorageAssignee: Michael Henriksen <mhenriks>
Status: CLOSED ERRATA QA Contact: Yan Du <yadu>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.8.0CC: awels, cnv-qe-bugs, mrashish, yadu
Target Milestone: ---   
Target Release: 4.8.0   
Hardware: All   
OS: Unspecified   
Whiteboard:
Fixed In Version: virt-cdi-operator v4.8.0-18 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-07-27 14:31:30 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:
Embargoed:

Description Michael Henriksen 2021-05-05 23:33:08 UTC
Description of problem:

We stole the idea of Duration and RenewBefore from cert-manager. See here for interpretation: https://github.com/kubevirt/containerized-data-importer/blob/main/pkg/apis/core/v1beta1/types.go#L388-L393

We were not handling RenewBefore correctly. It is supposed to be time before a cert's "not after." But we were treating it is time from "not before".

Conversion is easy and will be done automatically on all certs after upgrade.


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


How reproducible:

100%


Steps to Reproduce:
1.  Set explicit params for certs like this:

k edit cdi cdi

and add:

spec:
  certConfig:
    ca:
      duration: 10h
      renewBefore: 2h
    server:
      duration: 5h
      renewBefore: 1h


2.


Actual results:

    Check following secrets/annotations:

cdi-apiserver-signer -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"2h0m0s"}'"

cdi-uploadproxy-signer -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"2h0m0s"}'"

cdi-apiserver-server-cert -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"1h0m0s"}'"

cdi-uploadproxy-server-cert -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"5h0m0s","refresh":"1h0m0s"}'"


Expected results:

    Check following secrets/annotations:

cdi-apiserver-signer -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"8h0m0s"}'"

cdi-uploadproxy-signer -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"8h0m0s"}'"

cdi-apiserver-server-cert -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"4h0m0s"}'"

cdi-uploadproxy-server-cert -> "operator.cdi.kubevirt.io/certConfig: '{"lifetime":"5h0m0s","refresh":"4h0m0s"}'"


Additional info:

Notice the different refresh values

Comment 1 Yan Du 2021-06-02 11:51:25 UTC
Test on OCP4.8 with virt-cdi-operator-container-v4.8.0-19, issue have been fixed.

After setting params for certs in hco:

cdi-apiserver-signer -> operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"8h0m0s"}'

cdi-uploadproxy-signer -> operator.cdi.kubevirt.io/certConfig: '{"lifetime":"10h0m0s","refresh":"8h0m0s"}'

cdi-apiserver-server-cert -> operator.cdi.kubevirt.io/certConfig: '{"lifetime":"5h0m0s","refresh":"4h0m0s"}'

cdi-uploadproxy-server-cert -> operator.cdi.kubevirt.io/certConfig: '{"lifetime":"5h0m0s","refresh":"4h0m0s"}'

Comment 4 errata-xmlrpc 2021-07-27 14:31:30 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 (Moderate: OpenShift Virtualization 4.8.0 Images), 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/RHSA-2021:2920