mirror of
				https://github.com/optim-enterprises-bv/vault.git
				synced 2025-10-29 17:52:32 +00:00 
			
		
		
		
	This reverts commit 4c8cc87794.
			
			
This commit is contained in:
		| @@ -40,7 +40,6 @@ import ( | ||||
| 	"github.com/hashicorp/vault/helper/builtinplugins" | ||||
| 	"github.com/hashicorp/vault/helper/constants" | ||||
| 	"github.com/hashicorp/vault/helper/experiments" | ||||
| 	"github.com/hashicorp/vault/helper/logging" | ||||
| 	loghelper "github.com/hashicorp/vault/helper/logging" | ||||
| 	"github.com/hashicorp/vault/helper/metricsutil" | ||||
| 	"github.com/hashicorp/vault/helper/namespace" | ||||
| @@ -121,7 +120,6 @@ type ServerCommand struct { | ||||
| 	licenseReloadedCh chan (error)    // for tests | ||||
|  | ||||
| 	allLoggers []hclog.Logger | ||||
| 	logging.SubloggerAdder | ||||
|  | ||||
| 	flagConfigs            []string | ||||
| 	flagRecovery           bool | ||||
| @@ -443,26 +441,6 @@ func (c *ServerCommand) parseConfig() (*server.Config, []configutil.ConfigError, | ||||
| 	return config, configErrors, nil | ||||
| } | ||||
|  | ||||
| // AppendToAllLoggers is registered with the base logger to handle creation of | ||||
| // new subloggers through the phases of server startup. There are three phases | ||||
| // we need to handle: (1) Before CoreConfig is created, new subloggers are added | ||||
| // to c.allLoggers; (2) After CoreConfig is created, new subloggers are added to | ||||
| // CoreConfig.AllLoggers; (3) After Core instantiation, new subloggers are | ||||
| // appended to Core.allLoggers. This logic is managed by the SubloggerAdder | ||||
| // interface. | ||||
| // | ||||
| // NOTE: Core.allLoggers must be set to CoreConfig.allLoggers after NewCore to | ||||
| // keep track of new subloggers added before c.SubloggerAdder gets reassigned to | ||||
| // the Core implementation. | ||||
| func (c *ServerCommand) AppendToAllLoggers(sub hclog.Logger) hclog.Logger { | ||||
| 	if c.SubloggerAdder == nil { | ||||
| 		c.allLoggers = append(c.allLoggers, sub) | ||||
| 		return sub | ||||
| 	} | ||||
|  | ||||
| 	return c.SubloggerHook(sub) | ||||
| } | ||||
|  | ||||
| func (c *ServerCommand) runRecoveryMode() int { | ||||
| 	config, configErrors, err := c.parseConfig() | ||||
| 	if err != nil { | ||||
| @@ -608,7 +586,6 @@ func (c *ServerCommand) runRecoveryMode() int { | ||||
| 		DisableMlock: config.DisableMlock, | ||||
| 		RecoveryMode: c.flagRecovery, | ||||
| 		ClusterAddr:  config.ClusterAddr, | ||||
| 		AllLoggers:   c.allLoggers, | ||||
| 	} | ||||
|  | ||||
| 	core, newCoreError := vault.NewCore(coreConfig) | ||||
| @@ -832,6 +809,7 @@ func (c *ServerCommand) setupStorage(config *server.Config) (physical.Backend, e | ||||
| 	} | ||||
|  | ||||
| 	namedStorageLogger := c.logger.Named("storage." + config.Storage.Type) | ||||
| 	c.allLoggers = append(c.allLoggers, namedStorageLogger) | ||||
| 	backend, err := factory(config.Storage.Config, namedStorageLogger) | ||||
| 	if err != nil { | ||||
| 		return nil, fmt.Errorf("Error initializing storage of type %s: %w", config.Storage.Type, err) | ||||
| @@ -847,6 +825,7 @@ func beginServiceRegistration(c *ServerCommand, config *server.Config) (sr.Servi | ||||
| 	} | ||||
|  | ||||
| 	namedSDLogger := c.logger.Named("service_registration." + config.ServiceRegistration.Type) | ||||
| 	c.allLoggers = append(c.allLoggers, namedSDLogger) | ||||
|  | ||||
| 	// Since we haven't even begun starting Vault's core yet, | ||||
| 	// we know that Vault is in its pre-running state. | ||||
| @@ -1125,6 +1104,7 @@ func (c *ServerCommand) Run(args []string) int { | ||||
|  | ||||
| 	// create GRPC logger | ||||
| 	namedGRPCLogFaker := c.logger.Named("grpclogfaker") | ||||
| 	c.allLoggers = append(c.allLoggers, namedGRPCLogFaker) | ||||
| 	grpclog.SetLogger(&grpclogFaker{ | ||||
| 		logger: namedGRPCLogFaker, | ||||
| 		log:    os.Getenv("VAULT_GRPC_LOGGING") != "", | ||||
| @@ -1277,10 +1257,6 @@ func (c *ServerCommand) Run(args []string) int { | ||||
| 		return c.enableThreeNodeDevCluster(&coreConfig, info, infoKeys, c.flagDevListenAddr, os.Getenv("VAULT_DEV_TEMP_DIR")) | ||||
| 	} | ||||
|  | ||||
| 	// Keep track of new subloggers in coreConfig.AllLoggers until we hand it | ||||
| 	// off to core | ||||
| 	c.SubloggerAdder = &coreConfig | ||||
|  | ||||
| 	if c.flagDevFourCluster { | ||||
| 		return enableFourClusterDev(c, &coreConfig, info, infoKeys, c.flagDevListenAddr, os.Getenv("VAULT_DEV_TEMP_DIR")) | ||||
| 	} | ||||
| @@ -1368,10 +1344,6 @@ func (c *ServerCommand) Run(args []string) int { | ||||
|  | ||||
| 	} | ||||
|  | ||||
| 	// Now we can use the core SubloggerHook to add any new subloggers to | ||||
| 	// core.allLoggers | ||||
| 	c.SubloggerAdder = core | ||||
|  | ||||
| 	// Copy the reload funcs pointers back | ||||
| 	c.reloadFuncs = coreConfig.ReloadFuncs | ||||
| 	c.reloadFuncsLock = coreConfig.ReloadFuncsLock | ||||
| @@ -1850,7 +1822,6 @@ func (c *ServerCommand) configureLogging(config *server.Config) (hclog.Intercept | ||||
| 		LogRotateDuration: logRotateDuration, | ||||
| 		LogRotateBytes:    config.LogRotateBytes, | ||||
| 		LogRotateMaxFiles: config.LogRotateMaxFiles, | ||||
| 		SubloggerHook:     c.AppendToAllLoggers, | ||||
| 	} | ||||
|  | ||||
| 	return loghelper.Setup(logCfg, c.logWriter) | ||||
| @@ -2558,6 +2529,7 @@ func setSeal(c *ServerCommand, config *server.Config, infoKeys []string, info ma | ||||
|  | ||||
| 		var seal vault.Seal | ||||
| 		sealLogger := c.logger.ResetNamed(fmt.Sprintf("seal.%s", sealType)) | ||||
| 		c.allLoggers = append(c.allLoggers, sealLogger) | ||||
| 		defaultSeal := vault.NewDefaultSeal(vaultseal.NewAccess(aeadwrapper.NewShamirWrapper())) | ||||
| 		var sealInfoKeys []string | ||||
| 		sealInfoMap := map[string]string{} | ||||
| @@ -2612,6 +2584,7 @@ func initHaBackend(c *ServerCommand, config *server.Config, coreConfig *vault.Co | ||||
| 		} | ||||
|  | ||||
| 		namedHALogger := c.logger.Named("ha." + config.HAStorage.Type) | ||||
| 		c.allLoggers = append(c.allLoggers, namedHALogger) | ||||
| 		habackend, err := factory(config.HAStorage.Config, namedHALogger) | ||||
| 		if err != nil { | ||||
| 			return false, fmt.Errorf("Error initializing HA storage of type %s: %s", config.HAStorage.Type, err) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Hamid Ghaf
					Hamid Ghaf