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

update for default resource tags #87

Merged
merged 1 commit into from
May 20, 2022

Conversation

vijtrip2
Copy link
Contributor

Issue #, if available: aws-controllers-k8s/community#1261

Description of changes:

  • This PR changes the default ACK resource tags from empty list to []string{"services.k8s.aws/controller-version=%CONTROLLER_VERSION%" ,"services.k8s.aws/namespace=%K8S_NAMESPACE%"}.

  • Instead of statically passing the controller release version from release artifacts, i made it a dynamic %CONTROLLER_VERSION% variable. The dynamic variable will allow customers to use this variable in their custom tags as well.

  • I refactored the various service controller metadata fields into a new ServiceControllerMetadata type as well.

Tested locally that the resource tags get resolved as expected.

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

@vijtrip2 vijtrip2 changed the title updated the default resource tags update for default resource tags May 19, 2022
Copy link
Contributor

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

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

Left a suggestion inline.

I think it would be good to support a few more variables, even if they aren't used in the default. My suggestions would be:

  • %OWNER_ACCOUNT_ID% - taken from Status
  • %K8S_RESOURCE_NAME% - taken from metadata.name
  • %K8S_CRD_VERSION% - the CRD version (v1alpha1)

Comment on lines +71 to +72
case "%CONTROLLER_VERSION%":
expandedValue = generateControllerVersion(md)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we split this into two different variables? Perhaps %CONTROLLER_SERVICE% and %CONTROLLER_VERSION%? This way users can, with more granularity, choose their tag formats.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

how about i tackle this in a followup PR?

This PR can deal with refactor of serviceController and addition of a new tag field. Keeping existing expandValue method as is.

Next PR will deal with supporting more reserved keywords, and find + replace keywords in all resource tags, not just the ones that match the switch case.

Copy link
Contributor

Choose a reason for hiding this comment

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

The change I suggested will not be backward compatible. If we delay that change but push out this functionality, there is a chance that one of our GA controllers will be released between now and then with breaking compatibility. I'd prefer that if we are going to start enabling this feature, that we start off with the format we want to support in the long-term.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, by followup PR, i meant next PR(before releasing this feature).

And I am curious to know what will be the backward incompatible change. I did not get that part.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh the backward incompatibility would be %CONTROLLER_VERSION% changing from s3-v1.0.0 to v1.0.0. But I guess as long as we get both of these out before cutting a new runtime release then I'm fine with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After supporting these different tag variables, I was planning on changing the default tag to services.k8s.aws/controller-version=%CONTROLLER_SERVICE%-%CONTROLLER_VERSION% and then the output tag value will stay the same.

Also I wanted to do inplace substring replacement instead complete string replacement in the next PR.

Copy link
Contributor

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

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

/lgtm

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

ack-bot commented May 20, 2022

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: RedbackThomson, vijtrip2

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 [RedbackThomson,vijtrip2]

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 08a6708 into aws-controllers-k8s:main May 20, 2022
ack-bot pushed a commit that referenced this pull request May 24, 2022
Issue #, if available: aws-controllers-k8s/community#1261

Description of changes:
* support '%CONTROLLER_SERVICE%' , '%CONTROLLER_VERSION%', '%K8S_NAMESPACE%' and '%K8S_RESOURCE_NAME%' as the resource tag format
* support tag format as substring, and not just complete tag value
* As per the [comment](#87 (review)) , I did not add 'OWNER_ACCOUNT_ID' because any AWS related information will be known to customer when describing tags or viewing the resource in AWS console.  
* I also did not add 'K8S_CRD_VERSION' right now and waiting for multi version support , to find out the best place to find the k8s resource crd version.



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
3 participants