harmony: Fix resources.Register
This commit is contained in:
parent
a686a995f6
commit
4f9e168017
@ -9,21 +9,21 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-statestore"
|
|
||||||
"github.com/gbrlsnchs/jwt/v3"
|
"github.com/gbrlsnchs/jwt/v3"
|
||||||
ds "github.com/ipfs/go-datastore"
|
|
||||||
dssync "github.com/ipfs/go-datastore/sync"
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
|
|
||||||
"github.com/gin-contrib/pprof"
|
"github.com/gin-contrib/pprof"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
ds "github.com/ipfs/go-datastore"
|
||||||
|
dssync "github.com/ipfs/go-datastore/sync"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli/v2"
|
"github.com/urfave/cli/v2"
|
||||||
"go.opencensus.io/stats"
|
"go.opencensus.io/stats"
|
||||||
"go.opencensus.io/tag"
|
"go.opencensus.io/tag"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
|
"github.com/filecoin-project/go-statestore"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
lcli "github.com/filecoin-project/lotus/cli"
|
lcli "github.com/filecoin-project/lotus/cli"
|
||||||
|
@ -6,8 +6,7 @@ CREATE TABLE harmony_machines (
|
|||||||
host_and_port varchar(300) NOT NULL,
|
host_and_port varchar(300) NOT NULL,
|
||||||
cpu INTEGER NOT NULL,
|
cpu INTEGER NOT NULL,
|
||||||
ram BIGINT NOT NULL,
|
ram BIGINT NOT NULL,
|
||||||
gpu FLOAT NOT NULL,
|
gpu FLOAT NOT NULL
|
||||||
gpuram BIGINT NOT NULL
|
|
||||||
);
|
);
|
||||||
|
|
||||||
CREATE TABLE harmony_task (
|
CREATE TABLE harmony_task (
|
||||||
|
@ -3,6 +3,7 @@ package resources
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime"
|
"runtime"
|
||||||
@ -42,7 +43,7 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) {
|
|||||||
}
|
}
|
||||||
ctx := context.Background()
|
ctx := context.Background()
|
||||||
{ // Learn our owner_id while updating harmony_machines
|
{ // Learn our owner_id while updating harmony_machines
|
||||||
var ownerID int
|
var ownerID *int
|
||||||
|
|
||||||
// Upsert query with last_contact update, fetch the machine ID
|
// Upsert query with last_contact update, fetch the machine ID
|
||||||
// (note this isn't a simple insert .. on conflict because host_and_port isn't unique)
|
// (note this isn't a simple insert .. on conflict because host_and_port isn't unique)
|
||||||
@ -54,7 +55,7 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) {
|
|||||||
RETURNING id
|
RETURNING id
|
||||||
),
|
),
|
||||||
inserted AS (
|
inserted AS (
|
||||||
INSERT INTO harmony_machines (host_and_port, cpu, ram, gpu, gpuram, last_contact)
|
INSERT INTO harmony_machines (host_and_port, cpu, ram, gpu, last_contact)
|
||||||
SELECT $1, $2, $3, $4, CURRENT_TIMESTAMP
|
SELECT $1, $2, $3, $4, CURRENT_TIMESTAMP
|
||||||
WHERE NOT EXISTS (SELECT id FROM upsert)
|
WHERE NOT EXISTS (SELECT id FROM upsert)
|
||||||
RETURNING id
|
RETURNING id
|
||||||
@ -64,10 +65,13 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) {
|
|||||||
SELECT id FROM inserted;
|
SELECT id FROM inserted;
|
||||||
`, hostnameAndPort, reg.Cpu, reg.Ram, reg.Gpu).Scan(&ownerID)
|
`, hostnameAndPort, reg.Cpu, reg.Ram, reg.Gpu).Scan(&ownerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, xerrors.Errorf("inserting machine entry: %w", err)
|
||||||
|
}
|
||||||
|
if ownerID == nil {
|
||||||
|
return nil, xerrors.Errorf("no owner id")
|
||||||
}
|
}
|
||||||
|
|
||||||
reg.MachineID = ownerID
|
reg.MachineID = *ownerID
|
||||||
|
|
||||||
cleaned := CleanupMachines(context.Background(), db)
|
cleaned := CleanupMachines(context.Background(), db)
|
||||||
logger.Infow("Cleaned up machines", "count", cleaned)
|
logger.Infow("Cleaned up machines", "count", cleaned)
|
||||||
@ -87,9 +91,10 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) {
|
|||||||
|
|
||||||
return ®, nil
|
return ®, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func CleanupMachines(ctx context.Context, db *harmonydb.DB) int {
|
func CleanupMachines(ctx context.Context, db *harmonydb.DB) int {
|
||||||
ct, err := db.Exec(ctx, `DELETE FROM harmony_machines WHERE last_contact < $1`,
|
ct, err := db.Exec(ctx, `DELETE FROM harmony_machines WHERE last_contact < $1`,
|
||||||
time.Now().Add(-1*LOOKS_DEAD_TIMEOUT))
|
time.Now().Add(-1*LOOKS_DEAD_TIMEOUT).UTC())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warn("unable to delete old machines: ", err)
|
logger.Warn("unable to delete old machines: ", err)
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,14 @@ var Doc = map[string][]DocField{
|
|||||||
|
|
||||||
Comment: `FULLNODE_API_INFO is the API endpoint for the Lotus daemon.`,
|
Comment: `FULLNODE_API_INFO is the API endpoint for the Lotus daemon.`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "StorageRPCSecret",
|
||||||
|
Type: "string",
|
||||||
|
|
||||||
|
Comment: `RPC Secret for the storage subsystem.
|
||||||
|
If integrating with lotus-miner this must match the value from
|
||||||
|
cat ~/.lotusminer/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU | jq -r .PrivateKey`,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"Backup": {
|
"Backup": {
|
||||||
{
|
{
|
||||||
@ -748,18 +756,6 @@ over the worker address if this flag is set.`,
|
|||||||
|
|
||||||
Comment: ``,
|
Comment: ``,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
Name: "SealingParams",
|
|
||||||
Type: "SealingConfig",
|
|
||||||
|
|
||||||
Comment: ``,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Name: "SealerConfig",
|
|
||||||
Type: "//",
|
|
||||||
|
|
||||||
Comment: ``,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
Name: "Journal",
|
Name: "Journal",
|
||||||
Type: "JournalConfig",
|
Type: "JournalConfig",
|
||||||
|
@ -2,12 +2,8 @@ package provider
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/filecoin-project/lotus/provider/lpmessage"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/storage/paths"
|
|
||||||
"github.com/filecoin-project/lotus/storage/sealer"
|
|
||||||
|
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
@ -15,8 +11,11 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
dtypes "github.com/filecoin-project/lotus/node/modules/dtypes"
|
dtypes "github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/provider/chainsched"
|
"github.com/filecoin-project/lotus/provider/chainsched"
|
||||||
|
"github.com/filecoin-project/lotus/provider/lpmessage"
|
||||||
"github.com/filecoin-project/lotus/provider/lpwindow"
|
"github.com/filecoin-project/lotus/provider/lpwindow"
|
||||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||||
|
"github.com/filecoin-project/lotus/storage/paths"
|
||||||
|
"github.com/filecoin-project/lotus/storage/sealer"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,15 +2,18 @@ package lpmessage
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"github.com/filecoin-project/go-address"
|
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
|
||||||
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
|
||||||
"github.com/google/uuid"
|
"github.com/google/uuid"
|
||||||
"github.com/ipfs/go-cid"
|
"github.com/ipfs/go-cid"
|
||||||
logging "github.com/ipfs/go-log/v2"
|
logging "github.com/ipfs/go-log/v2"
|
||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/api"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
|
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var log = logging.Logger("lpmessage")
|
var log = logging.Logger("lpmessage")
|
||||||
|
@ -3,6 +3,14 @@ package lpwindow
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
"sort"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ipfs/go-cid"
|
||||||
|
"go.uber.org/multierr"
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-bitfield"
|
"github.com/filecoin-project/go-bitfield"
|
||||||
@ -12,16 +20,11 @@ import (
|
|||||||
"github.com/filecoin-project/go-state-types/crypto"
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/go-state-types/dline"
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
"github.com/filecoin-project/go-state-types/proof"
|
"github.com/filecoin-project/go-state-types/proof"
|
||||||
|
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/build"
|
"github.com/filecoin-project/lotus/build"
|
||||||
types "github.com/filecoin-project/lotus/chain/types"
|
types "github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||||
proof7 "github.com/filecoin-project/specs-actors/v7/actors/runtime/proof"
|
|
||||||
"github.com/ipfs/go-cid"
|
|
||||||
"go.uber.org/multierr"
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
"sort"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const disablePreChecks = false // todo config
|
const disablePreChecks = false // todo config
|
||||||
|
@ -4,10 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/filecoin-project/go-bitfield"
|
|
||||||
"github.com/filecoin-project/go-state-types/crypto"
|
|
||||||
"github.com/filecoin-project/go-state-types/network"
|
|
||||||
"github.com/filecoin-project/lotus/storage/sealer"
|
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@ -16,9 +12,12 @@ import (
|
|||||||
"golang.org/x/xerrors"
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
|
"github.com/filecoin-project/go-bitfield"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||||
|
"github.com/filecoin-project/go-state-types/crypto"
|
||||||
"github.com/filecoin-project/go-state-types/dline"
|
"github.com/filecoin-project/go-state-types/dline"
|
||||||
|
"github.com/filecoin-project/go-state-types/network"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
@ -29,6 +28,7 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/lib/promise"
|
"github.com/filecoin-project/lotus/lib/promise"
|
||||||
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
"github.com/filecoin-project/lotus/node/modules/dtypes"
|
||||||
"github.com/filecoin-project/lotus/provider/chainsched"
|
"github.com/filecoin-project/lotus/provider/chainsched"
|
||||||
|
"github.com/filecoin-project/lotus/storage/sealer"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
|
"github.com/filecoin-project/lotus/storage/sealer/sealtasks"
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||||
"github.com/filecoin-project/lotus/storage/wdpost"
|
"github.com/filecoin-project/lotus/storage/wdpost"
|
||||||
|
@ -4,13 +4,16 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
ffi "github.com/filecoin-project/filecoin-ffi"
|
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
|
||||||
"github.com/filecoin-project/lotus/storage/paths"
|
|
||||||
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
|
||||||
"golang.org/x/xerrors"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
|
ffi "github.com/filecoin-project/filecoin-ffi"
|
||||||
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
|
|
||||||
|
"github.com/filecoin-project/lotus/storage/paths"
|
||||||
|
"github.com/filecoin-project/lotus/storage/sealer/storiface"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SimpleFaultTracker struct {
|
type SimpleFaultTracker struct {
|
||||||
|
@ -3,11 +3,15 @@ package lpwindow
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"golang.org/x/xerrors"
|
||||||
|
|
||||||
"github.com/filecoin-project/go-address"
|
"github.com/filecoin-project/go-address"
|
||||||
"github.com/filecoin-project/go-state-types/abi"
|
"github.com/filecoin-project/go-state-types/abi"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
"github.com/filecoin-project/go-state-types/builtin"
|
"github.com/filecoin-project/go-state-types/builtin"
|
||||||
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
"github.com/filecoin-project/go-state-types/builtin/v9/miner"
|
||||||
|
|
||||||
"github.com/filecoin-project/lotus/api"
|
"github.com/filecoin-project/lotus/api"
|
||||||
"github.com/filecoin-project/lotus/chain/types"
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
||||||
@ -17,7 +21,6 @@ import (
|
|||||||
"github.com/filecoin-project/lotus/provider/chainsched"
|
"github.com/filecoin-project/lotus/provider/chainsched"
|
||||||
"github.com/filecoin-project/lotus/provider/lpmessage"
|
"github.com/filecoin-project/lotus/provider/lpmessage"
|
||||||
"github.com/filecoin-project/lotus/storage/ctladdr"
|
"github.com/filecoin-project/lotus/storage/ctladdr"
|
||||||
"golang.org/x/xerrors"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type WdPoStSubmitTaskApi interface {
|
type WdPoStSubmitTaskApi interface {
|
||||||
|
Loading…
Reference in New Issue
Block a user