Browse Source

Added loadSecurityConfigOnce (#5792)

pull/4462/merge
vadimartynov 5 months ago
committed by GitHub
parent
commit
b796c21fa9
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 2
      unmaintained/diff_volume_servers/diff_volume_servers.go
  2. 2
      unmaintained/repeated_vacuum/repeated_vacuum.go
  3. 2
      unmaintained/stream_read_volume/stream_read_volume.go
  4. 2
      unmaintained/volume_tailer/volume_tailer.go
  5. 2
      weed/command/backup.go
  6. 2
      weed/command/benchmark.go
  7. 2
      weed/command/download.go
  8. 2
      weed/command/filer.go
  9. 2
      weed/command/filer_backup.go
  10. 2
      weed/command/filer_cat.go
  11. 2
      weed/command/filer_copy.go
  12. 2
      weed/command/filer_meta_backup.go
  13. 2
      weed/command/filer_meta_tail.go
  14. 2
      weed/command/filer_remote_gateway.go
  15. 2
      weed/command/filer_remote_sync.go
  16. 2
      weed/command/filer_replication.go
  17. 2
      weed/command/filer_sync.go
  18. 2
      weed/command/iam.go
  19. 2
      weed/command/master.go
  20. 2
      weed/command/master_follower.go
  21. 2
      weed/command/mount_std.go
  22. 2
      weed/command/mq_broker.go
  23. 2
      weed/command/s3.go
  24. 2
      weed/command/server.go
  25. 2
      weed/command/shell.go
  26. 2
      weed/command/upload.go
  27. 2
      weed/command/volume.go
  28. 2
      weed/command/webdav.go
  29. 7
      weed/util/config.go

2
unmaintained/diff_volume_servers/diff_volume_servers.go

@ -41,7 +41,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
vid := uint32(*volumeId) vid := uint32(*volumeId)

2
unmaintained/repeated_vacuum/repeated_vacuum.go

@ -26,7 +26,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
genFile(grpcDialOption, 0) genFile(grpcDialOption, 0)

2
unmaintained/stream_read_volume/stream_read_volume.go

@ -24,7 +24,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
vid := uint32(*volumeId) vid := uint32(*volumeId)

2
unmaintained/volume_tailer/volume_tailer.go

@ -25,7 +25,7 @@ var (
func main() { func main() {
flag.Parse() flag.Parse()
util2.LoadConfiguration("security", false)
util2.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util2.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util2.GetViper(), "grpc.client")
vid := needle.VolumeId(*volumeId) vid := needle.VolumeId(*volumeId)

2
weed/command/backup.go

@ -66,7 +66,7 @@ var cmdBackup = &Command{
func runBackup(cmd *Command, args []string) bool { func runBackup(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
if *s.volumeId == -1 { if *s.volumeId == -1 {

2
weed/command/benchmark.go

@ -111,7 +111,7 @@ var (
func runBenchmark(cmd *Command, args []string) bool { func runBenchmark(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
b.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client") b.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH) fmt.Printf("This is SeaweedFS version %s %s %s\n", util.Version(), runtime.GOOS, runtime.GOARCH)

2
weed/command/download.go

@ -47,7 +47,7 @@ var cmdDownload = &Command{
} }
func runDownload(cmd *Command, args []string) bool { func runDownload(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
for _, fid := range args { for _, fid := range args {

2
weed/command/filer.go

@ -178,7 +178,7 @@ func runFiler(cmd *Command, args []string) bool {
go http.ListenAndServe(fmt.Sprintf(":%d", *f.debugPort), nil) go http.ListenAndServe(fmt.Sprintf(":%d", *f.debugPort), nil)
} }
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
switch { switch {
case *f.metricsHttpIp != "": case *f.metricsHttpIp != "":

2
weed/command/filer_backup.go

@ -59,7 +59,7 @@ var cmdFilerBackup = &Command{
func runFilerBackup(cmd *Command, args []string) bool { func runFilerBackup(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
util.LoadConfiguration("replication", true) util.LoadConfiguration("replication", true)
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")

2
weed/command/filer_cat.go

@ -59,7 +59,7 @@ var cmdFilerCat = &Command{
func runFilerCat(cmd *Command, args []string) bool { func runFilerCat(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
if len(args) == 0 { if len(args) == 0 {
return false return false

2
weed/command/filer_copy.go

@ -83,7 +83,7 @@ var cmdFilerCopy = &Command{
func runCopy(cmd *Command, args []string) bool { func runCopy(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
if len(args) <= 1 { if len(args) <= 1 {
return false return false

2
weed/command/filer_meta_backup.go

@ -56,7 +56,7 @@ The backup writes to another filer store specified in a backup_filer.toml.
func runFilerMetaBackup(cmd *Command, args []string) bool { func runFilerMetaBackup(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
metaBackup.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client") metaBackup.grpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
// load backup_filer.toml // load backup_filer.toml

2
weed/command/filer_meta_tail.go

@ -45,7 +45,7 @@ var (
func runFilerMetaTail(cmd *Command, args []string) bool { func runFilerMetaTail(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
clientId := util.RandomInt32() clientId := util.RandomInt32()

2
weed/command/filer_remote_gateway.go

@ -78,7 +78,7 @@ var cmdFilerRemoteGateway = &Command{
func runFilerRemoteGateway(cmd *Command, args []string) bool { func runFilerRemoteGateway(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
remoteGatewayOptions.grpcDialOption = grpcDialOption remoteGatewayOptions.grpcDialOption = grpcDialOption

2
weed/command/filer_remote_sync.go

@ -73,7 +73,7 @@ var cmdFilerRemoteSynchronize = &Command{
func runFilerRemoteSynchronize(cmd *Command, args []string) bool { func runFilerRemoteSynchronize(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
remoteSyncOptions.grpcDialOption = grpcDialOption remoteSyncOptions.grpcDialOption = grpcDialOption

2
weed/command/filer_replication.go

@ -30,7 +30,7 @@ var cmdFilerReplicate = &Command{
func runFilerReplicate(cmd *Command, args []string) bool { func runFilerReplicate(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
util.LoadConfiguration("replication", true) util.LoadConfiguration("replication", true)
util.LoadConfiguration("notification", true) util.LoadConfiguration("notification", true)
config := util.GetViper() config := util.GetViper()

2
weed/command/filer_sync.go

@ -118,7 +118,7 @@ var cmdFilerSynchronize = &Command{
func runFilerSynchronize(cmd *Command, args []string) bool { func runFilerSynchronize(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
grace.SetupProfiling(*syncCpuProfile, *syncMemProfile) grace.SetupProfiling(*syncCpuProfile, *syncMemProfile)

2
weed/command/iam.go

@ -47,7 +47,7 @@ func runIam(cmd *Command, args []string) bool {
func (iamopt *IamOptions) startIamServer() bool { func (iamopt *IamOptions) startIamServer() bool {
filerAddress := pb.ServerAddress(*iamopt.filer) filerAddress := pb.ServerAddress(*iamopt.filer)
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
for { for {
err := pb.WithGrpcFilerClient(false, 0, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error { err := pb.WithGrpcFilerClient(false, 0, filerAddress, grpcDialOption, func(client filer_pb.SeaweedFilerClient) error {

2
weed/command/master.go

@ -105,7 +105,7 @@ var (
func runMaster(cmd *Command, args []string) bool { func runMaster(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
util.LoadConfiguration("master", false) util.LoadConfiguration("master", false)
grace.SetupProfiling(*masterCpuProfile, *masterMemProfile) grace.SetupProfiling(*masterCpuProfile, *masterMemProfile)

2
weed/command/master_follower.go

@ -68,7 +68,7 @@ var cmdMasterFollower = &Command{
func runMasterFollower(cmd *Command, args []string) bool { func runMasterFollower(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
util.LoadConfiguration("master", false) util.LoadConfiguration("master", false)
if *mf.portGrpc == 0 { if *mf.portGrpc == 0 {

2
weed/command/mount_std.go

@ -66,7 +66,7 @@ func RunMount(option *MountOptions, umask os.FileMode) bool {
// try to connect to filer // try to connect to filer
filerAddresses := pb.ServerAddresses(*option.filer).ToAddresses() filerAddresses := pb.ServerAddresses(*option.filer).ToAddresses()
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
var cipher bool var cipher bool
var err error var err error

2
weed/command/mq_broker.go

@ -54,7 +54,7 @@ var cmdMqBroker = &Command{
func runMqBroker(cmd *Command, args []string) bool { func runMqBroker(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
mqBrokerStandaloneOptions.masters = pb.ServerAddresses(*mqBrokerStandaloneOptions.mastersString).ToAddressMap() mqBrokerStandaloneOptions.masters = pb.ServerAddresses(*mqBrokerStandaloneOptions.mastersString).ToAddressMap()

2
weed/command/s3.go

@ -165,7 +165,7 @@ var cmdS3 = &Command{
func runS3(cmd *Command, args []string) bool { func runS3(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
switch { switch {
case *s3StandaloneOptions.metricsHttpIp != "": case *s3StandaloneOptions.metricsHttpIp != "":

2
weed/command/server.go

@ -179,7 +179,7 @@ func runServer(cmd *Command, args []string) bool {
go http.ListenAndServe(fmt.Sprintf(":%d", *serverOptions.debugPort), nil) go http.ListenAndServe(fmt.Sprintf(":%d", *serverOptions.debugPort), nil)
} }
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
util.LoadConfiguration("master", false) util.LoadConfiguration("master", false)
grace.SetupProfiling(*serverOptions.cpuprofile, *serverOptions.memprofile) grace.SetupProfiling(*serverOptions.cpuprofile, *serverOptions.memprofile)

2
weed/command/shell.go

@ -35,7 +35,7 @@ var cmdShell = &Command{
func runShell(command *Command, args []string) bool { func runShell(command *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client") shellOptions.GrpcDialOption = security.LoadClientTLS(util.GetViper(), "grpc.client")
shellOptions.Directory = "/" shellOptions.Directory = "/"

2
weed/command/upload.go

@ -69,7 +69,7 @@ var cmdUpload = &Command{
func runUpload(cmd *Command, args []string) bool { func runUpload(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client") grpcDialOption := security.LoadClientTLS(util.GetViper(), "grpc.client")
defaultReplication, err := readMasterConfiguration(grpcDialOption, pb.ServerAddress(*upload.master)) defaultReplication, err := readMasterConfiguration(grpcDialOption, pb.ServerAddress(*upload.master))

2
weed/command/volume.go

@ -125,7 +125,7 @@ var (
func runVolume(cmd *Command, args []string) bool { func runVolume(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
// If --pprof is set we assume the caller wants to be able to collect // If --pprof is set we assume the caller wants to be able to collect
// cpu and memory profiles via go tool pprof // cpu and memory profiles via go tool pprof

2
weed/command/webdav.go

@ -60,7 +60,7 @@ var cmdWebDav = &Command{
func runWebDav(cmd *Command, args []string) bool { func runWebDav(cmd *Command, args []string) bool {
util.LoadConfiguration("security", false)
util.LoadSecurityConfiguration()
glog.V(0).Infof("Starting Seaweed WebDav Server %s at https port %d", util.Version(), *webDavStandaloneOptions.port) glog.V(0).Infof("Starting Seaweed WebDav Server %s at https port %d", util.Version(), *webDavStandaloneOptions.port)

7
weed/util/config.go

@ -11,6 +11,7 @@ import (
var ( var (
ConfigurationFileDirectory DirectoryValueType ConfigurationFileDirectory DirectoryValueType
loadSecurityConfigOnce sync.Once
) )
type DirectoryValueType string type DirectoryValueType string
@ -31,6 +32,12 @@ type Configuration interface {
SetDefault(key string, value interface{}) SetDefault(key string, value interface{})
} }
func LoadSecurityConfiguration(){
loadSecurityConfigOnce.Do(func() {
LoadConfiguration("security", false)
})
}
func LoadConfiguration(configFileName string, required bool) (loaded bool) { func LoadConfiguration(configFileName string, required bool) (loaded bool) {
// find a filer store // find a filer store

Loading…
Cancel
Save