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

Add support for the cross resource type move operation in the proto schema #34480

Merged
merged 4 commits into from
Jan 11, 2024

Conversation

liamcervante
Copy link
Member

@liamcervante liamcervante commented Jan 4, 2024

Update proto schema and provider interfaces with support for moved across resource type RPCs.

Target Release

1.8.0-alpha

Draft CHANGELOG entry

N/A, will write a proper entry for the whole moved-across-resource-type change once completed.

@liamcervante liamcervante requested review from jbardin, bflad and a team January 4, 2024 16:07
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

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

Optimistically approving as overall looks good to me, just with some minor considerations. 🚀

Regarding the unknown schema state encoding/decoding, if you peek at the UpgradeResourceState RPC handling, you'll see what I believe to be a similar problem there. That RPC opts to send this data in its "raw state" form (JSON of flat map or existing state data), which its up to the provider side to implement the appropriate decoding. Not sure if that implementation detail something worth using here as well and apologies I missed that previously.

}
}

message MoveResourceState {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor, open question: We haven't shipped even an alpha with protocol version 5.5/6.5 and functions support. Should we just roll this into the existing protocol definitions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

Comment on lines 665 to 669
targetType, ok := schema.ResourceTypes[r.TargetTypeName]
if !ok {
resp.Diagnostics = resp.Diagnostics.Append(fmt.Errorf("unknown resource type %q", r.TargetTypeName))
return resp
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Should this validation occur before the provider is called or other computational effort happens?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, it will be. I've added a comment explaining this, but I've left the check in anyway. In case something goes wrong earlier, we can still return an error here instead of crashing.

Comment on lines +397 to +398
// SourceProviderAddress is the address of the provider that the resource
// is being moved from.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Might be good to include these field-level comments in the protocol definition so it is more self-documenting. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

// SourceStateFlatmap is the legacy flatmap encoding.
// Only one of these fields may be set for the move request.
SourceStateJSON []byte
SourceStateFlatmap map[string]string
Copy link
Member

Choose a reason for hiding this comment

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

I would drop this field, as there's no way a new provider should ever see (or be equipped to deal with) the pre-v0.12 encoding

Copy link
Member Author

Choose a reason for hiding this comment

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

Done!

@liamcervante liamcervante force-pushed the liamcervante/cross-resource-move-protos branch from 92de399 to 3635724 Compare January 9, 2024 08:51
@liamcervante liamcervante requested a review from jbardin January 9, 2024 09:37
@liamcervante liamcervante merged commit 7d14338 into main Jan 11, 2024
4 checks passed
@liamcervante liamcervante deleted the liamcervante/cross-resource-move-protos branch January 11, 2024 09:08
Copy link
Contributor

Reminder for the merging maintainer: if this is a user-visible change, please update the changelog on the appropriate release branch.

Copy link
Contributor

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants