Compare commits
5 Commits
877e519821
...
0a6516b44e
Author | SHA1 | Date | |
---|---|---|---|
|
0a6516b44e | ||
|
03ab15902c | ||
|
53194614df | ||
|
2181da14a1 | ||
|
b498ee271d |
@ -58,21 +58,19 @@ storage:
|
|||||||
# network. If no allocations are defined then no data is replicated to this
|
# network. If no allocations are defined then no data is replicated to this
|
||||||
# node.
|
# 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 data directory of each allocation should be on a different drive, while
|
||||||
# the meta directories can be anywhere (ideally on an SSD).
|
# the meta directories can be anywhere (ideally on an SSD).
|
||||||
#
|
#
|
||||||
# Capacity declares how many gigabytes can be stored in each allocation, and
|
# Capacity declares how many gigabytes can be stored in each allocation, and
|
||||||
# is required. It must be a multiple of 100.
|
# is required. It must be a multiple of 100.
|
||||||
#
|
#
|
||||||
# The ports are all required and must all be unique within and across
|
# The ports are all _optional_, and will be automatically assigned if they are
|
||||||
# allocations.
|
|
||||||
#
|
|
||||||
# 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
|
# not specified. If ports any ports are specified then all should be
|
||||||
# specified, and each should be unique across all allocations.
|
# 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:
|
#allocations:
|
||||||
|
|
||||||
#- data_path: /foo/bar/data
|
#- data_path: /foo/bar/data
|
||||||
|
32
default.nix
32
default.nix
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
pkgsAttrs ? (import ./nix/pkgs.nix),
|
pkgsAttrs ? (import ./nix/pkgs.nix),
|
||||||
bootstrap ? null,
|
bootstrap ? null,
|
||||||
|
releaseName ? "debug",
|
||||||
|
|
||||||
}: let
|
}: let
|
||||||
|
|
||||||
@ -27,7 +28,7 @@ in rec {
|
|||||||
buildInputs = [ pkgs.git pkgs.go ];
|
buildInputs = [ pkgs.git pkgs.go ];
|
||||||
|
|
||||||
src = ./.;
|
src = ./.;
|
||||||
inherit bootstrap;
|
inherit bootstrap releaseName;
|
||||||
nixPkgsVersion = pkgsAttrs.version;
|
nixPkgsVersion = pkgsAttrs.version;
|
||||||
nixPkgsRev = pkgsAttrs.rev;
|
nixPkgsRev = pkgsAttrs.rev;
|
||||||
builtByUser = builtins.getEnv "USER";
|
builtByUser = builtins.getEnv "USER";
|
||||||
@ -44,6 +45,7 @@ in rec {
|
|||||||
echo "Built for host: $hostName" >> "$versionFile"
|
echo "Built for host: $hostName" >> "$versionFile"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Release: $releaseName" >> "$versionFile"
|
||||||
echo "Build date: $(date) ($(date +%s))" >> "$versionFile"
|
echo "Build date: $(date) ($(date +%s))" >> "$versionFile"
|
||||||
echo "Built by: $builtByUser" >> "$versionFile"
|
echo "Built by: $builtByUser" >> "$versionFile"
|
||||||
echo "Git rev: $(cd srcCp && git describe --always --long --dirty=' (dirty)')" >> "$versionFile"
|
echo "Git rev: $(cd srcCp && git describe --always --long --dirty=' (dirty)')" >> "$versionFile"
|
||||||
@ -95,24 +97,22 @@ in rec {
|
|||||||
source $stdenv/setup
|
source $stdenv/setup
|
||||||
cp -rL "$src" cryptic-net
|
cp -rL "$src" cryptic-net
|
||||||
chmod +w cryptic-net -R
|
chmod +w cryptic-net -R
|
||||||
mkdir $out
|
appimagetool cryptic-net "$out"
|
||||||
appimagetool cryptic-net "$out/cryptic-net"
|
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
service = pkgs.writeText "cryptic-service" ''
|
release = pkgs.stdenv.mkDerivation {
|
||||||
[Unit]
|
name = "cryptic-net-AppImage";
|
||||||
Description=cryptic nebula
|
inherit appImage releaseName;
|
||||||
Requires=network.target
|
|
||||||
After=network.target
|
|
||||||
|
|
||||||
[Service]
|
buildInputs = [ pkgs.coreutils ];
|
||||||
Restart=always
|
|
||||||
RestartSec=1s
|
|
||||||
User=root
|
|
||||||
ExecStart=${appImage}/cryptic-net
|
|
||||||
|
|
||||||
[Install]
|
builder = builtins.toFile "build.sh" ''
|
||||||
WantedBy=multi-user.target
|
source $stdenv/setup
|
||||||
'';
|
|
||||||
|
mkdir -p "$out"
|
||||||
|
cp "$appImage" "$out"/cryptic-net-$releaseName-linux-amd64
|
||||||
|
(cd "$out" && sha256sum * > sha256.txt)
|
||||||
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
@ -105,7 +105,7 @@ func (b Bootstrap) GetGarageBootstrapHosts(
|
|||||||
|
|
||||||
for objInfo := range objInfoCh {
|
for objInfo := range objInfoCh {
|
||||||
|
|
||||||
ctx := mctx.Annotate(ctx, "object-key", objInfo.Key)
|
ctx := mctx.Annotate(ctx, "objectKey", objInfo.Key)
|
||||||
|
|
||||||
if objInfo.Err != nil {
|
if objInfo.Err != nil {
|
||||||
return nil, fmt.Errorf("listing objects: %w", objInfo.Err)
|
return nil, fmt.Errorf("listing objects: %w", objInfo.Err)
|
||||||
|
@ -268,7 +268,7 @@ var subCmdDaemon = subCmd{
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.Info(
|
logger.Info(
|
||||||
mctx.Annotate(ctx, "bootstrap-file-path", path),
|
mctx.Annotate(ctx, "bootstrapFilePath", path),
|
||||||
"bootstrap file found",
|
"bootstrap file found",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -11,11 +11,12 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"code.betamike.com/cryptic-io/pmux/pmuxlib"
|
"code.betamike.com/cryptic-io/pmux/pmuxlib"
|
||||||
|
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
|
||||||
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
|
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func garageAdminClientLogger(logger *mlog.Logger) *mlog.Logger {
|
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,
|
// newGarageAdminClient will return an AdminClient for a local garage instance,
|
||||||
@ -57,7 +58,7 @@ func waitForGarageAndNebula(
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
logger = garageAdminClientLogger(logger)
|
adminClientLogger := garageAdminClientLogger(logger)
|
||||||
|
|
||||||
for _, alloc := range allocs {
|
for _, alloc := range allocs {
|
||||||
|
|
||||||
@ -69,9 +70,12 @@ func waitForGarageAndNebula(
|
|||||||
adminClient := garage.NewAdminClient(
|
adminClient := garage.NewAdminClient(
|
||||||
adminAddr,
|
adminAddr,
|
||||||
hostBootstrap.Garage.AdminToken,
|
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 {
|
if err := adminClient.Wait(ctx); err != nil {
|
||||||
return fmt.Errorf("waiting for garage instance %q to start up: %w", adminAddr, err)
|
return fmt.Errorf("waiting for garage instance %q to start up: %w", adminAddr, err)
|
||||||
}
|
}
|
||||||
@ -271,7 +275,7 @@ func garageApplyLayout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
clusterLayout[id] = peerLayout{
|
clusterLayout[id] = peerLayout{
|
||||||
Capacity: alloc.Capacity / 100,
|
Capacity: alloc.Capacity,
|
||||||
Zone: zone,
|
Zone: zone,
|
||||||
Tags: []string{},
|
Tags: []string{},
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ func writeLock() error {
|
|||||||
// returns a cleanup function which will clean up the created runtime directory.
|
// returns a cleanup function which will clean up the created runtime directory.
|
||||||
func setupAndLockRuntimeDir(ctx context.Context, logger *mlog.Logger) (func(), error) {
|
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")
|
logger.Info(ctx, "will use runtime directory for temporary state")
|
||||||
|
|
||||||
if err := os.MkdirAll(envRuntimeDirPath, 0700); err != nil {
|
if err := os.MkdirAll(envRuntimeDirPath, 0700); err != nil {
|
||||||
|
@ -10,6 +10,7 @@ import (
|
|||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/mediocregopher/mediocre-go-lib/v2/mctx"
|
||||||
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
|
"github.com/mediocregopher/mediocre-go-lib/v2/mlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -149,6 +150,7 @@ func (c *AdminClient) Wait(ctx context.Context) error {
|
|||||||
return ctxErr
|
return ctxErr
|
||||||
|
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
|
c.logger.Warn(ctx, "waiting for instance to become ready", err)
|
||||||
continue
|
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 {
|
if numUp >= ReplicationFactor-1 {
|
||||||
|
c.logger.Debug(ctx, "instance appears to be online")
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c.logger.Debug(ctx, "instance not online yet, will continue waiting")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user