Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composition creates duplicate API GW integrations #941

Closed
alexandru-crossover opened this issue Nov 15, 2021 · 3 comments
Closed

Composition creates duplicate API GW integrations #941

alexandru-crossover opened this issue Nov 15, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@alexandru-crossover
Copy link

What happened?

Composition:

apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: api-route-composition
  labels:
    provider: aws
spec:
  compositeTypeRef:
    apiVersion: core.test.io/v1
    kind: CompositeApiRoute
  resources:
    - name: integration
      base:
        apiVersion: apigatewayv2.aws.crossplane.io/v1alpha1
        kind: Integration
        spec: {}
      patches:
        - fromFieldPath: "spec.resourceName"
          toFieldPath: "metadata.name"
          policy:
            fromFieldPath: Required
        - fromFieldPath: "spec.apiId"
          toFieldPath: "spec.forProvider.apiId"
        - fromFieldPath: "spec.integrationType"
          toFieldPath: "spec.forProvider.integrationType"
          policy:
            fromFieldPath: Required
        - fromFieldPath: "spec.integrationUri"
          toFieldPath: "spec.forProvider.integrationURI"
        - fromFieldPath: "spec.payloadFormatVersion"
          toFieldPath: "spec.forProvider.payloadFormatVersion"
        - fromFieldPath: "spec.requestParameters"
          toFieldPath: "spec.forProvider.requestParameters"
        - fromFieldPath: "spec.region"
          toFieldPath: "spec.forProvider.region"
          policy:
            fromFieldPath: Required
        - type: ToCompositeFieldPath
          fromFieldPath: "status.atProvider.integrationID"
          toFieldPath: "spec._integrationID"
    - name: route
      base:
        apiVersion: apigatewayv2.aws.crossplane.io/v1alpha1
        kind: Route
        spec:
          forProvider:
            target: integrations/unknown
      patches:
        - fromFieldPath: "spec.resourceName"
          toFieldPath: "metadata.name"
          policy:
            fromFieldPath: Required
        - fromFieldPath: "spec.apiId"
          toFieldPath: "spec.forProvider.apiId"
        - fromFieldPath: "spec.region"
          toFieldPath: "spec.forProvider.region"
          policy:
            fromFieldPath: Required
        - fromFieldPath: "spec.routeKey"
          toFieldPath: "spec.forProvider.routeKey"
          policy:
            fromFieldPath: Required
        - fromFieldPath: "spec._integrationID"
          toFieldPath: "spec.forProvider.target"
          transforms:
            - type: string
              string:
                fmt: "integrations/%s"
        - type: ToCompositeFieldPath
          fromFieldPath: "status.atProvider.routeID"
          toFieldPath: "status.routeID"

Definition:

apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
  name: compositeapiroutes.core.test.io
spec:
  defaultCompositionRef:
    name: api-route-composition
  group: core.test.io
  names:
    kind: CompositeApiRoute
    plural: compositeapiroutes
  claimNames:
    kind: ApiRoute
    plural: apiroutes
  versions:
    - name: v1
      served: true
      referenceable: true
      schema:
        openAPIV3Schema:
          type: object
          properties:
            spec:
              type: object
              properties:
                resourceName:
                  type: string
                apiId:
                  type: string
                integrationType:
                  type: string
                  enum:
                    - AWS
                    - AWS_PROXY
                    - HTTP
                    - HTTP_PROXY
                    - MOCK
                integrationUri:
                  type: string
                payloadFormatVersion:
                  type: string
                region:
                  type: string
                requestParameters:
                  type: object
                  x-kubernetes-preserve-unknown-fields: true
                routeKey:
                  type: string
                _integrationID:
                  type: string
              required:
                - integrationType
                - region
                - routeKey
            status:
              type: object
              properties:
                integrationID:
                  type: string
                routeID:
                  type: string

Sometimes, the above composition generates 2 integrations for the same resource. We have identified the creation of duplicate resources from CloudTrail events. We are seeing this only for integrations, routes are always created only once.

This leads to orphan integrations when the composite resource gets deleted, because only one of the 2 integrations is removed.

This is similar to #378 and #590, but we are not copying the annotations.

How can we reproduce it?

It's unclear under what conditions this happens, though it appears to be related to the load from the cluster.

What environment did it happen in?

Crossplane version: 1.1.1
AWS provider version: v0.20.0-rc.0.80.ga4a50b5d
Kubernetes version: 1.19
Kubernetes distribution: EKS

@alexandru-crossover alexandru-crossover added the bug Something isn't working label Nov 15, 2021
@chlunde
Copy link
Collaborator

chlunde commented Nov 15, 2021

Might be related: #825

@muvaf
Copy link
Member

muvaf commented Jan 29, 2022

@chlunde Is this still relevant?

@chlunde chlunde closed this as completed Feb 1, 2022
@chlunde
Copy link
Collaborator

chlunde commented Feb 1, 2022

I believe this is fixed now, please report if you can reproduce this on the latest release, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants