awslabs / crossplane-on-eks

Crossplane bespoke composition blueprints for AWS resources
Apache License 2.0
308 stars 109 forks source link

[QUESTION] [Bug]: Operation cannot be fulfilled on xobjectstorages.awsblueprints.io "standard-object-storage-gqbj8": the object has been modified #80

Closed Fettah closed 1 year ago

Fettah commented 1 year ago

Please describe your quesiton here

I have copied and pasted the examples used here to create an S3 bucket using a composite resource definition and I seeing an error and the buckets are not being create, though I have not mad any changes to the examples specified in this repository:

apiVersion: apiextensions.crossplane.io/v1
kind: CompositeResourceDefinition
metadata:
  name: xobjectstorages.awsblueprints.io
spec:
  claimNames:
    kind: ObjectStorage
    plural: objectstorages
  group: awsblueprints.io
  names:
    kind: XObjectStorage
    plural: xobjectstorages
  connectionSecretKeys:
    - region
    - bucket-name
    - s3-put-policy
  versions:
    - name: v1alpha1
      served: true
      referenceable: true
      schema:
        openAPIV3Schema:
          properties:
            spec:
              description: ObjectStorageSpec defines the desired state of ObjectStorage
              properties:
                resourceConfig:
                  description:
                    ResourceConfig defines general properties of this AWS
                    resource.
                  properties:
                    deletionPolicy:
                      description: Defaults to Delete
                      enum:
                        - Delete
                        - Orphan
                      type: string
                    name:
                      description:
                        Set the name of this resource in AWS to the value
                        provided by this field.
                      type: string
                    providerConfigName:
                      type: string
                    region:
                      type: string
                    tags:
                      items:
                        properties:
                          key:
                            type: string
                          value:
                            type: string
                        required:
                          - key
                          - value
                        type: object
                      type: array
                  required:
                    - providerConfigName
                    - region
                    - tags
                  type: object
              required:
                - resourceConfig
              type: object
            status:
              description: ObjectStorageStatus defines the observed state of ObjectStorage
              properties:
                bucketName:
                  type: string
                bucketArn:
                  type: string
              type: object
          type: object
---
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
  name: s3bucket.awsblueprints.io
  labels:
    awsblueprints.io/provider: aws
    awsblueprints.io/environment: dev
    s3.awsblueprints.io/configuration: standard
spec:
  writeConnectionSecretsToNamespace: crossplane-system
  compositeTypeRef:
    apiVersion: awsblueprints.io/v1alpha1
    kind: XObjectStorage
  patchSets:
    - name: common-fields
      patches:
        - type: FromCompositeFieldPath
          fromFieldPath: spec.resourceConfig.providerConfigName
          toFieldPath: spec.providerConfigRef.name
        - type: FromCompositeFieldPath
          fromFieldPath: spec.resourceConfig.deletionPolicy
          toFieldPath: spec.deletionPolicy
        - type: FromCompositeFieldPath
          fromFieldPath: spec.resourceConfig.region
          toFieldPath: spec.forProvider.region
        - type: FromCompositeFieldPath
          fromFieldPath: spec.resourceConfig.name
          toFieldPath: metadata.annotations[crossplane.io/external-name]
  resources:
    - name: s3-bucket
      connectionDetails:
        - name: bucket-name
          fromConnectionSecretKey: endpoint
        - name: region
          fromConnectionSecretKey: region
      base:
        apiVersion: s3.aws.crossplane.io/v1beta1
        kind: Bucket
        spec:
          deletionPolicy: Delete
          forProvider:
            acl: private
            publicAccessBlockConfiguration:
              blockPublicAcls: true
              blockPublicPolicy: true
              ignorePublicAcls: true
              restrictPublicBuckets: true
            serverSideEncryptionConfiguration:
              rules:
                - applyServerSideEncryptionByDefault:
                    sseAlgorithm: AES256
      patches:
        - type: PatchSet
          patchSetName: common-fields
        - type: FromCompositeFieldPath
          fromFieldPath: spec.resourceConfig.tags
          toFieldPath: spec.forProvider.tagging.tagSet
          policy:
            mergeOptions:
              appendSlice: true
              keepMapValues: true
        - type: FromCompositeFieldPath
          fromFieldPath: spec.resourceConfig.region
          toFieldPath: spec.forProvider.locationConstraint
        - fromFieldPath: spec.writeConnectionSecretToRef.namespace
          toFieldPath: spec.writeConnectionSecretToRef.namespace
        - type: ToCompositeFieldPath
          fromFieldPath: metadata.annotations[crossplane.io/external-name]
          toFieldPath: status.bucketName
        - type: ToCompositeFieldPath
          fromFieldPath: status.atProvider.arn
          toFieldPath: status.bucketArn
        - fromFieldPath: metadata.uid
          toFieldPath: spec.writeConnectionSecretToRef.name
          transforms:
            - type: string
              string:
                fmt: "%s-bucket"
---
apiVersion: awsblueprints.io/v1alpha1
kind: ObjectStorage
metadata:
  name: standard-object-storage
  namespace: default
spec:
  compositionSelector:
    matchLabels:
      awsblueprints.io/provider: aws
      awsblueprints.io/environment: dev
      s3.awsblueprints.io/configuration: standard
  writeConnectionSecretToRef:
    name: bucket-info
  resourceConfig:
    providerConfigName: aws-provider-config
    region: eu-central-1
    tags:
      - key: env
        value: test
      - key: anotherKey
        value: anotherValue

Crossplane configs:

kind: ControllerConfig
metadata:
name: aws-config
annotations:
    eks.amazonaws.com/role-arn: "$ROLE_ARN"
spec:
podSecurityContext:
    fsGroup: 2000

apiVersion: aws.crossplane.io/v1beta1
kind: ProviderConfig
metadata:
name: aws-provider
spec:
credentials:
    source: InjectedIdentity

crossplane was installed with helm (repository: https://charts.crossplane.io/stable, version: 1.10.1) with this version: "{xpkg.upbound.io/crossplane-contrib/provider-aws:v0.33.0}"

Here is the error I get:

image image
nabuskey commented 1 year ago

@Fettah The error message the object has been modified is a red herring and can safely ignored. This message occurs whenever there are two goroutines accessing the same object or something similar. Meaningful messages are usually found in the events of managed resources. Are you seeing anything useful in managed resource events? In your case, you should be able to get it via kubectl describe bucket <bucket_name> See: https://github.com/awslabs/crossplane-on-eks/blob/main/doc/debugging.md

nabuskey commented 1 year ago

Please feel free to re-open the issue or reach out on the Crossplane slack.