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

TALM doesn's support policies with object-templates-raw only

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done-Errata
    • Icon: Undefined Undefined
    • 4.15.z
    • 4.13.z
    • TALM Operator
    • None
    • No
    • CNF RAN Sprint 245, CNF RAN Sprint 247
    • 2
    • False
    • Hide

      None

      Show
      None
    • Feature
    • Proposed

      Description of problem:

      When trying to create a CGU targetting a policy that uses object-templates-raw the talm operator marks the CGU as invalid due to a validation error.
      
      ERROR    controllers.ClusterGroupUpgrade    Policy is invalid    {"error": "leaf-hubs-deploy-ztp-pipeline: policy is missing its spec.policy-templates.objectDefinition.spec.object-templates"}
      
      
      The validation should include object-templates-raw as well.

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

      4.13.X

      How reproducible:

      Always

      Steps to Reproduce:

      Use this policy:
      
      
      apiVersion: policy.open-cluster-management.io/v1
      kind: Policy
      metadata:
        annotations:
          policy.open-cluster-management.io/categories: CM Configuration Management
          policy.open-cluster-management.io/controls: CM-2 Baseline Configuration
          policy.open-cluster-management.io/standards: NIST SP 800-53
          ran.openshift.io/ztp-deploy-wave: "15"
        name: leaf-hubs-apply-vendor-label
        namespace: ztp-policies
      spec:
        disabled: false
        policy-templates:
        - objectDefinition:
            apiVersion: policy.open-cluster-management.io/v1
            kind: ConfigurationPolicy
            metadata:
              name: apply-vendor-label-to-leaf-hubs
            spec:
              evaluationInterval:
                compliant: 10m
                noncompliant: 10s
              namespaceselector:
                exclude:
                - kube-*
                include:
                - '*'
              object-templates-raw: |
                {{- range (lookup "cluster.open-cluster-management.io/v1" "ManagedCluster" "" "").items }}
                {{- if eq (index .metadata.labels "leaf-hub") "true" }}
                - complianceType: musthave
                  objectDefinition:
                    apiVersion: cluster.open-cluster-management.io/v1
                    kind: ManagedCluster
                    metadata:
                      name: {{ .metadata.name }}
                      labels:
                        vendor: "OpenShift"
                {{- end }}
                {{- end }}
              remediationAction: inform
              severity: low
        remediationAction: inform

      Actual results:

      CGU reads the policy and validation fails.

      Expected results:

      CGU reads the policy and creates the enforce version.

      Additional info:

      https://redhat-internal.slack.com/archives/C02EG99MR9C/p1699288532177459

            sskeard@redhat.com Steven Skeard
            mavazque@redhat.com Mario Vazquez Cebrian
            Joshua Clark Joshua Clark
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: