Bring in safe mode support (#8478)

This PR refactors object layer handling such
that upon failure in sub-system initialization
server reaches a stage of safe-mode operation
wherein only certain API operations are enabled
and available.

This allows for fixing many scenarios such as

 - incorrect configuration in vault, etcd,
   notification targets
 - missing files, incomplete config migrations
   unable to read encrypted content etc
 - any other issues related to notification,
   policies, lifecycle etc
This commit is contained in:
Harshavardhana
2019-11-09 09:27:23 -08:00
committed by kannappanr
parent 1c90a6bd49
commit 822eb5ddc7
41 changed files with 1129 additions and 830 deletions

View File

@@ -15,7 +15,6 @@
package crypto
import (
"fmt"
"testing"
)
@@ -23,17 +22,17 @@ var verifyVaultConfigTests = []struct {
Config VaultConfig
ShouldFail bool
}{
{
ShouldFail: false, // 0
Config: emptyVaultConfig,
},
{
ShouldFail: true,
Config: VaultConfig{Endpoint: "https://127.0.0.1:8080"},
Config: VaultConfig{
Endpoint: "https://127.0.0.1:8080",
Enabled: true,
},
},
{
ShouldFail: true, // 1
Config: VaultConfig{
Enabled: true,
Endpoint: "https://127.0.0.1:8080",
Auth: VaultAuth{Type: "unsupported"},
},
@@ -41,6 +40,7 @@ var verifyVaultConfigTests = []struct {
{
ShouldFail: true, // 2
Config: VaultConfig{
Enabled: true,
Endpoint: "https://127.0.0.1:8080",
Auth: VaultAuth{
Type: "approle",
@@ -51,6 +51,7 @@ var verifyVaultConfigTests = []struct {
{
ShouldFail: true, // 3
Config: VaultConfig{
Enabled: true,
Endpoint: "https://127.0.0.1:8080",
Auth: VaultAuth{
Type: "approle",
@@ -61,6 +62,7 @@ var verifyVaultConfigTests = []struct {
{
ShouldFail: true, // 4
Config: VaultConfig{
Enabled: true,
Endpoint: "https://127.0.0.1:8080",
Auth: VaultAuth{
Type: "approle",
@@ -71,6 +73,7 @@ var verifyVaultConfigTests = []struct {
{
ShouldFail: true, // 5
Config: VaultConfig{
Enabled: true,
Endpoint: "https://127.0.0.1:8080",
Auth: VaultAuth{
Type: "approle",
@@ -82,9 +85,9 @@ var verifyVaultConfigTests = []struct {
}
func TestVerifyVaultConfig(t *testing.T) {
for i, test := range verifyVaultConfigTests {
for _, test := range verifyVaultConfigTests {
test := test
t.Run(fmt.Sprintf("Test-%d", i), func(t *testing.T) {
t.Run(test.Config.Endpoint, func(t *testing.T) {
err := test.Config.Verify()
if test.ShouldFail && err == nil {
t.Errorf("Verify should fail but returned 'err == nil'")