|
6 | 6 | package sql |
7 | 7 |
|
8 | 8 | import ( |
| 9 | + "cmp" |
9 | 10 | "context" |
10 | 11 | gojson "encoding/json" |
11 | 12 | "fmt" |
12 | 13 | "math" |
| 14 | + "slices" |
13 | 15 | "strings" |
14 | 16 | "time" |
15 | 17 |
|
@@ -170,16 +172,30 @@ func BootstrapTenant( |
170 | 172 | // cluster's bootstrapping logic. |
171 | 173 | tenantVersion.Version = clusterversion.Latest.Version() |
172 | 174 | bootstrapVersionOverride = 0 |
173 | | - case execCfg.Settings.Version.IsActive(ctx, clusterversion.PreviousRelease): |
174 | | - // If the previous major version is active, use that version to create the |
175 | | - // tenant and bootstrap it just like the previous major version binary |
176 | | - // would, using hardcoded initial values. |
177 | | - tenantVersion.Version = clusterversion.PreviousRelease.Version() |
178 | | - bootstrapVersionOverride = clusterversion.PreviousRelease |
179 | 175 | default: |
180 | | - // Otherwise, use the initial values from the min supported version. |
181 | | - tenantVersion.Version = clusterversion.MinSupported.Version() |
182 | | - bootstrapVersionOverride = clusterversion.MinSupported |
| 176 | + // Iterate through supported previous releases in reverse order to find the |
| 177 | + // appropriate bootstrap version. |
| 178 | + supportedReleases := clusterversion.SupportedPreviousReleases() |
| 179 | + |
| 180 | + // Sort to ensure proper ordering (should already be sorted, but being safe). |
| 181 | + slices.SortFunc(supportedReleases, func(a, b clusterversion.Key) int { |
| 182 | + return cmp.Compare(a, b) |
| 183 | + }) |
| 184 | + |
| 185 | + // If no supported release is active, fall back to min supported version. |
| 186 | + // This should not happen in practice. |
| 187 | + foundVersion := clusterversion.MinSupported |
| 188 | + for i := len(supportedReleases) - 1; i >= 0; i-- { |
| 189 | + k := supportedReleases[i] |
| 190 | + if execCfg.Settings.Version.IsActive(ctx, k) { |
| 191 | + // Use the highest active supported release to create the tenant and |
| 192 | + // bootstrap it with the hardcoded initial values for that version. |
| 193 | + foundVersion = k |
| 194 | + break |
| 195 | + } |
| 196 | + } |
| 197 | + tenantVersion.Version = foundVersion.Version() |
| 198 | + bootstrapVersionOverride = foundVersion |
183 | 199 | } |
184 | 200 |
|
185 | 201 | initialValuesOpts := bootstrap.InitialValuesOpts{ |
|
0 commit comments