-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ETCD-519:Add reconcile etcd database size (#1248)
* ETCD-519:Add reconcile etcd database size * bump openshift/api deps * fix verify deps * add featureGate accessor * sorting imports * fix fmt
- Loading branch information
Showing
57 changed files
with
5,181 additions
and
1,471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package backendquotahelpers | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates" | ||
) | ||
|
||
const BackendQuotaFeatureGateName = "EtcdBackendQuota" | ||
|
||
func IsBackendQuotaFeatureGateEnabled(featureGateAccessor featuregates.FeatureGateAccess) (bool, error) { | ||
gates, err := featureGateAccessor.CurrentFeatureGates() | ||
if err != nil { | ||
return false, fmt.Errorf("could not access feature gates, error was: %w", err) | ||
} | ||
|
||
return gates.Enabled(BackendQuotaFeatureGateName), nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package backendquotahelpers | ||
|
||
import ( | ||
"testing" | ||
|
||
configv1 "github.com/openshift/api/config/v1" | ||
"github.com/openshift/library-go/pkg/operator/configobserver/featuregates" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestBackendQuotaFeatureGateEnabled(t *testing.T) { | ||
backendQuotaFeatureGateAccessor := featuregates.NewHardcodedFeatureGateAccess( | ||
[]configv1.FeatureGateName{BackendQuotaFeatureGateName}, | ||
[]configv1.FeatureGateName{}) | ||
enabled, err := IsBackendQuotaFeatureGateEnabled(backendQuotaFeatureGateAccessor) | ||
require.True(t, enabled) | ||
require.NoError(t, err) | ||
} | ||
|
||
func TestBackendQuotaFeatureGateDisabled(t *testing.T) { | ||
backendQuotaFeatureGateAccessor := featuregates.NewHardcodedFeatureGateAccess( | ||
[]configv1.FeatureGateName{}, | ||
[]configv1.FeatureGateName{BackendQuotaFeatureGateName}) | ||
enabled, err := IsBackendQuotaFeatureGateEnabled(backendQuotaFeatureGateAccessor) | ||
require.False(t, enabled) | ||
require.NoError(t, err) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package etcdenvvar | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestConvertDBSize(t *testing.T) { | ||
testCases := []struct { | ||
name string | ||
input int64 | ||
exp string | ||
}{ | ||
{ | ||
name: "1 GB", | ||
input: 1, | ||
exp: "1073741824", | ||
}, | ||
{ | ||
name: "8 GB", | ||
input: 8, | ||
exp: "8589934592", | ||
}, | ||
{ | ||
name: "16 GB", | ||
input: 16, | ||
exp: "17179869184", | ||
}, | ||
{ | ||
name: "32 GB", | ||
input: 32, | ||
exp: "34359738368", | ||
}, | ||
{ | ||
name: "64 GB", | ||
input: 64, | ||
exp: "68719476736", | ||
}, | ||
} | ||
|
||
for _, tc := range testCases { | ||
t.Run(tc.name, func(t *testing.T) { | ||
assert.Equal(t, tc.exp, GibibytesToBytesString(tc.input)) | ||
}) | ||
} | ||
} |
Oops, something went wrong.