-
Notifications
You must be signed in to change notification settings - Fork 686
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
Handling a null response for certain values from PCA #2137
Open
cam-mclaren
wants to merge
1
commit into
oracle:master
Choose a base branch
from
cam-mclaren:issue_1924
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does setting the values to an empty map fix the issue you are facing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi thanks for reviewing.
Problem Description
At the moment we are having trouble with aggregate data types like maps being returned as null by the PCA API. When stored as
null
in the state file these aggregate data type variables report a change as being required every plan despite the values not being specified in our terraform configuration.To give a concrete example, below I have an image of the state file for vm instance created with the OCI Terraform provider on a Private Cloud Appliance. You can see that the value for system tags is set to
null
which is due to the behavior of the PCA API.Image 1: system_tags set to null
Whenever this
system_tags
variable is set tonull
in the state file aterraform plan
will always report(known after apply)
as the value it will be changed to. With the null value Terraform seems to always detect changes to be made despite no actual Terraform configuration changes. This is okay when dealing with a single vm instance. However larger scales these reported changes become very problematic and make it very difficult to determine legitimate drift in your configuration.Image 2: terraform plan reports the
system_tags
value as requiring a change despite its value being unspecified.We can fix this false
system_tags
change by setting it to an empty map{}
through a manual edit of the state file. Below I have an image of the state file after being manually edited.Image 3: system_tags is manually set to {} in the state file.
The resulting
terraform plan
no longer reports thesystem_tags
attribute as requiring a change as can be seen in Image 4.Image 4: There is no required change detected for system_tags.
We can fix the
extended_metadata
attribute in the same way. By changing it in the state file fromnull
to{}
this will remove the false change from the plan entirely.Image 5: After setting the values in the state file from null to {} no change is detected.
As seen above setting the values of
extended_metadata
andsystem_tags
to a value of empty map entirely removes the problem of the provider falsely reporting changes for PCA users.I suspect for those without a PCA to access you will be able to confirm this problematic behavior from
null
by manually editing a state file for a vm instance on OCI so that itssystem_tags
attribute is set tonull
.