Bug 2078781

Summary: PreflightValidation does not handle multiarch images
Product: OpenShift Container Platform Reporter: Constantin Vultur <cvultur>
Component: Special Resource OperatorAssignee: yevgeny shnaidman <yshnaidm>
Status: CLOSED ERRATA QA Contact: Constantin Vultur <cvultur>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: 4.11   
Target Milestone: ---   
Target Release: 4.11.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-08-10 11:08:24 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 Constantin Vultur 2022-04-26 07:59:49 UTC
Description of problem:
Using an multiarch image in preflightvalidation panics the operator

Version-Release number of selected component (if applicable):
current master/release-4.11 on Apr 25th

How reproducible:


Steps to Reproduce:
1. Create a Preflightvalidation using a multiarch updateImage
2.
3.

Actual results:
There are no events in the preflightvalidation:
# oc describe preflightvalidation
Name:         preflight
Namespace:    
Labels:       <none>
Annotations:  <none>
API Version:  sro.openshift.io/v1beta1
Kind:         PreflightValidation
Metadata:
  Creation Timestamp:  2022-04-26T07:44:29Z
  Generation:          1
  Managed Fields:
    API Version:  sro.openshift.io/v1beta1
    Fields Type:  FieldsV1
    fieldsV1:
      f:spec:
        .:
        f:updateImage:
    Manager:         kubectl-create
    Operation:       Update
    Time:            2022-04-26T07:44:29Z
  Resource Version:  473342
  UID:               1d5040da-7d35-4d59-add6-9af4acf1b45d
Spec:
  Update Image:  quay.io/openshift-release-dev/ocp-release@sha256:f7f252c39b64601c8ac3de737a584ba4f6016b1f4b17801d726ca2fd15492878
Events:          <none>

The Operator panics out. Logs shows:
panic: runtime error: index out of range [-1]

goroutine 909 [running]:
github.com/openshift/special-resource-operator/pkg/registry.(*registry).LastLayer(0x2dc5d08, {0x2dc5d08, 0xc001eea660}, {0xc0007e2100, 0x0})
	/workspace/pkg/registry/registry.go:108 +0xb7
github.com/openshift/special-resource-operator/pkg/preflight.(*preflight).getOSData(0xc000636bd0, {0x2dc5d08, 0xc001eea660}, {0xc0007e2100, 0x71})
	/workspace/pkg/preflight/preflight.go:281 +0x9d
github.com/openshift/special-resource-operator/pkg/preflight.(*preflight).PrepareRuntimeInfo(0xc000636bd0, {0x2dc5d08, 0xc001eea660}, {0xc0007e2100, 0x71})
	/workspace/pkg/preflight/preflight.go:247 +0xb0
github.com/openshift/special-resource-operator/controllers.(*PreflightValidationReconciler).runPreflightValidation(0xc0003ed200, {0x2dc5d08, 0xc001eea660}, 0xc001efe160)
	/workspace/controllers/preflightvalidation_controller.go:105 +0xe3
github.com/openshift/special-resource-operator/controllers.(*PreflightValidationReconciler).Reconcile(0xc0003ed200, {0x2dc5d08, 0xc001eea660}, {{{0x0, 0x2927020}, {0xc0009e0b50, 0xc00099c280}}})
	/workspace/controllers/preflightvalidation_controller.go:85 +0x147
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Reconcile(0xc0005a70e0, {0x2dc5d08, 0xc001eea5d0}, {{{0x0, 0x2927020}, {0xc0009e0b50, 0xc0008ae2c0}}})
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:114 +0x222
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).reconcileHandler(0xc0005a70e0, {0x2dc5c60, 0xc00086a3c0}, {0x2872ea0, 0xc000928ae0})
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:311 +0x2f2
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).processNextWorkItem(0xc0005a70e0, {0x2dc5c60, 0xc00086a3c0})
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:266 +0x205
sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2.2()
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:227 +0x85
created by sigs.k8s.io/controller-runtime/pkg/internal/controller.(*Controller).Start.func2
	/workspace/vendor/sigs.k8s.io/controller-runtime/pkg/internal/controller/controller.go:223 +0x354


Expected results:
preflight validation to work successfully


Additional info:

Comment 2 Constantin Vultur 2022-05-02 17:14:33 UTC
Ran new bundle from release-4.11 branch after the PR was pushed in. 

For a PreflightValidation spec with image:

Spec:
  Update Image:  quay.io/openshift-release-dev/ocp-release@sha256:f7f252c39b64601c8ac3de737a584ba4f6016b1f4b17801d726ca2fd15492878
Status:
  Sr Statuses:
    Last Transition Time:  2022-05-02T17:09:26Z
    Name:                  simple-kmod
    Status Reason:         Failed to load helm chart for CR simple-kmod
    Verification Status:   Error
    Last Transition Time:  2022-05-02T17:09:26Z
    Name:                  simple-kmod-second
    Status Reason:        EDITED_QE
    Verification Status:   False
Events:                    <none>


Image used is an multi-arch:

# oc image info quay.io/openshift-release-dev/ocp-release@sha256:f7f252c39b64601c8ac3de737a584ba4f6016b1f4b17801d726ca2fd15492878
W0502 13:10:11.897784  735032 helpers.go:151] Defaulting of registry auth file to "${HOME}/.docker/config.json" is deprecated. The default will be switched to podman config locations in the future version.
error: the image is a manifest list and contains multiple images - use --filter-by-os to select from:

  OS            DIGEST
  linux/amd64   sha256:7b2bd43e0e1e9d595a20095da46efff3945734e09e8adb4d8369bd2f6beda6c0
  linux/ppc64le sha256:bf2d99b2f5772b1536f2f89d3f8f99fe28292d2ba03e63a08606e4588e431f13
  linux/s390x   sha256:a39530fa32d50df1a1ff504ac71e2aa6b11dd23a21a3ba0ea9dfc5a4f93ca181
  linux/arm64   sha256:037f132552d23505e7a5838b13d322c4b777dc638dffc6898671dbfcc6498786

Comment 5 errata-xmlrpc 2022-08-10 11:08:24 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 (Important: OpenShift Container Platform 4.11.0 bug fix and security update), 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-2022:5069