Bug 2116686 - [capi] Cluster kind should be valid
Summary: [capi] Cluster kind should be valid
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Cloud Compute
Version: 4.12
Hardware: Unspecified
OS: Unspecified
low
low
Target Milestone: ---
: 4.13.0
Assignee: Alberto
QA Contact: sunzhaohua
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-08-09 07:39 UTC by sunzhaohua
Modified: 2023-05-17 22:47 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2023-05-17 22:46:56 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift cluster-capi-operator pull 76 0 None open Bug 2116686: Initial implementation of validation webhooks 2022-09-21 15:06:07 UTC
Github openshift cluster-capi-operator pull 85 0 None open Bug 2116686: OCPBUGS-1493: Add provider webhook 2022-11-21 15:00:41 UTC
Red Hat Product Errata RHSA-2023:1326 0 None None None 2023-05-17 22:47:05 UTC

Description sunzhaohua 2022-08-09 07:39:37 UTC
Description of problem:
Cluster kind should be valid

Version-Release number of selected component (if applicable):
4.12.0-0.nightly-2022-08-08-143443

How reproducible:
Always

Steps to Reproduce:
1. Enable capi by featuregate
2. Create a cluster resource with invalid or empty kind
apiVersion: cluster.x-k8s.io/v1beta1
kind: Cluster
metadata:
  name: zhsunupi-h8wbm
  namespace: openshift-cluster-api
spec:
  infrastructureRef:
    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: "invalid"
    name: zhsunupi-h8wbm
    namespace: openshift-cluster-api
3. Check the created cluster
4. Delete cluster
$ oc delete cluster zhsunupi-h8wbm      
cluster.cluster.x-k8s.io "zhsunupi-h8wbm" deleted
^C

Actual results:
Cluster was created successful, and couldn't be deleted.
$ oc get cluster  
NAME             PHASE      AGE     VERSION
zhsunupi-h8wbm   Deleting   5m12s

spec:
  infrastructureRef:
    apiVersion: infrastructure.cluster.x-k8s.io/v1beta1
    kind: ""
    name: zhsunaws3-mptzl
    namespace: openshift-cluster-api
status:
  conditions:
  - lastTransitionTime: "2022-08-09T06:24:43Z"
    status: "True"
    type: ControlPlaneInitialized
  observedGeneration: 1
  phase: Deleting

Expected results:
Cluster couldn't be created if kind is invalid or empty.

Additional info:

Comment 1 Joel Speed 2022-08-15 13:30:02 UTC
As far as I'm aware we don't actually use these fields, but it would be good to validate them and make sure they are correct, for example, it should be an AWSCluster on AWS.

Comment 2 Michael McCune 2022-08-29 15:21:56 UTC
i have not had a chance to investigate this yet, hoping to get some time during this sprint.

Comment 3 Michael McCune 2022-09-19 15:16:27 UTC
handing this to Mike Fedosin

Comment 4 Mike Fedosin 2022-11-21 15:00:09 UTC
Hey! I added more webhooks and also activated the previous ones in this PR: https://github.com/openshift/cluster-capi-operator/pull/85

Comment 5 sunzhaohua 2022-11-23 08:16:58 UTC
Hi Mike, I tested before pr merge, these all work as expected. Just one thing want to confirm, cluster can be created more than one, is this ok?
$ oc get cluster                                                                    
NAME                          PHASE          AGE   VERSION
ci-ln-kv1gj4b-72292-jn4rw     Provisioning   19m
ci-ln-kv1gj4b-72292-jn4rw-1   Provisioning   7s


$ oc create -f ~/data/capi/gcp-cluster.yaml                                                                                                   
Error from server (unsupported cluster infra provider kind: GCPCluster-invalid): error when creating "/Users/sunzhaohua/data/capi/gcp-cluster.yaml": admission webhook "validation.cluster.cluster.x-k8s.io" denied the request: unsupported cluster infra provider kind: GCPCluster-invalid
$ oc delete cluster ci-ln-kv1gj4b-72292-jn4rw                                 
Error from server (deletion of cluster is not allowed): admission webhook "validation.cluster.cluster.x-k8s.io" denied the request: deletion of cluster is not allowed

$ oc create -f coreprovider.yaml                                             
Error from server (incorrect core provider name: cluster-api2): error when creating "coreprovider.yaml": admission webhook "vcoreprovider.operator.cluster.x-k8s.io" denied the request: incorrect core provider name: cluster-api2
$  oc delete CoreProvider cluster-api
Error from server (deletion of core provider is not allowed): admission webhook "vcoreprovider.operator.cluster.x-k8s.io" denied the request: deletion of core provider is not allowed

$ oc create -f infrastructureprovider-gcp.yaml                             
Error from server (incorrect infra provider name for GCP platform: gcp2): error when creating "infrastructureprovider-gcp.yaml": admission webhook "vinfrastructureprovider.operator.cluster.x-k8s.io" denied the request: incorrect infra provider name for GCP platform: gcp2
$ oc delete infraStructureProvider gcp
Error from server (deletion of infrastructure provider is not allowed): admission webhook "vinfrastructureprovider.operator.cluster.x-k8s.io" denied the request: deletion of infrastructure provider is not allowed

Comment 7 sunzhaohua 2022-11-28 02:34:15 UTC
Move to verified, created a new bug to trace the cluster issue https://issues.redhat.com/browse/OCPBUGS-4147

Comment 11 errata-xmlrpc 2023-05-17 22:46:56 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.13.0 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-2023:1326


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