|
|
|
@ -135,8 +135,12 @@ func runDaemonPmuxOnce( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err := doOnce(ctx, func(ctx context.Context) error { |
|
|
|
|
fmt.Fprintln(os.Stderr, "updating host info in garage") |
|
|
|
|
return hostBootstrap.PutGarageBoostrapHost(ctx) |
|
|
|
|
if err := hostBootstrap.PutGarageBoostrapHost(ctx); err != nil { |
|
|
|
|
fmt.Fprintf(os.Stderr, "updating host info in garage: %v\n", err) |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
@ -155,8 +159,12 @@ func runDaemonPmuxOnce( |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
err := doOnce(ctx, func(ctx context.Context) error { |
|
|
|
|
fmt.Fprintln(os.Stderr, "applying garage layout") |
|
|
|
|
return garageApplyLayout(ctx, hostBootstrap, daemonConfig) |
|
|
|
|
if err := garageApplyLayout(ctx, hostBootstrap, daemonConfig); err != nil { |
|
|
|
|
fmt.Fprintf(os.Stderr, "applying garage layout: %v\n", err) |
|
|
|
|
return err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return nil |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
@ -234,9 +242,8 @@ var subCmdDaemon = subCmd{ |
|
|
|
|
bootstrapDataDirPath = bootstrap.DataDirPath(envDataDirPath) |
|
|
|
|
bootstrapAppDirPath = bootstrap.AppDirPath(envAppDirPath) |
|
|
|
|
|
|
|
|
|
hostBootstrapPath string |
|
|
|
|
hostBootstrap bootstrap.Bootstrap |
|
|
|
|
foundHostBootstrap bool |
|
|
|
|
hostBootstrapPath string |
|
|
|
|
hostBootstrap bootstrap.Bootstrap |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
tryLoadBootstrap := func(path string) bool { |
|
|
|
@ -245,6 +252,7 @@ var subCmdDaemon = subCmd{ |
|
|
|
|
return false |
|
|
|
|
|
|
|
|
|
} else if hostBootstrap, err = bootstrap.FromFile(path); errors.Is(err, fs.ErrNotExist) { |
|
|
|
|
fmt.Fprintf(os.Stderr, "bootstrap file not found at %q\n", path) |
|
|
|
|
err = nil |
|
|
|
|
return false |
|
|
|
|
|
|
|
|
@ -253,21 +261,22 @@ var subCmdDaemon = subCmd{ |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fmt.Fprintf(os.Stderr, "bootstrap file found at %q\n", path) |
|
|
|
|
hostBootstrapPath = path |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foundHostBootstrap = tryLoadBootstrap(bootstrapDataDirPath) |
|
|
|
|
foundHostBootstrap = !foundHostBootstrap && *bootstrapPath != "" && tryLoadBootstrap(*bootstrapPath) |
|
|
|
|
foundHostBootstrap = !foundHostBootstrap && tryLoadBootstrap(bootstrapAppDirPath) |
|
|
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
switch { |
|
|
|
|
case tryLoadBootstrap(bootstrapDataDirPath): |
|
|
|
|
case *bootstrapPath != "" && tryLoadBootstrap(*bootstrapPath): |
|
|
|
|
case tryLoadBootstrap(bootstrapAppDirPath): |
|
|
|
|
case err != nil: |
|
|
|
|
return fmt.Errorf("attempting to load bootstrap.yml file: %w", err) |
|
|
|
|
|
|
|
|
|
} else if !foundHostBootstrap { |
|
|
|
|
default: |
|
|
|
|
return errors.New("No bootstrap.yml file could be found, and one is not provided with --bootstrap-path") |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} else if hostBootstrapPath != bootstrapDataDirPath { |
|
|
|
|
if hostBootstrapPath != bootstrapDataDirPath { |
|
|
|
|
|
|
|
|
|
// If the bootstrap file is not being stored in the data dir, copy
|
|
|
|
|
// it there, so it can be loaded from there next time.
|
|
|
|
|