Skip to content

Commit c98132d

Browse files
authored
Merge pull request #948 from 09harsh/flag_disabling_no_wait_excludes
Flag for enabling no-wait excludes
2 parents 0025b3f + be1ca3f commit c98132d

File tree

7 files changed

+65
-7
lines changed

7 files changed

+65
-7
lines changed

api/v1beta1/foundationdb_version.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,8 @@ func (version FdbVersion) HasZoneFaultToleranceInStatus() bool {
155155

156156
// HasNonBlockingExcludes determines if a version has support for non-blocking
157157
// exclude commands.
158-
//
159-
// This is currently set to false across the board, pending investigation into
160-
// potential bugs with non-blocking excludes.
161-
func (version FdbVersion) HasNonBlockingExcludes() bool {
162-
return false
158+
func (version FdbVersion) HasNonBlockingExcludes(useNonBlockingExcludes bool) bool {
159+
return version.IsAtLeast(FdbVersion{Major: 6, Minor: 3, Patch: 5}) && useNonBlockingExcludes
163160
}
164161

165162
// NextMajorVersion returns the next major version of FoundationDB.

api/v1beta1/foundationdb_version_test.go

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ package v1beta1
2222

2323
import (
2424
. "github.com/onsi/ginkgo"
25+
. "github.com/onsi/ginkgo/extensions/table"
2526
. "github.com/onsi/gomega"
2627
)
2728

@@ -91,4 +92,43 @@ var _ = Describe("[api] FDBVersion", func() {
9192
Expect(version.Equal(FdbVersion{Major: 6, Minor: 2, Patch: 21})).To(BeFalse())
9293
})
9394
})
95+
96+
When("checking if the version has support for non-blocking exclude commands", func() {
97+
type testCase struct {
98+
version FdbVersion
99+
useNonBlockingExcludes bool
100+
expectedResult bool
101+
}
102+
103+
DescribeTable("should return if non-blocking excludes are enabled",
104+
func(tc testCase) {
105+
Expect(tc.version.HasNonBlockingExcludes(tc.useNonBlockingExcludes)).To(Equal(tc.expectedResult))
106+
},
107+
Entry("When version is below 6.3.5 and useNonBlockingExcludes is false",
108+
testCase{
109+
version: FdbVersion{Major: 6, Minor: 3, Patch: 0},
110+
useNonBlockingExcludes: false,
111+
expectedResult: false,
112+
}),
113+
Entry("When version is below 6.3.5 and useNonBlockingExcludes is true",
114+
testCase{
115+
version: FdbVersion{Major: 6, Minor: 3, Patch: 0},
116+
useNonBlockingExcludes: false,
117+
expectedResult: false,
118+
}),
119+
Entry("When version is atleast 6.3.5 and useNonBlockingExcludes is false",
120+
testCase{
121+
version: FdbVersion{Major: 6, Minor: 3, Patch: 5},
122+
useNonBlockingExcludes: false,
123+
expectedResult: false,
124+
}),
125+
Entry("When version is atleast 6.3.5 and useNonBlockingExcludes is true",
126+
testCase{
127+
version: FdbVersion{Major: 6, Minor: 3, Patch: 6},
128+
useNonBlockingExcludes: true,
129+
expectedResult: true,
130+
}),
131+
)
132+
133+
})
94134
})

api/v1beta1/foundationdbcluster_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,6 +1108,10 @@ type FoundationDBClusterAutomationOptions struct {
11081108
// Defaults to true.
11091109
// Deprecated: Will be enforced by default in 1.0.0 without disabling.
11101110
EnforceFullReplicationForDeletion *bool `json:"enforceFullReplicationForDeletion,omitempty"`
1111+
1112+
// UseNonBlockingExcludes defines whether the operator is allowed to use non blocking exclude commands.
1113+
// The default is false.
1114+
UseNonBlockingExcludes *bool `json:"useNonBlockingExcludes,omitempty"`
11111115
}
11121116

11131117
// AutomaticReplacementOptions controls options for automatically replacing
@@ -2924,6 +2928,15 @@ func (cluster *FoundationDBCluster) GetEnforceFullReplicationForDeletion() bool
29242928
return *cluster.Spec.AutomationOptions.EnforceFullReplicationForDeletion
29252929
}
29262930

2931+
// GetUseNonBlockingExcludes returns the value of useNonBlockingExcludes or false if unset.
2932+
func (cluster *FoundationDBCluster) GetUseNonBlockingExcludes() bool {
2933+
if cluster.Spec.AutomationOptions.UseNonBlockingExcludes == nil {
2934+
return false
2935+
}
2936+
2937+
return *cluster.Spec.AutomationOptions.UseNonBlockingExcludes
2938+
}
2939+
29272940
// GetProcessClassLabel provides the label that this cluster is using for the
29282941
// process class when identifying resources.
29292942
func (cluster *FoundationDBCluster) GetProcessClassLabel() string {

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/apps.foundationdb.org_foundationdbclusters.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ spec:
7676
minimum: 0
7777
type: integer
7878
type: object
79+
useNonBlockingExcludes:
80+
type: boolean
7981
type: object
8082
automountServiceAccountToken:
8183
type: boolean

docs/cluster_spec.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ FoundationDBClusterAutomationOptions provides flags for enabling or disabling op
191191
| replacements | Replacements contains options for automatically replacing failed processes. | [AutomaticReplacementOptions](#automaticreplacementoptions) | false |
192192
| ignorePendingPodsDuration | IgnorePendingPodsDuration defines how long a Pod has to be in the Pending Phase before ignore it during reconciliation. This prevents Pod that are stuck in Pending to block further reconciliation. | time.Duration | false |
193193
| enforceFullReplicationForDeletion | EnforceFullReplicationForDeletion defines if the operator is only allowed to delete Pods if the cluster is fully replicated. If the cluster is not fully replicated the Operator won't delete any Pods that are marked for removal. Defaults to true. **Deprecated: Will be enforced by default in 1.0.0 without disabling.** | *bool | false |
194+
| useNonBlockingExcludes | UseNonBlockingExcludes defines whether the operator is allowed to use non blocking exclude commands. The default is false. | *bool | false |
194195

195196
[Back to TOC](#table-of-contents)
196197

fdbclient/admin_client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ func (client *cliAdminClient) ExcludeInstances(addresses []fdbtypes.ProcessAddre
237237
return err
238238
}
239239

240-
if version.HasNonBlockingExcludes() {
240+
if version.HasNonBlockingExcludes(client.Cluster.GetUseNonBlockingExcludes()) {
241241
_, err = client.runCommand(cliCommand{
242242
command: fmt.Sprintf(
243243
"exclude no_wait %s",
@@ -299,7 +299,7 @@ func (client *cliAdminClient) CanSafelyRemove(addresses []fdbtypes.ProcessAddres
299299
return nil, err
300300
}
301301

302-
if version.HasNonBlockingExcludes() {
302+
if version.HasNonBlockingExcludes(client.Cluster.GetUseNonBlockingExcludes()) {
303303
output, err := client.runCommand(cliCommand{command: fmt.Sprintf(
304304
"exclude no_wait %s",
305305
fdbtypes.ProcessAddressesString(addresses, " "),

0 commit comments

Comments
 (0)