Uploaded image for project: 'OpenShift Bugs'
  1. OpenShift Bugs
  2. OCPBUGS-61040

[AWS][CAPI] The error message is inaccurate when both setting capacityReservationId and Open/None capacityReservationPreference

XMLWordPrintable

    • Quality / Stability / Reliability
    • False
    • Hide

      None

      Show
      None
    • None
    • Low
    • None
    • None
    • None
    • CLOUD Sprint 277, CLOUD Sprint 278
    • 2
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Description of problem:

        When both setting capacityReservationId and Open/None capacityReservationPreference, will get error message as below:
      
          message: 'admission webhook "validation.awsmachine.infrastructure.cluster.x-k8s.io"
            denied the request: AWSMachine.infrastructure.cluster.x-k8s.io "huliu-aws829a-4nts6-worker-us-east-2aa-p4mz6"
            is invalid: spec.capacityReservationPreference: Forbidden: when a reservation
            ID is specified, capacityReservationPreference may only be `capacity-reservations-only`
            or empty'
      
      But `capacity-reservations-only` is not a valid value, if I set `capacity-reservations-only` for capacityReservationPreference, will get error message as below:
      
      liuhuali@Lius-MacBook-Pro huali-test % oc create -f ms2.yaml 
      The AWSMachineTemplate "huliu-aws829a-4nts6-worker-test2" is invalid: 
      * spec.template.spec.capacityReservationPreference: Unsupported value: "capacity-reservations-only": supported values: "", "None", "CapacityReservationsOnly", "Open"
      * <nil>: Invalid value: "": "spec.template.spec.capacityReservationPreference" must validate all the schemas (allOf). None validated
      * <nil>: Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation
      
      So `capacity-reservations-only` should be changed to `CapacityReservationsOnly`
      
      By the way, `a reservation ID` should be better changed to `capacityReservationId`

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

          4.20.0-0.nightly-2025-08-28-071300

      How reproducible:

          always

      Steps to Reproduce:

          1.Create awsmachinetemplate setting capacityReservationId and Open/None capacityReservationPreference, like 
      
            capacityReservationPreference: None
            capacityReservationId: cr-0c6b869ee31356e75
      
      liuhuali@Lius-MacBook-Pro huali-test % oc create -f ms2.yaml 
      awsmachinetemplate.infrastructure.cluster.x-k8s.io/huliu-aws829a-4nts6-worker-test1 created
      liuhuali@Lius-MacBook-Pro huali-test % oc get awsmachinetemplate
      NAME                                             AGE
      huliu-aws829a-4nts6-worker-test1                 25s
      huliu-aws829a-4nts6-worker-us-east-2a-2914f458   112m
      huliu-aws829a-4nts6-worker-us-east-2b-e571d075   112m
      huliu-aws829a-4nts6-worker-us-east-2c-0704d6c6   112m
      
          2.Create machineset, will see the error message in the machineset
      
      liuhuali@Lius-MacBook-Pro huali-test % oc create -f ms3.yaml 
      machineset.cluster.x-k8s.io/huliu-aws829a-4nts6-worker-us-east-2aa created
      liuhuali@Lius-MacBook-Pro huali-test % oc get machineset.c huliu-aws829a-4nts6-worker-us-east-2aa -oyaml
      ...
      status:
        conditions:
        - lastTransitionTime: "2025-08-29T04:22:53Z"
          message: 'admission webhook "validation.awsmachine.infrastructure.cluster.x-k8s.io"
            denied the request: AWSMachine.infrastructure.cluster.x-k8s.io "huliu-aws829a-4nts6-worker-us-east-2aa-9fcxd"
            is invalid: spec.capacityReservationPreference: Forbidden: when a reservation
            ID is specified, capacityReservationPreference may only be `capacity-reservations-only`
            or empty'
          reason: InfrastructureTemplateCloningFailed
          severity: Error
          status: "False"
          type: Ready
      
           3. Try setting `capacity-reservations-only` for capacityReservationPreference in awsmachinetemplate, get error
      
            capacityReservationPreference: capacity-reservations-only
      
      liuhuali@Lius-MacBook-Pro huali-test % oc create -f ms2.yaml 
      The AWSMachineTemplate "huliu-aws829a-4nts6-worker-test2" is invalid: 
      * spec.template.spec.capacityReservationPreference: Unsupported value: "capacity-reservations-only": supported values: "", "None", "CapacityReservationsOnly", "Open"
      * <nil>: Invalid value: "": "spec.template.spec.capacityReservationPreference" must validate all the schemas (allOf). None validated
      * <nil>: Invalid value: "null": some validation rules were not checked because the object was invalid; correct the existing errors to complete validation 

      Actual results:

          error message shows 
      
          message: 'admission webhook "validation.awsmachine.infrastructure.cluster.x-k8s.io"
            denied the request: AWSMachine.infrastructure.cluster.x-k8s.io "huliu-aws829a-4nts6-worker-us-east-2aa-9fcxd"
            is invalid: spec.capacityReservationPreference: Forbidden: when a reservation
            ID is specified, capacityReservationPreference may only be `capacity-reservations-only`
            or empty'

      Expected results:

          `capacity-reservations-only` should be changed to `CapacityReservationsOnly`
      
      `a reservation ID` should be better changed to `capacityReservationId`

      Additional info:

          new feature testing for https://issues.redhat.com/browse/OCPCLOUD-3028

              ddonati@redhat.com Damiano Donati
              huliu@redhat.com Huali Liu
              None
              None
              Huali Liu Huali Liu
              None
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Created:
                Updated: