Uploaded image for project: 'Cost Management'
  1. Cost Management
  2. COST-4071

Operator: Use cluster ID as default source name when none provided

XMLWordPrintable

    • Icon: Epic Epic
    • Resolution: Done
    • Icon: Normal Normal
    • 2023Q4
    • None
    • Operators
    • None
    • Operator: cluster ID default source name
    • False
    • None
    • False
    • COST-4035 - Get rid of INSERT-SOURCE-NAME
    • COST-4035Get rid of INSERT-SOURCE-NAME
    • 0% To Do, 0% In Progress, 100% Done

      Release target date: October 2, 2023

       

      When installing the operator, users must replace INSERT-SOURCE-NAME with a some string.

      But many don't, which makes this a common source (no pun intended O of errors for customers.

      Is there a way to force them to insert a source name during operator installation? Or just automagically generate a source name from some source (eg cluster id) data?

       

      from mskarbek 

      I think there are 2 options to accomplish this:

      1. create a validation pattern for the source name. This would be a regex that excludes INSERT-SOURCE-NAME as a valid source name. This route prevents a user from creating a CR with INSERT-SOURCE-NAME as their source name.
      2. do not validate the name, but check the sourceName in the code, and change it to the cluster-id if the sourceName is defined as INSERT-SOURCE-NAME.

      I tried the a regex pattern (which we would add here in the api definition):

      // +kubebuilder:validation:Pattern=`^((?!INSERT-SOURCE-NAME).)*$`
      

       but that failed with:

      The CustomResourceDefinition "kokumetricsconfigs.koku-metrics-cfg.openshift.io" is invalid: spec.validation.openAPIV3Schema.properties[spec].properties[source].properties[name].pattern: Invalid value: "^((?! must be a valid regular expression, but isn't: error parsing regexp: invalid or unsupported Perl syntax: `(?!`
      make: *** [install] Error 1
      

      Basically, that regex pattern is not compatible with Go regex. So we would need to figure out how to construction a regex that excludes INSERT-SOURCE-NAME that is go compatible.

       
      For the code route, we probably want to check the value of the source name here. Then we could do something like:

      	StringReflectSpec(r, cr, &cr.Spec.Source.SourceName, &cr.Status.Source.SourceName, "")
      	if cr.Status.Source.SourceName == "INSERT-SOURCE-NAME" {
      		cr.Status.Source.SourceName = cr.Status.ClusterID
      	}
      

              rh-ee-dnakabaa David Nakabaale
              pgarciaq@redhat.com Pau Garcia Quiles
              Daniel Chorvatovic Daniel Chorvatovic
              Votes:
              0 Vote for this issue
              Watchers:
              17 Start watching this issue

                Created:
                Updated:
                Resolved: