Skip to content

Conversation

@a-hilaly
Copy link
Member

@a-hilaly a-hilaly commented Mar 21, 2022

Currently when a resource is created without setting a region in the
annotations, the controller uses either the namespace annotation or the
controller region flag. This causes the controller to miss manage the
resource if they are restart with a different region, or if run a second
controller using a different region flag.

This patch adds a new field to ResourceMetadata struct and
AWSResourceIdentifiers interface to store the AWS region in which
the resource is created/should be managed. This patch also updates the
reconciler.getRegion method to lookup for a region in the
status.ResourceMetadata before trying to get one from the
resource/namespace annotations or the controller configuration.

Addresses aws-controllers-k8s/community#1220

This patch will also require some changes to the code-generator.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.

@a-hilaly a-hilaly changed the title Add Region() to ResourceMetadata struct and AWSResourceIdentifiers Add Region() to ResourceMetadata struct and AWSResourceIdentifiers interface Mar 21, 2022
@jaypipes jaypipes self-requested a review March 21, 2022 18:11
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

@a-hilaly thank you! a few minor comments about naming/wording, nothing major :)

interface

Currently when a resource is created without setting a region in the
annotations, the controller uses either the namespace annotation or the
controller region flag. This causes the controller to miss manage the
resource if they are restart with a different region, or if run a second
controller using a different region flag.

This patch adds a new field to `ResourceMetadata` struct and
`AWSResourceIdentifiers` interface store the AWSRegion in which the
resource is created/should be managed. This patch also updates the
`reconciler.getRegion` method to lookup for a region in the
status.ResourceMetadata before trying to get one from the
resource/namespace annotations or the controller configuration.

Addresses aws-controllers-k8s/community#1220

This patch will also require some changes to the code-generator.
Copy link
Collaborator

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

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

👍 thanks Amine!

@RedbackThomson
Copy link
Contributor

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 21, 2022
@ack-bot
Copy link
Collaborator

ack-bot commented Mar 21, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, jaypipes, RedbackThomson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [A-Hilaly,RedbackThomson,jaypipes]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-bot ack-bot merged commit a0caf01 into aws-controllers-k8s:main Mar 21, 2022
ack-bot pushed a commit to aws-controllers-k8s/code-generator that referenced this pull request Mar 22, 2022
Follow up to aws-controllers-k8s/runtime#79

This patch modifies the code-generator to generate a `Region` function
so that a resource can also satisfy the `Identifiers` interface. This
the patch also extends the `setStatusDefaults` so that it correctly
populates the `status.ResourceMetadata.Region` with the aws region in
which it is created/managed

Description of changes:
- Add `Region()` method to resourceIdentifiers template.
- Modifies `setStatusDefaults` to  be able to set the a default region.
- Update `runtime_test.go`

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 license.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants