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

Adding aws_batch_job_definition to v1beta1 version #857

Merged
merged 2 commits into from
Sep 28, 2023
Merged

Adding aws_batch_job_definition to v1beta1 version #857

merged 2 commits into from
Sep 28, 2023

Conversation

huffmanjohnf
Copy link
Contributor

Description of your changes

Adding (1) resources in the batch group:

Fixes #162
Related to #200

I have:

  • Run make reviewable test to ensure this PR is ready for review.

How has this code been tested

Applied in personal AWS account using local deployment created by make local-deploy.

@Upbound-CLA
Copy link

Upbound-CLA commented Sep 1, 2023

CLA assistant check
All committers have signed the CLA.

@huffmanjohnf
Copy link
Contributor Author

/test-examples="examples/batch/jobdefinition.yaml"

2 similar comments
@jeanduplessis
Copy link
Collaborator

/test-examples="examples/batch/jobdefinition.yaml"

@turkenf
Copy link
Collaborator

turkenf commented Sep 22, 2023

/test-examples="examples/batch/jobdefinition.yaml"

Copy link
Collaborator

@turkenf turkenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this PR @huffmanjohnf, I left a comment to consider.

@@ -1546,6 +1546,9 @@ var ExternalNameConfigs = map[string]config.ExternalName{
//
// Batch Scheduling Policy can be imported using the arn: arn:aws:batch:us-east-1:123456789012:scheduling-policy/sample
"aws_batch_scheduling_policy": config.TemplatedStringAsIdentifier("name", "arn:aws:batch:{{ .setup.configuration.region }}:{{ .setup.client_metadata.account_id }}:scheduling-policy/{{ .external_name }}"),
// Batch Job Definition can be imported using ARN that has a random substring, revision at the end:
// arn:aws:batch:us-east-1:123456789012:job-definition/sample:1
"aws_batch_job_definition": config.IdentifierFromProvider,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"aws_batch_job_definition": config.IdentifierFromProvider,
"aws_batch_job_definition": config.TemplatedStringAsIdentifier("name", "arn:aws:batch:{{ .setup.configuration.region }}:{{ .setup.client_metadata.account_id }}:job-definition/{{ .external_name }}"),

If you haven't tried it, can you please try the configuration above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the suggestion @turkenf. That was the first configuration I attempted, which ended up reproducing the behavior described in #162.

In summary, the configuration you suggested would successfully create the external resource but then the controller could not observe it afterwards due to:

Message: observe failed: cannot run refresh: refresh failed: "name" ("test:1") must be up to 128 letters (uppercase and lowercase), numbers, underscores and dashes, and must start with an alphanumeric.:

In other words, the external name part of the ARN for a job-definition has a name (defined in config, i.e. test) and a version (provided by AWS, i.e. :1).

If I understood the Contributing docs correctly, the version suffix provided by AWS breaks the pattern for Case 5: Non-random Substrings as Identifier used for most ARNs and instead falls into the random substring case:

However, there are cases where the ARN includes random substring and that would fall under Case 4.

I ended up choosing config.IdentifierFromProvider based on other resources with ARNs following the name:version pattern, such as an aws_ecs_task_definition external name. This worked locally, as I could create and observe the external resource from a local Crossplane cluster (created by make local-deploy) against my own AWS account.

I've never worked with golang before and mostly relied on the docs and Makefile to create this PR, so I'm certainly open for guidance on the best way to configure this. I am not sure how to troubleshoot the automated test logs or the error (uptest-v0.5.0: error: cannot run e2e tests successfully: cannot execute tests: kuttl failed: exit status 1) and can't seem to get make e2e run on my machine. Any help is much appreciated!

@turkenf
Copy link
Collaborator

turkenf commented Sep 27, 2023

/test-examples="examples/batch/jobdefinition.yaml"

@turkenf
Copy link
Collaborator

turkenf commented Sep 27, 2023

@huffmanjohnf, uptest failed because of:

ClientException: Error executing request, Exception : Value 0.25 for type VCPU in resourceRequirement is not valid. Please provide a numeric value.

@huffmanjohnf
Copy link
Contributor Author

Awesome, thank you for sharing the exception! That points me in the right direction. I'll update the resourceRequirement value from the Terraform example.

Where did you find that error trace? I didn't see it in the action logs.

@turkenf
Copy link
Collaborator

turkenf commented Sep 27, 2023

@huffmanjohnf
Copy link
Contributor Author

Ahh, I see. Thank you!
Ok, I've updated examples/batch/jobdefinition.yaml with a vCPU value of "1". I guess the example in the Terraform docs is no longer valid as vCPU must be an integer greater than or equal to 1. I left the original example examples-generated/batch/jobdefinition.yaml untouched.

@huffmanjohnf
Copy link
Contributor Author

/test-examples="examples/batch/jobdefinition.yaml"

1 similar comment
@turkenf
Copy link
Collaborator

turkenf commented Sep 27, 2023

/test-examples="examples/batch/jobdefinition.yaml"

Copy link
Collaborator

@turkenf turkenf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution @huffmanjohnf, LGTM.

@turkenf turkenf merged commit 5f209c3 into crossplane-contrib:main Sep 28, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

batch: aws_batch_job_definition CannotObserveExternalResource deployment error
4 participants