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

Removing the applying of StateFuncs to parameters #358

Merged
merged 2 commits into from
Mar 6, 2024

Conversation

sergenyalcin
Copy link
Member

@sergenyalcin sergenyalcin commented Mar 1, 2024

Description of your changes

Relevant PR: crossplane-contrib/provider-upjet-aws#1188

This PR removes the applying of StateFuncs to parameters. This PR contains a fix for the crossplane-contrib/provider-upjet-aws#1109.

In the Diff function of terraform-plugin-sdk, the StateFuncs have already applied to parameters. So, when we apply the StateFuncs before the Observe, the StateFuncs is called two times.

Big portion of the StateFuncs are idempotents like NomalizeJson, strings.ToUpper etc. However, some of them are not idempotent and we observed the problem in this type of case.

During the investigations of crossplane-contrib/provider-upjet-aws#1109 issue, we observed that a problematic behavior in upjet side. The aws.ec2.Instance resource's field user_data has a StateFunc that calculates the hash of the provided string and stores this hash value of string in status. For this resource the StateFunc is not idempotent and this causes a problem because we call the StateFunc two times. Result of this behavior, we calculate the wrong input for the resoruce.

This PR proposes removal of applying the StateFuncs to parameters. We will continue to process HCL expressions in parameters.

I have:

  • Read and followed Upjet's contribution process.
  • Run make reviewable to ensure this PR is ready for review.
  • Added backport release-x.y labels to auto-backport this PR if necessary.

How has this code been tested

Tested against the following resources that have different StateFuncs (in AWS):

  • ec2.Instance
  • networkmanager.CoreNetwork
  • dynamodb.Table

Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
Copy link
Collaborator

@ulucinar ulucinar left a comment

Choose a reason for hiding this comment

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

Thanks @sergenyalcin, lgtm. If we do not observe any issues with the proposed changes here in our tests in crossplane-contrib/provider-upjet-aws#1188, then we can merge this PR.

pkg/controller/external_tfpluginsdk.go Outdated Show resolved Hide resolved
Signed-off-by: Sergen Yalçın <yalcinsergen97@gmail.com>
@sergenyalcin sergenyalcin merged commit 363f66c into crossplane:main Mar 6, 2024
7 checks passed
@sergenyalcin sergenyalcin deleted the fix-statefunc-call branch March 6, 2024 10:50
Copy link

github-actions bot commented Mar 6, 2024

Successfully created backport PR #364 for release-1.2.

Copy link

github-actions bot commented Mar 6, 2024

Successfully created backport PR #365 for release-1.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants