Bug 2102324 - GCP: Panic when unknown region AND machinesets specified in install config
Summary: GCP: Panic when unknown region AND machinesets specified in install config
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Installer
Version: 4.10-rc3
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 4.12.0
Assignee: Aditya Narayanaswamy
QA Contact: Jianli Wei
Mike Pytlak
URL:
Whiteboard:
Depends On:
Blocks: 2112913 2112928
TreeView+ depends on / blocked
 
Reported: 2022-06-29 16:48 UTC by Patrick Dillon
Modified: 2023-01-17 19:51 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
* Previously, when an installation on Google Cloud provider (GCP) failed because an invalid GCP region was specified, the resulting error message did not mention this as the cause of the failure. This update improves the error message, which now states the region is not valid. (link:https://bugzilla.redhat.com/show_bug.cgi?id=2102324[*BZ#2102324*])
Clone Of:
Environment:
Last Closed: 2023-01-17 19:50:54 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift installer pull 6065 0 None open Bug 2102324: Fix panic when unknown region is provided. 2022-06-30 16:43:43 UTC
Github openshift installer pull 6127 0 None open Bug 2102324: Fix validation errors for instance type 2022-07-15 13:07:22 UTC
Red Hat Product Errata RHSA-2022:7399 0 None None None 2023-01-17 19:51:16 UTC

Description Patrick Dillon 2022-06-29 16:48:34 UTC
Version: master

Platform: gcp

Create an install config with an invalid region (in this case, europe-west-8) AND add machine pools, installer will panic:

```
# cat c/install-config.yaml 
apiVersion: v1
baseDomain: installer.gcp.devcluster.openshift.com
compute:
- architecture: amd64
  hyperthreading: Enabled
  name: worker
  platform:
    gcp:
      osDisk:
        DiskSizeGB: 0
        diskType: ""
      type: e2-standard-4
  replicas: 3
controlPlane:
  architecture: amd64
  hyperthreading: Enabled
  name: master
  platform:
    gcp:
      osDisk:
        DiskSizeGB: 0
        diskType: ""
      type: e2-standard-4
  replicas: 3
metadata:
  creationTimestamp: null
  name: padillon06291216
networking:
  clusterNetwork:
  - cidr: 10.128.0.0/14
    hostPrefix: 23
  machineNetwork:
  - cidr: 10.0.0.0/16
  networkType: OpenShiftSDN
  serviceNetwork:
  - 172.30.0.0/16
platform:
  gcp:
    projectID: openshift-dev-installer
    region: europe-west-8
```

# ./openshift-install create install-config --dir c
INFO Credentials loaded from file "/root/.gcp/osServiceAccount.json" 
panic: runtime error: index out of range [0] with length 0

goroutine 1 [running]:
github.com/openshift/installer/pkg/asset/installconfig/gcp.validateInstanceTypes({0x19d6f8f0, 0xc00011b2e8}, 0xc000805680)
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/installconfig/gcp/validation.go:93 +0x8f5
github.com/openshift/installer/pkg/asset/installconfig/gcp.Validate({0x19d6f8f0, 0xc00011b2e8}, 0xc000805680)
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/installconfig/gcp/validation.go:47 +0x505
github.com/openshift/installer/pkg/asset/installconfig.(*InstallConfig).platformValidation(0xc000a36240)
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/installconfig/installconfig.go:215 +0x1d1
github.com/openshift/installer/pkg/asset/installconfig.(*InstallConfig).finish(0xc000a36240, {0x4b4f074, 0x13})
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/installconfig/installconfig.go:180 +0x574
github.com/openshift/installer/pkg/asset/installconfig.(*InstallConfig).Load(0xc000a36240, {0x19c8c4b8, 0xc000a7b600})
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/installconfig/installconfig.go:147 +0x188
github.com/openshift/installer/pkg/asset/store.(*storeImpl).load(0xc00063dc50, {0x19c93650, 0x1d37eb20}, {0x0, 0x0})
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/store/store.go:264 +0x2b2
github.com/openshift/installer/pkg/asset/store.(*storeImpl).fetch(0xc00063dc50, {0x19c93650, 0x1d37eb20}, {0x0, 0x0})
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/store/store.go:201 +0x1b1
github.com/openshift/installer/pkg/asset/store.(*storeImpl).Fetch(0x7fffedbb883f, {0x19c93650, 0x1d37eb20}, {0x1d343c90, 0x1, 0x1})
	/home/padillon/go/src/github.com/openshift/installer/pkg/asset/store/store.go:77 +0x48
main.runTargetCmd.func1({0x7fffedbb883f, 0x1})
	/home/padillon/go/src/github.com/openshift/installer/cmd/openshift-install/create.go:250 +0x116
main.runTargetCmd.func2(0x1d35ac80, {0xc000435f60, 0x2, 0x2})
	/home/padillon/go/src/github.com/openshift/installer/cmd/openshift-install/create.go:279 +0xe7
github.com/spf13/cobra.(*Command).execute(0x1d35ac80, {0xc000435f20, 0x2, 0x2})
	/home/padillon/go/src/github.com/openshift/installer/vendor/github.com/spf13/cobra/command.go:860 +0x5f8
github.com/spf13/cobra.(*Command).ExecuteC(0xc000534280)
	/home/padillon/go/src/github.com/openshift/installer/vendor/github.com/spf13/cobra/command.go:974 +0x3bc
github.com/spf13/cobra.(*Command).Execute(...)
	/home/padillon/go/src/github.com/openshift/installer/vendor/github.com/spf13/cobra/command.go:902
main.installerMain()
	/home/padillon/go/src/github.com/openshift/installer/cmd/openshift-install/main.go:60 +0x29e
main.main()
	/home/padillon/go/src/github.com/openshift/installer/cmd/openshift-install/main.go:38 +0xff

Installer should handle this error gracefully.

Comment 4 Jianli Wei 2022-07-18 05:23:12 UTC
Verified with a build having the PR (https://prow.ci.openshift.org/view/gs/origin-ci-test/logs/release-openshift-origin-installer-launch-gcp-modern/1548879863383855104), reasonable error message shows up now.  

$ openshift-install version
openshift-install 4.11.0-0.ci.test-2022-07-18-045521-ci-ln-4f0hn9t-latest
built from commit 2160b2cf50caa34773c1563e25a58774f1cba744
release image registry.build05.ci.openshift.org/ci-ln-4f0hn9t/release@sha256:cd4ab92709a2b74b741bac3a4307b416ff4e5fc9a8eefcbd589ec5060942d069
release architecture amd64
$ yq-3.3.0 r test2/install-config.yaml compute
- architecture: amd64
  hyperthreading: Enabled
  name: worker
  platform:
    gcp:
      osDisk:
        DiskSizeGB: 0
        diskType: ""
      type: e2-standard-4
  replicas: 3
$ yq-3.3.0 r test2/install-config.yaml controlPlane
architecture: amd64
hyperthreading: Enabled
name: master
platform:
  gcp:
    osDisk:
      DiskSizeGB: 0
      diskType: ""
    type: e2-standard-4
replicas: 3
$ yq-3.3.0 r test2/install-config.yaml platform
gcp:
  projectID: openshift-qe
  region: europe-west-8
$ 
$ openshift-install create install-config --dir test2
INFO Credentials loaded from file "/home/fedora/.gcp/osServiceAccount.json" 
ERROR failed to fetch Install Config: failed to load asset "Install Config": failed to create install config: [platform.gcp.region: Invalid value: "europe-west-8": invalid region, <nil>: Internal error: failed to fetch instance types, this error usually occurs if the region is not found] 
$

Comment 6 Jianli Wei 2022-07-25 05:48:45 UTC
Verified with 4.12.0-0.nightly-2022-07-25-010250.
 
$ openshift-install version
openshift-install 4.12.0-0.nightly-2022-07-25-010250
built from commit 4ecf43ce0ee68edda209739165d0973f9d66c2c4
release image registry.ci.openshift.org/ocp/release@sha256:2b5339e882f16a8411a5b137b916099083d4bb13bd6ab7a61b8d99eb89910952
release architecture amd64
$ 
$ yq-3.3.0 r test1/install-config.yaml compute
- architecture: amd64
  hyperthreading: Enabled
  name: worker
  platform:
    gcp:
      osDisk:
        DiskSizeGB: 0
        diskType: ""
      type: e2-standard-4
  replicas: 3
$ yq-3.3.0 r test1/install-config.yaml controlPlane
architecture: amd64
hyperthreading: Enabled
name: master
platform:
  gcp:
    osDisk:
      DiskSizeGB: 0
      diskType: ""
    type: e2-standard-4
replicas: 3
$ yq-3.3.0 r test1/install-config.yaml platform
gcp:
  projectID: openshift-qe
  region: europe-west-8
$ openshift-install create install-config --dir test1
INFO Credentials loaded from file "/home/fedora/.gcp/osServiceAccount.json" 
ERROR failed to fetch Install Config: failed to load asset "Install Config": failed to create install config: [platform.gcp.region: Invalid value: "europe-west-8": invalid region, <nil>: Internal error: failed to fetch instance types, this error usually occurs if the region is not found] 
$

Comment 9 errata-xmlrpc 2023-01-17 19:50:54 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 Container Platform 4.12.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:7399


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