Compare commits

..

5 Commits

Author SHA1 Message Date
Brian Picciano
0a6516b44e Add release target in nix 2022-11-16 17:45:13 +01:00
Brian Picciano
03ab15902c Update docs for storage allocs in daemon.yml 2022-11-16 17:30:55 +01:00
Brian Picciano
53194614df Switch to using camelCase for logs 2022-11-16 17:27:42 +01:00
Brian Picciano
2181da14a1 Added some debug logging, ultimately not needed 2022-11-16 17:25:55 +01:00
Brian Picciano
b498ee271d Don't divide layout capacity by 100
See discussion in
https://git.deuxfleurs.fr/Deuxfleurs/garage/issues/414. Apparently the
capacity is only relative to that of other instances in the layout, it
has no absolute value of its own. We can say it corresponds to GB for
ease-of-use, but garage doesn't see it that way.
2022-11-16 15:51:13 +01:00
7 changed files with 40 additions and 29 deletions

View File

@ -58,21 +58,19 @@ storage:
# network. If no allocations are defined then no data is replicated to this
# node.
#
# Each allocation should have its own data/meta directories, separate from the
# other allocations.
#
# The data directory of each allocation should be on a different drive, while
# the meta directories can be anywhere (ideally on an SSD).
#
# Capacity declares how many gigabytes can be stored in each allocation, and
# is required. It must be a multiple of 100.
#
# The ports are all required and must all be unique within and across
# allocations.
#
# THe ports are all _optional_, and will be automatically assigned if they are
# The ports are all _optional_, and will be automatically assigned if they are
# not specified. If ports any ports are specified then all should be
# specified, and each should be unique across all allocations.
#
# Once assigned (either implicitly or explicitly) the rpc_port of an
# allocation should not be changed.
#allocations:
#- data_path: /foo/bar/data

View File

@ -2,6 +2,7 @@
pkgsAttrs ? (import ./nix/pkgs.nix),
bootstrap ? null,
releaseName ? "debug",
}: let
@ -27,7 +28,7 @@ in rec {
buildInputs = [ pkgs.git pkgs.go ];
src = ./.;
inherit bootstrap;
inherit bootstrap releaseName;
nixPkgsVersion = pkgsAttrs.version;
nixPkgsRev = pkgsAttrs.rev;
builtByUser = builtins.getEnv "USER";
@ -44,6 +45,7 @@ in rec {
echo "Built for host: $hostName" >> "$versionFile"
fi
echo "Release: $releaseName" >> "$versionFile"
echo "Build date: $(date) ($(date +%s))" >> "$versionFile"
echo "Built by: $builtByUser" >> "$versionFile"
echo "Git rev: $(cd srcCp && git describe --always --long --dirty=' (dirty)')" >> "$versionFile"
@ -95,24 +97,22 @@ in rec {
source $stdenv/setup
cp -rL "$src" cryptic-net
chmod +w cryptic-net -R
mkdir $out
appimagetool cryptic-net "$out/cryptic-net"
appimagetool cryptic-net "$out"
'';
};
service = pkgs.writeText "cryptic-service" ''
[Unit]
Description=cryptic nebula
Requires=network.target
After=network.target
release = pkgs.stdenv.mkDerivation {
name = "cryptic-net-AppImage";
inherit appImage releaseName;
[Service]
Restart=always
RestartSec=1s
User=root
ExecStart=${appImage}/cryptic-net
buildInputs = [ pkgs.coreutils ];
[Install]
WantedBy=multi-user.target
builder = builtins.toFile "build.sh" ''
source $stdenv/setup
mkdir -p "$out"
cp "$appImage" "$out"/cryptic-net-$releaseName-linux-amd64
(cd "$out" && sha256sum * > sha256.txt)
'';
};
}

View File

@ -105,7 +105,7 @@ func (b Bootstrap) GetGarageBootstrapHosts(
for objInfo := range objInfoCh {
ctx := mctx.Annotate(ctx, "object-key", objInfo.Key)
ctx := mctx.Annotate(ctx, "objectKey", objInfo.Key)
if objInfo.Err != nil {
return nil, fmt.Errorf("listing objects: %w", objInfo.Err)

View File

@ -268,7 +268,7 @@ var subCmdDaemon = subCmd{
}
logger.Info(
mctx.Annotate(ctx, "bootstrap-file-path", path),
mctx.Annotate(ctx, "bootstrapFilePath", path),
"bootstrap file found",
)

View File

@ -11,11 +11,12 @@ import (
"strconv"
"code.betamike.com/cryptic-io/pmux/pmuxlib"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
)
func garageAdminClientLogger(logger *mlog.Logger) *mlog.Logger {
return logger.WithNamespace("garage-admin-client")
return logger.WithNamespace("garageAdminClient")
}
// newGarageAdminClient will return an AdminClient for a local garage instance,
@ -57,7 +58,7 @@ func waitForGarageAndNebula(
return nil
}
logger = garageAdminClientLogger(logger)
adminClientLogger := garageAdminClientLogger(logger)
for _, alloc := range allocs {
@ -69,9 +70,12 @@ func waitForGarageAndNebula(
adminClient := garage.NewAdminClient(
adminAddr,
hostBootstrap.Garage.AdminToken,
logger,
adminClientLogger,
)
ctx := mctx.Annotate(ctx, "garageAdminAddr", adminAddr)
logger.Debug(ctx, "wating for garage instance to start")
if err := adminClient.Wait(ctx); err != nil {
return fmt.Errorf("waiting for garage instance %q to start up: %w", adminAddr, err)
}
@ -271,7 +275,7 @@ func garageApplyLayout(
}
clusterLayout[id] = peerLayout{
Capacity: alloc.Capacity / 100,
Capacity: alloc.Capacity,
Zone: zone,
Tags: []string{},
}

View File

@ -49,7 +49,7 @@ func writeLock() error {
// returns a cleanup function which will clean up the created runtime directory.
func setupAndLockRuntimeDir(ctx context.Context, logger *mlog.Logger) (func(), error) {
ctx = mctx.Annotate(ctx, "runtime-dir-path", envRuntimeDirPath)
ctx = mctx.Annotate(ctx, "runtimeDirPath", envRuntimeDirPath)
logger.Info(ctx, "will use runtime directory for temporary state")
if err := os.MkdirAll(envRuntimeDirPath, 0700); err != nil {

View File

@ -10,6 +10,7 @@ import (
"net/http/httputil"
"time"
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
)
@ -149,6 +150,7 @@ func (c *AdminClient) Wait(ctx context.Context) error {
return ctxErr
} else if err != nil {
c.logger.Warn(ctx, "waiting for instance to become ready", err)
continue
}
@ -160,9 +162,16 @@ func (c *AdminClient) Wait(ctx context.Context) error {
}
}
ctx := mctx.Annotate(ctx,
"numKnownNodes", len(clusterStatus.KnownNodes),
"numUp", numUp,
)
if numUp >= ReplicationFactor-1 {
c.logger.Debug(ctx, "instance appears to be online")
return nil
}
c.logger.Debug(ctx, "instance not online yet, will continue waiting")
}
}