Skip to content

Commit

Permalink
Fix role counts for versions prior to 7.0 (#1142)
Browse files Browse the repository at this point in the history
* Fix role counts for versions prior to 7.0
  • Loading branch information
johscheuer authored Mar 28, 2022
1 parent 18f9c18 commit 5532b11
Show file tree
Hide file tree
Showing 6 changed files with 934 additions and 417 deletions.
16 changes: 9 additions & 7 deletions api/v1beta2/foundationdb_database_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ func (configuration DatabaseConfiguration) getRegion(id string, priority int) Re
// The default LogRouters value will be equal to 3 times the Logs value when
// the UsableRegions is greater than 1. It will be equal to -1 when the
// UsableRegions is less than or equal to 1.
func (configuration *DatabaseConfiguration) GetRoleCountsWithDefaults(faultTolerance int) RoleCounts {
func (configuration *DatabaseConfiguration) GetRoleCountsWithDefaults(version Version, faultTolerance int) RoleCounts {
counts := configuration.RoleCounts.DeepCopy()
if counts.Storage == 0 {
counts.Storage = 2*faultTolerance + 1
Expand All @@ -247,11 +247,13 @@ func (configuration *DatabaseConfiguration) GetRoleCountsWithDefaults(faultToler
if counts.Proxies == 0 {
counts.Proxies = 3
}
if counts.CommitProxies == 0 {
counts.CommitProxies = 2
}
if counts.GrvProxies == 0 {
counts.GrvProxies = 1
if version.HasSeparatedProxies() {
if counts.CommitProxies == 0 {
counts.CommitProxies = 2
}
if counts.GrvProxies == 0 {
counts.GrvProxies = 1
}
}
if counts.Resolvers == 0 {
counts.Resolvers = 1
Expand Down Expand Up @@ -528,7 +530,7 @@ func (configuration DatabaseConfiguration) AreSeparatedProxiesConfigured() bool
// "proxies=%d" using the correct counts of the configuration object.
//
func (configuration DatabaseConfiguration) GetProxiesString(version Version) string {
counts := configuration.GetRoleCountsWithDefaults(DesiredFaultTolerance(configuration.RedundancyMode))
counts := configuration.GetRoleCountsWithDefaults(version, DesiredFaultTolerance(configuration.RedundancyMode))
if version.HasSeparatedProxies() && configuration.AreSeparatedProxiesConfigured() {
return fmt.Sprintf(" commit_proxies=%d grv_proxies=%d", counts.CommitProxies, counts.GrvProxies)
}
Expand Down
6 changes: 4 additions & 2 deletions api/v1beta2/foundationdbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,9 @@ func (cluster *FoundationDBCluster) GetProcessSettings(processClass ProcessClass
// the UsableRegions is greater than 1. It will be equal to -1 when the
// UsableRegions is less than or equal to 1.
func (cluster *FoundationDBCluster) GetRoleCountsWithDefaults() RoleCounts {
return cluster.Spec.DatabaseConfiguration.GetRoleCountsWithDefaults(cluster.DesiredFaultTolerance())
// We can ignore the error here since the version will be validated in an earlier step.
version, _ := ParseFdbVersion(cluster.Spec.Version)
return cluster.Spec.DatabaseConfiguration.GetRoleCountsWithDefaults(version, cluster.DesiredFaultTolerance())
}

// calculateProcessCount determines the process count from a given role count.
Expand Down Expand Up @@ -1158,7 +1160,7 @@ func (cluster *FoundationDBCluster) CheckReconciliation(log logr.Logger) (bool,

desiredConfiguration := cluster.DesiredDatabaseConfiguration()
if !equality.Semantic.DeepEqual(cluster.Status.DatabaseConfiguration, desiredConfiguration) {
logger.Info("Pending database configuration change", "state", "NeedsConfigurationChange")
logger.Info("Pending database configuration change", "state", "NeedsConfigurationChange", "current", cluster.Status.DatabaseConfiguration, "desired", desiredConfiguration)
cluster.Status.Generations.NeedsConfigurationChange = cluster.ObjectMeta.Generation
reconciled = false
}
Expand Down
Loading

0 comments on commit 5532b11

Please sign in to comment.