-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Make sure resource private data is carried through the entire resource lifecycle #21611
Conversation
Private data was previously created during Plan, and sent back to the provider during Apply. This data also needs to be persisteded accross Read calls, but rather than rely on core for that we can send the data to the provider during Read to allow for more flexibilty.
Send Private data blob through ReadResource as well. This will allow for extra flexibility for future providers that may want to pass data out of band through to their resource Read functions.
|
||
func TestResourceTimeout_delete(t *testing.T) { | ||
// If the delete timeout isn't saved until destroy, the cleanup here will | ||
// fail because the default is only 20m. |
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.
Just A Comment: only 20m
😭
states/state_deepcopy.go
Outdated
@@ -181,14 +184,17 @@ func (obj *ResourceInstanceObject) DeepCopy() *ResourceInstanceObject { | |||
|
|||
var private []byte | |||
if obj.Private != nil { | |||
private := make([]byte, len(obj.Private)) | |||
private = make([]byte, len(obj.Private)) | |||
copy(private, obj.Private) | |||
} | |||
|
|||
// Some addrs.Referencable implementations are technically mutable, but |
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.
Typo fix opportunity? addrs.Referenceable
(if we apply the "while we're in the neighborhood" rule)
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.
Comment-y comments, I think I would need a talk-through to properly understand intent here (and changes to private data raise a security??
brain flag for me)
2315561
to
750e7e5
Compare
|
@@ -266,7 +267,7 @@ func testState() *states.State { | |||
Type: "test", | |||
}.Absolute(addrs.RootModuleInstance), | |||
) | |||
}) | |||
}).DeepCopy() |
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.
This DeepCopy
made me 🤔 a bunch because there's no other variable holding a reference to the state we built here and thus the copying seems superfluous.
However, reading down to see the other changes below I assume the goal here is to make sure that all of the data in the state makes it into the copy, and that makes sense. For the benefit of a future maintainer who won't have the benefit of seeing this line in the context of this PR diff, perhaps a short comment explaining that this is here to implicitly test DeepCopy
would be helpful so it doesn't get cleaned up.
750e7e5
to
5b1dcd1
Compare
Fix the scope of the private data copy in DeepCopy. Make sure Dependencies matches nil vs empty so that Equal compares correctly between copied states
The timeout value is still not being persisted. While it doesn't fix this issue, make sure to always return Private during Plan.
Makre sure private data is maintained all the way to destroy. This slipped through, since private data isn't used much for current providers, except for timeouts.
The private->meta data was lost in the test harness.
5b1dcd1
to
4cb6ebe
Compare
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
The Private data was lost in a couple places, and not detected due to the Private data not being used heavily by the current SDK.
This also adds the Private data to the
ReadResource
call. While not currently used, it makes the use of the data more consistent, and would allow for more flexibility with future providers.Fixes #21528