Skip to content

Set current CompatibilityInfo outside of driver_lib #2478

@serbel324

Description

@serbel324

How it works now:

Information about compatibility is stored in the form of protobuf in a global object CompatibilityInfo of type TCompatibilityInfo:
https://github.com/ydb-platform/ydb/blob/main/ydb/core/driver_lib/version/version.h#L169
To change the compatibility information for binary we need to change the constructor:
https://github.com/ydb-platform/ydb/blob/stable-23-3/ydb/core/driver_lib/version/version.cpp#L27

The problem with this approach is that NBS uses YDB code by directly linking it without copying or modifying, therefore, in their binary the compatibility information remains the same as in arcadia/ydb.

What is proposed:

We propose to move the construction of the current compatibility information into a separate function and define this function in a separate source file, differing for NBS and YDB. This can be main.cpp or some new file.

How it would look with the main.cpp option:

ydb/core/driver_lib/version/version.cpp

...

TCompatibilityInfo::TCompatibilityInfo() {
    ...

    auto current = MakeCurrentCompatiblityInfo();

    ...
}

...

ydb/apps/ydbd/main.cpp

...

#include <ydb/core/driver_lib/version.h>

...

NKikimrConfig::TCurrentCompatibilityInfo TCompatibilityInfo::MakeCurrentCompatiblityInfo() {
    using TCurrentConstructor = TCompatibilityInfo::TProtoConstructor::TCurrentCompatibilityInfo;
    using TVersionConstructor = TCompatibilityInfo::TProtoConstructor::TVersion;

    return TCurrentConstructor{
        .Application = "ydb",
        .Version = TVersionConstructor{
            .Year = 23,
            .Major = 3,
        }
    }.ToPB();
}

...

cloud/blockstore/apps/server/main.cpp
and
cloud/filestore/apps/server/main.cpp


...

#include <ydb/core/driver_lib/version.h>

...

NKikimrConfig::TCurrentCompatibilityInfo TCompatibilityInfo::MakeCurrentCompatiblityInfo() {
    using TCurrentConstructor = TCompatibilityInfo::TProtoConstructor::TCurrentCompatibilityInfo;
    using TVersionConstructor = TCompatibilityInfo::TProtoConstructor::TVersion;

    return TCurrentConstructor{
        .Application = "nbs",
        .Version = TVersionConstructor{
            .Year = 23,
            .Major = 3,
        }
    }.ToPB();
}

...

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions