Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Commit

Permalink
Tag singularity metrics to motion (#177)
Browse files Browse the repository at this point in the history
Context: 
- #174 

Previous steps
- data-preservation-programs/singularity#398
-
data-preservation-programs/singularity-metrics@46bc0d3

Next step:
- Create Grafana dashboard with tagged motion telemetry
  • Loading branch information
xinaxu authored Oct 23, 2023
2 parents d35c382 + d23c029 commit bb873c7
Show file tree
Hide file tree
Showing 8 changed files with 617 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The version of singularity you will use to make deals. Generally, this should not change
SINGULARITY_REF=:v0.5.2
SINGULARITY_REF=:v0.5.4

# Comma seperated list of storage providers motion should make storage deals with
# You must set this value to contain at least one storage provider for motion to
Expand Down
4 changes: 4 additions & 0 deletions cmd/motion/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/filecoin-project/motion/blob"
"github.com/filecoin-project/motion/integration/singularity"
"github.com/ipfs/go-log/v2"
_ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli/v2"
)

Expand Down Expand Up @@ -45,11 +46,13 @@ func main() {
Name: "experimentalSingularityStore",
Usage: "Whether to use experimental Singularity store as the storage and deal making engine",
DefaultText: "Local storage is used",
EnvVars: []string{"MOTION_EXPERIMENTAL_SINGULARITY_STORE"},
},
&cli.StringFlag{
Name: "experimentalRemoteSingularityAPIUrl",
Usage: "When using a singularity as the storage engine, if set, uses a remote HTTP API to interface with Singularity",
DefaultText: "use singularity as a code library",
EnvVars: []string{"MOTION_EXPERIMENTAL_REMOTE_SINGULARITY_API_URL"},
},
&cli.StringSliceFlag{
Name: "storageProvider",
Expand Down Expand Up @@ -135,6 +138,7 @@ func main() {
Name: "experimentalSingularityContentURLTemplate",
Usage: "When using a singularity as the storage engine, if set, setups up online deals to use the given url template for making online deals",
DefaultText: "make offline deals",
EnvVars: []string{"MOTION_SINGULARITY_CONTENT_URL_TEMPLATE"},
},
&cli.StringFlag{
Name: "experimentalSingularityScheduleCron",
Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ module github.com/filecoin-project/motion
go 1.20

require (
github.com/data-preservation-programs/singularity v0.5.3
github.com/data-preservation-programs/singularity v0.5.4
github.com/filecoin-project/go-address v1.1.0
github.com/filecoin-project/go-state-types v0.12.0
github.com/google/uuid v1.3.1
github.com/gotidy/ptr v1.4.0
github.com/ipfs/go-log/v2 v2.5.1
github.com/joho/godotenv v1.5.1
github.com/stretchr/testify v1.8.4
github.com/urfave/cli/v2 v2.25.7
go.uber.org/goleak v1.2.0
Expand Down
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHH
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0=
github.com/data-preservation-programs/singularity v0.5.3 h1:nksfYBN4uUszy619oFqoiQaCFtXaLr1uony1SURB5Ek=
github.com/data-preservation-programs/singularity v0.5.3/go.mod h1:M9Pxg4zDOaxVg8oHEiOku+kS93KVz70m8MYhbpS5lBM=
github.com/data-preservation-programs/singularity v0.5.4 h1:9zEOBWZY1PZeYMGmGynnyvzgwrYQ+WUAYnUsbDirxCs=
github.com/data-preservation-programs/singularity v0.5.4/go.mod h1:M9Pxg4zDOaxVg8oHEiOku+kS93KVz70m8MYhbpS5lBM=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
Expand Down Expand Up @@ -336,6 +336,8 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
Expand Down
585 changes: 583 additions & 2 deletions go.work.sum

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions integration/singularity/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"sync"
"time"

"github.com/data-preservation-programs/singularity/client/swagger/http/admin"
"github.com/data-preservation-programs/singularity/client/swagger/http/deal_schedule"
"github.com/data-preservation-programs/singularity/client/swagger/http/file"
"github.com/data-preservation-programs/singularity/client/swagger/http/job"
Expand Down Expand Up @@ -87,8 +88,23 @@ func (s *SingularityStore) initPreparation(ctx context.Context) (*models.ModelPr
func (s *SingularityStore) Start(ctx context.Context) error {
logger := logger.With("preparation", s.preparationName)

// List out preparations and see if one with the configured name exists
// Set the identity to Motion for tracking purpose
resp, err := s.singularityClient.Admin.SetIdentity(&admin.SetIdentityParams{
Context: ctx,
Request: &models.AdminSetIdentityRequest{
Identity: "Motion",
},
})
if err != nil {
logger.Errorw("Failed to set motion identity, are you using Singularity v0.5.4+?", "err", err)
return fmt.Errorf("failed to set motion identity, are you using Singularity v0.5.4+?: %w", err)
}
if !resp.IsSuccess() {
logger.Errorw("Failed to set motion identity, are you using Singularity v0.5.4+?", "err", resp.Error())
return fmt.Errorf("failed to set motion identity, are you using Singularity v0.5.4+?: %s", resp.Error())
}

// List out preparations and see if one with the configured name exists
listPreparationsRes, err := s.singularityClient.Preparation.ListPreparations(&preparation.ListPreparationsParams{
Context: ctx,
})
Expand Down Expand Up @@ -380,7 +396,7 @@ func (s *SingularityStore) Put(ctx context.Context, reader io.ReadCloser) (*blob
logger.Errorw("Failed to move ID file to store", "err", err)
return nil, err
}
logger.Infow("Stored blob successfully", "id", desc.ID, "size", desc.Size, "singularityFileID", pushFileRes.Payload.ID)
logger.Infow("Stored blob successfully", "id", desc.ID.String(), "size", desc.Size, "singularityFileID", pushFileRes.Payload.ID)
return desc, nil
}

Expand Down
4 changes: 4 additions & 0 deletions integration/singularity/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ func TestStorePut(t *testing.T) {
func testHandler(w http.ResponseWriter, req *http.Request) {
defer req.Body.Close()

if req.URL.Path == "/api/identity" && req.Method == http.MethodPost {
w.WriteHeader(http.StatusNoContent)
return
}
if req.URL.Path == "/api/preparation/MOTION_PREPARATION/schedules" && req.Method == http.MethodGet {
http.Error(w, "", http.StatusNotFound)
return
Expand Down
2 changes: 1 addition & 1 deletion integration/test/motionlarity/.env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SINGULARITY_REF=:v0.5.2
SINGULARITY_REF=:v0.5.4
LOTUS_TEST='true'
LOTUS_API=http://lotus:1234/rpc/v1
MOTION_PRICE_PER_GIB_EPOCH=0
Expand Down

0 comments on commit bb873c7

Please sign in to comment.