crossplane-contrib / provider-jet-aws

AWS Provider for Crossplane that is built with Terrajet.
https://crossplane.io
Apache License 2.0
37 stars 30 forks source link

ECS Service: cannot set external name #170

Closed stevendborrelli closed 2 years ago

stevendborrelli commented 2 years ago

What happened?

When creating an ECS service, the provider cannot set the external-name annotation.

 Warning  CannotObserveExternalResource  4m47s (x918 over 78m)  managed/ecs.aws.jet.crossplane.io/v1alpha2, kind=service  cannot set critical annotations: cannot get external name: external name should have the following format: cluster-name/service-name

It looks like it is omitting the cluster name from the external name:

             crossplane.io/external-name: xppoca1-ecs-prq7x

How can we reproduce it?

Name:         xppoca1-ecs-prq7x
Namespace:    
Labels:       crossplane.io/claim-name=
              crossplane.io/claim-namespace=
              crossplane.io/composite=xppoca1-ecs
Annotations:  crossplane.io/external-create-pending: 2022-03-11T16:45:42Z
              crossplane.io/external-create-succeeded: 2022-03-11T16:45:42Z
              crossplane.io/external-name: xppoca1-ecs-prq7x
API Version:  ecs.aws.jet.crossplane.io/v1alpha2
Kind:         Service
Metadata:
  Creation Timestamp:  2022-03-11T16:44:29Z
  Finalizers:
    finalizer.managedresource.crossplane.io
  Generate Name:  xppoca1-ecs-
  Generation:     3
  Managed Fields:
    API Version:  ecs.aws.jet.crossplane.io/v1alpha2
    Manager:      crossplane
    Operation:    Update
    Time:         2022-03-11T16:45:15Z
    API Version:  ecs.aws.jet.crossplane.io/v1alpha2
    Fields Type:  FieldsV1
    fieldsV1:
      f:metadata:
        f:annotations:
          .:
          f:crossplane.io/external-create-pending:
          f:crossplane.io/external-create-succeeded:
          f:crossplane.io/external-name:
        f:finalizers:
          .:
          v:"finalizer.managedresource.crossplane.io":
      f:status:
        .:
        f:atProvider:
          .:
          f:id:
        f:conditions:
    Manager:    crossplane-provider
    Operation:  Update
    Time:       2022-03-11T16:45:53Z
  Owner References:
    API Version:     aws.autodemo.crossplane.io/v1alpha1
    Controller:      true
    Kind:            XECSCluster
    Name:            xppoca1-ecs
    UID:             86276eb4-f0f7-4142-a0d6-b8472d17ab2f
  Resource Version:  42829906
  UID:               639932b1-e0a9-46ee-bbb5-a642c866ea93
Spec:
  Deletion Policy:  Delete
  For Provider:
    Cluster:  xppoca1-ecs-snq6z
    Network Configuration:
      Subnets:
        subnet1
    Region:           us-west-2
    Task Definition:  demo-task1:3
  Provider Config Ref:
    Name:  aws-provider
Status:
  At Provider:
    Id:  arn:aws:ecs:us-west-2:ACCOUNT:service/test-ecs-snq6z/test-ecs-prq7x
  Conditions:
    Last Transition Time:  2022-03-11T16:45:53Z
    Message:               observe failed: cannot set critical annotations: cannot get external name: external name should have the following format: cluster-name/service-name
    Reason:                ReconcileError
    Status:                False
    Type:                  Synced
    Last Transition Time:  2022-03-11T16:44:38Z
    Reason:                Creating
    Status:                False
    Type:                  Ready
    Last Transition Time:  2022-03-11T16:45:48Z
    Reason:                Finished
    Status:                True
    Type:                  AsyncOperation
    Last Transition Time:  2022-03-11T16:45:48Z
    Reason:                Success
    Status:                True
    Type:                  LastAsyncOperation

What environment did it happen in?

Crossplane version: 1.6.2 Provider-jet-aws: 0.4.0

stevendborrelli commented 2 years ago

[Edit]: never mind, I had an issue with my external-name.

Working for me.

PR #173 may not have fixed the issue. In testing this morning I get:

  Warning  CannotObserveExternalResource  2m10s (x23 over 3m35s)  managed/ecs.aws.jet.crossplane.io/v1alpha2, kind=service  cannot run refresh: refresh failed: error reading ECS service: InvalidParameterException: Invalid identifier: Unexpected number of separators: : File name: main.tf.json

The service is not created in AWS.

stevendborrelli commented 2 years ago

In further testing, this was an issue caused by me trying a custom external name to get around the first issue. Once I let the provider set the external name it worked.

PR looks good!