Skip to content

Update the compatibility check for multiple newer versions #2329

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 33 additions & 37 deletions controllers/check_client_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,16 @@ func (c checkClientCompatibility) reconcile(
}
}

protocolVersion, err := adminClient.GetProtocolVersion(cluster.Spec.Version)
if err != nil {
return &requeue{curError: err}
}

ignoredLogGroups := make(map[fdbv1beta2.LogGroup]fdbv1beta2.None)
for _, logGroup := range cluster.GetIgnoreLogGroupsForUpgrade() {
ignoredLogGroups[logGroup] = fdbv1beta2.None{}
}

unsupportedClients := getUnsupportedClients(status, protocolVersion, ignoredLogGroups)
unsupportedClients, err := getUnsupportedClients(status, cluster.Spec.Version, ignoredLogGroups)
if err != nil {
return &requeue{curError: err}
}

if len(unsupportedClients) > 0 {
message := fmt.Sprintf(
"%d clients do not support version %s: %s", len(unsupportedClients),
Expand All @@ -117,32 +116,45 @@ func (c checkClientCompatibility) reconcile(
return nil
}

// foundationDBClient represents a client of the FoundationDBCluster
type foundationDBClient struct {
// description represents the client description.
description string
// supportedVersions is a map of all supported versions of this client.
supportedVersions map[string]fdbv1beta2.None
}

// getUnsupportedClients check if all clients supports at least the target version. If a process supports a newer version than
// the target version, then the assumption is that the client also supports the older version, including the target version.
// Other checks could fail because the FDB cluster only maintains a list of samples for the client information, that list
// has an upper limit on how many samples will be tracked. Each list for a specific version has its own limit, so it's
// possible that clients are in different lists.
func getUnsupportedClients(
status *fdbv1beta2.FoundationDBStatus,
protocolVersion string,
targetVersion string,
ignoredLogGroups map[fdbv1beta2.LogGroup]fdbv1beta2.None,
) []string {
) ([]string, error) {
var unsupportedClients []string

processAddresses := map[string]fdbv1beta2.None{}
for _, process := range status.Cluster.Processes {
processAddresses[process.Address.MachineAddress()] = fdbv1beta2.None{}
}

var unsupportedClients []string
clientSupportedVersions := map[string]*foundationDBClient{}
version, err := fdbv1beta2.ParseFdbVersion(targetVersion)
if err != nil {
return nil, err
}

for _, versionInfo := range status.Cluster.Clients.SupportedVersions {
if versionInfo.ProtocolVersion == "Unknown" {
continue
}

for _, client := range versionInfo.ConnectedClients {
clientVersion, err := fdbv1beta2.ParseFdbVersion(versionInfo.ClientVersion)
if err != nil {
return nil, err
}

// If the version is protocol compatible or newer than the targeted version, then the current client
// supports the targeted version.
if clientVersion.IsProtocolCompatible(version) || clientVersion.IsAtLeast(version) {
continue
}

for _, client := range versionInfo.MaxProtocolClients {
if _, ok := ignoredLogGroups[client.LogGroup]; ok {
continue
}
Expand All @@ -160,25 +172,9 @@ func getUnsupportedClients(
continue
}

if currentClient, ok := clientSupportedVersions[addr.String()]; ok {
currentClient.supportedVersions[versionInfo.ProtocolVersion] = fdbv1beta2.None{}
} else {
clientSupportedVersions[addr.String()] = &foundationDBClient{
description: client.Description(),
supportedVersions: map[string]fdbv1beta2.None{
versionInfo.ProtocolVersion: {},
},
}
}
}
}

// Validate for all clients that they support the requested version.
for _, client := range clientSupportedVersions {
if _, ok := client.supportedVersions[protocolVersion]; !ok {
unsupportedClients = append(unsupportedClients, client.description)
unsupportedClients = append(unsupportedClients, client.Description())
}
}

return unsupportedClients
return unsupportedClients, nil
}
5 changes: 4 additions & 1 deletion controllers/check_client_compatibility_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ var _ = Describe("check client compatibility", func() {
})

JustBeforeEach(func() {
unsupportedClients = getUnsupportedClients(status, "fdb00b063010001", ignoredLogGroups)
var err error
unsupportedClients, err = getUnsupportedClients(status, "6.3.15", ignoredLogGroups)
Expect(err).NotTo(HaveOccurred())
})

AfterEach(func() {
Expand Down Expand Up @@ -349,6 +351,7 @@ var _ = Describe("check client compatibility", func() {
})
})

// todo come up with some additional tests?
When("the status contains newer versions and the desired version is present", func() {
BeforeEach(func() {
status = &fdbv1beta2.FoundationDBStatus{
Expand Down