Skip to content

Regex matching not behaving as expected #35

@ashishkurian

Description

@ashishkurian

What happened?

I tried the latest version v0.2.1 of the function sequencer to have regex matching of resource names. However it does not seem to be working.

How can we reproduce it?

I am using the following composition to have control over the sequence of resource creation. I want EksClusterId-Ashtest to be created before EksUserArn-Ashtest. However, with the following regex matching, both the resources are created concurrently. As soon as I specify the exact names of the resources instead of a regex matching, the sequence is followed.

---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: xcastaicommon.mycompany.com
spec:
  compositeTypeRef:
    apiVersion: mycompany.com/v1alpha1
    kind: XCastAICommon
  environment:
    environmentConfigs:
    - type: Reference
      ref:
        name: iaws-main
    - type: Reference
      ref:
        name: iaws-auto
  mode: Pipeline
  pipeline:
  - step: castai-ekscluster
    functionRef:
      name: function-go-templating
    input:
      apiVersion: gotemplating.fn.crossplane.io/v1beta1
      kind: GoTemplate
      source: Inline
      inline:
        template: |
          {{- $accountId          := printf "%q" (.observed.composite.resource.spec.genericParameters.accountID) }}
          {{- $region             := .observed.composite.resource.spec.genericParameters.region }}
          {{- $eksClusterName     := .observed.composite.resource.spec.genericParameters.eksClusterName }}
          {{- $deletionPolicy     := .observed.composite.resource.spec.genericParameters.deletionPolicy }}
          {{- $providerConfigRef  := .observed.composite.resource.spec.genericParameters.providerConfig }}
          ---
          apiVersion: castai.upbound.io/v1alpha1
          kind: EksClusterId
          metadata:
            annotations:
              gotemplating.fn.crossplane.io/composition-resource-name: EksClusterId-Ashtest
            labels:
              cast-ai-cluster: {{$eksClusterName}}
          spec:
            deletionPolicy: {{$deletionPolicy}}
            providerConfigRef:
              name: {{$providerConfigRef}}
            forProvider:
              region: {{$region}}
              accountId: {{$accountId}}
              clusterName: {{$eksClusterName}}            
  - step: castai-eksuserarn
    functionRef:
      name: function-go-templating
    input:
      apiVersion: gotemplating.fn.crossplane.io/v1beta1
      kind: GoTemplate
      source: Inline
      inline:
        template: |
          {{- $deletionPolicy     := .observed.composite.resource.spec.genericParameters.deletionPolicy }}
          {{- $providerConfigRef  := .observed.composite.resource.spec.genericParameters.providerConfig }}
          {{ $managedresources    := .observed.resources | default dict }}
          {{ $EksClusterId        := get $managedresources "EksClusterId-Ashtest" | default dict }}
          {{ $EksClusterIdId      := dig "resource" "status" "atProvider" "id" "defaultvalue" $EksClusterId }}
          ---
          apiVersion: castai.upbound.io/v1alpha1
          kind: EksUserArn
          metadata:
            annotations:
              gotemplating.fn.crossplane.io/composition-resource-name: EksUserArn-Ashtest
          spec:
            deletionPolicy: {{$deletionPolicy}}
            providerConfigRef:
              name: {{$providerConfigRef}}
            forProvider:
              clusterId: {{$EksClusterIdId}}
  - step: automatically-detect-ready-composed-resources
    functionRef:
      name: function-auto-ready
  - step: sequence-creation
    functionRef:
      name: function-sequencer
    input:
      apiVersion: sequencer.fn.crossplane.io/v1beta1
      kind: Input
      rules:
        - sequence:
          - ^EksClusterId-.*$
          - ^EksUserArn-.*$

What environment did it happen in?

Function version: v0.2.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions