Skip to content

Annotate proto messages with version and detect etcd version generated the wal#13216

Merged
ptabor merged 1 commit intoetcd-io:mainfrom
serathius:wal
Aug 6, 2021
Merged

Annotate proto messages with version and detect etcd version generated the wal#13216
ptabor merged 1 commit intoetcd-io:mainfrom
serathius:wal

Conversation

@serathius
Copy link
Member

@serathius serathius commented Jul 14, 2021

Implements annotations as part of #13168

This PR introduces custom proto annotations etcd_version_msg, etcd_version_field, etcd_version_enum, etcd_version_enum_value.

They will be used to indicate which version a specific field/message/enum etc was introduced, and will be used during downgrade to check compatibility. For example when downgrading storage to v3.5 we should make sure wal doesn't include any message or sets any field from v3.6+. As result we can be sure that WAL will be correctly interpreted by older version.

Notes to reviewer:

@serathius serathius force-pushed the wal branch 2 times, most recently from 22b26c1 to b52a31d Compare July 14, 2021 11:07
@serathius serathius changed the title Wal Annotate proto messages with version and detect etcd version generated the wal Jul 14, 2021
@serathius serathius mentioned this pull request Jul 14, 2021
13 tasks
@serathius serathius force-pushed the wal branch 3 times, most recently from 3d661c6 to 3917301 Compare July 14, 2021 13:50
@serathius serathius requested a review from ptabor July 14, 2021 13:51
@serathius
Copy link
Member Author

cc @lilic

Copy link
Contributor

@lilic lilic left a comment

Choose a reason for hiding this comment

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

Couple of initial questions haven't looked at the wal code yet.

membershippb.ClusterVersionSetRequest cluster_version_set = 1300;
membershippb.ClusterMemberAttrSetRequest cluster_member_attr_set = 1301;
membershippb.DowngradeInfoSetRequest downgrade_info_set = 1302;
membershippb.ClusterVersionSetRequest cluster_version_set = 1300 [(versionpb.etcd_version_field) = "3.5"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Just trying to understand, will these changes need to be backported to 3.5 release as well? Would this create any compatibility issues?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, storage downgrade is done by older binaries. It's enough to have those annotations in v3.6, so it can verify the WAL and mark it as v3.5 compatible. v3.5 doesn't need to now about annotations.

AuthEnableRequest auth_enable = 1000;
AuthDisableRequest auth_disable = 1011;
AuthStatusRequest auth_status = 1013;
AuthStatusRequest auth_status = 1013 [(versionpb.etcd_version_field) = "3.5"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you have to manually write these versions, if so will they change in future release will we have to keep bumping them?

Copy link
Member Author

Choose a reason for hiding this comment

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

No need to bump them, those annotations indicate etcd version that introduced the specific field/message. However any new message/field added after this change should include those annotations.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for that.

However any new message/field added after this change should include those annotations.

is this enforced in any way? e.g. with tests or failure of proto generation?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to enforcing.
If we had no 'message level annotations', it would be easier to enforce no fields without an annotation
in the transitive proto-descriptor.

Copy link
Member Author

Choose a reason for hiding this comment

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

Enforcing is definitely in the plan. It might be a little harder to implement with message and enum annotations, but it should be possible if we introduce allowlisting (enforcer will require always message version set, but for fields only if they are not in allow list maintained by enforcer).

Decided on splitting message vs field and enum vs enum value based on:

  • Enum default value (equal 0) will never be considered set, so annotating it doesn't make sense. It can be also confusing as someone might think that setting this enum value will mean that required etcd version is changed, but it's not.
  • Messages with no fields, for example AuthStatusRequest. We technically can determine the version based on field annotation that uses this message, but I think it might become confusing when we will add some fields to this message. Decided that messages should be self sufficient to define their etcd version.
  • Readability, having this annotation on each and every field makes the proto much less readable. I would prefer to keep the proto definition cleaner and even if the enforces will be more complicated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Enforcing of the version is not done to all the proto files, like lease.proto doesn't have it, so how do we determine going forward which require a version field in a tested way?

Copy link
Member Author

Choose a reason for hiding this comment

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

For storage versioning we just need to ensure that protos used in WAL have annotations. This means that we should look for all submessages from raftpb.Entry as a root. We might consider expanding this to all proto if that would useful for other purposes.

AuthEnableRequest auth_enable = 1000;
AuthDisableRequest auth_disable = 1011;
AuthStatusRequest auth_status = 1013;
AuthStatusRequest auth_status = 1013 [(versionpb.etcd_version_field) = "3.5"];
Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to enforcing.
If we had no 'message level annotations', it would be easier to enforce no fields without an annotation
in the transitive proto-descriptor.

@serathius serathius force-pushed the wal branch 2 times, most recently from da1f4e1 to bdaebb0 Compare July 16, 2021 12:17
@serathius
Copy link
Member Author

serathius commented Jul 19, 2021

Addressed/responded on all issues. PTAL

Copy link
Contributor

@lilic lilic left a comment

Choose a reason for hiding this comment

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

Mainly reviewed as I was re-reading the storage versioning design doc.

AuthEnableRequest auth_enable = 1000;
AuthDisableRequest auth_disable = 1011;
AuthStatusRequest auth_status = 1013;
AuthStatusRequest auth_status = 1013 [(versionpb.etcd_version_field) = "3.5"];
Copy link
Contributor

Choose a reason for hiding this comment

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

Enforcing of the version is not done to all the proto files, like lease.proto doesn't have it, so how do we determine going forward which require a version field in a tested way?

@serathius serathius force-pushed the wal branch 3 times, most recently from de6d681 to 5d3d98c Compare July 30, 2021 12:08
@serathius serathius force-pushed the wal branch 4 times, most recently from bf11d4f to f36eec0 Compare August 4, 2021 11:29
…enerated wal

Co-authored-by: Lili Cosic <cosiclili@gmail.com>
@ptabor ptabor merged commit 873f369 into etcd-io:main Aug 6, 2021
@serathius serathius deleted the wal branch June 15, 2023 20:36
@alxn
Copy link

alxn commented Jul 8, 2025

For now I used unassigned proto field numbers, those should be replaced with official ones

Any update on this ?

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants