Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: stone node sends piece data to gateway #128

Merged
merged 9 commits into from
Feb 21, 2023
Merged

Conversation

sysvm
Copy link
Collaborator

@sysvm sysvm commented Feb 19, 2023

Description

In previous code, stone node straightly send piece data to syncer just for test. But this is not standard format.

  1. I fix it that stone node send piece data to gateway through HTTP and gateway send data to syncer through RPC.
  2. stone node get downstream gateway through P2P.

Rationale

Storage provider works in production environment.

Example

add an example CLI or API response...

Changes

Notable changes:

  • add each change in a bullet point here
  • ...

@sysvm sysvm changed the title fix: stone node sends piece data to gateway through HTTP feat: stone node sends piece data to gateway through HTTP Feb 19, 2023
@will-2012 will-2012 changed the title feat: stone node sends piece data to gateway through HTTP feat: stone node sends piece data to gateway Feb 19, 2023
StoneHubServiceAddress = "127.0.0.1:9333"
SyncerServiceAddress = ["127.0.0.1:9543", "127.0.0.1:9553", "127.0.0.1:9563", "127.0.0.1:9573", "127.0.0.1:9583", "127.0.0.1:9593"]
SyncerAddress = ["127.0.0.1:9543", "127.0.0.1:9553", "127.0.0.1:9563", "127.0.0.1:9573", "127.0.0.1:9583", "127.0.0.1:9593"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

syncer address should be replaced by gateway address?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

node.reportErrToStoneHub(ctx, allocResp, merrors.ErrSyncerNumber)
return merrors.ErrSyncerNumber
secondaryGatewayList := node.cfg.GatewayAddress
if len(secondaryPieceData) > len(secondarySPs) || len(secondaryGatewayList) != len(secondarySPs) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why len(secondaryGatewayList) != len(secondarySPs) ?
it ie ok, len(secondaryGatewayList) >= len(secondarySPs).

Copy link
Collaborator Author

@sysvm sysvm Feb 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required for checking mock logic

"spID", syncerInfo.GetStorageProviderId(), "index", syncerInfo.GetPieceIndex(), "count", syncerInfo.GetPieceCount(),
"redundancyType", syncerInfo.GetRedundancyType().String())
req = addReqHeader(req, syncerInfo, traceID)
log.Infow("request header", "header", req.Header)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debug log?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

log.Errorw("copy request body failed", "error", err)
return err
}
log.Error("error response body")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete the log?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deleted

PieceJob piece_job = 3;
ErrMessage err_message = 4;
string bucket_name = 3;
string object_name = 4;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add the field of pb between stone hub and stone node.
shoud add fill the field in stone hub?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@sysvm sysvm force-pushed the syncer_to_gateway branch from ee6b2a3 to 9da80d5 Compare February 21, 2023 03:54
@sysvm sysvm force-pushed the syncer_to_gateway branch from 9da80d5 to bc31299 Compare February 21, 2023 03:56
w.Header().Set(model.GnfdSealSignatureHeader, sig)
}

func handlePieceChecksum(pieceChecksum [][]byte) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions with similar functions in util/util.go maybe be reused

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

return strings.Join(list, ",")
}

func transferRedundancyType(redundancyType string) (ptypes.RedundancyType, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Functions with similar functions in util/util.go maybe be reused

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use different transfer type, so this similar function in util/util.go doesn't satisfy mine.

)

// syncPiece send rpc request to secondary storage provider to sync the piece data
func (g *Gateway) syncPiece(ctx context.Context, syncerInfo *stypes.SyncerInfo, pieceData [][]byte, traceID string) (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At present, there is no abstract layer of processor. Consider unifying it in the future

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix it later

model/const.go Outdated
RangeHeader = "Range"
ContentRangeHeader = "Content-Range"
// StoneNode to gateway request header
GnfdTraceIDHeader = "X-Gnfd-Trace-ID"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reuse GnfdRequestIDHeader?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Copy link
Collaborator

@will-2012 will-2012 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -62,6 +62,7 @@ func (g *Gateway) syncPieceHandler(w http.ResponseWriter, r *http.Request) {
errDescription = InternalError
}
addRespHeader(resp, w)
log.Info("sync piece handler reply response to stone node")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: add detail log at input and output site, it will comfortable to debug

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@sysvm sysvm force-pushed the syncer_to_gateway branch from 6a1c2e3 to 845cc91 Compare February 21, 2023 12:27
@joeylichang joeylichang merged commit d26b18b into develop Feb 21, 2023
@sysvm sysvm deleted the syncer_to_gateway branch February 21, 2023 12:45
joeylichang added a commit that referenced this pull request Feb 26, 2023
* fix: docker push bug (#115)

* feat: add stone load and gc workflow (#117)

* feat: add iterator and batch interface to db

* chore: delete memory job db v1 code

* feat: impl the iterator and batch of job memory db

* feat: add stone load and gc db

* chore: delete job sql db v1 impl

* feat: job sql add iterator and batcher interface

* refactor: rename job_db v2 interface to job_db interface

---------

Co-authored-by: joeylichang <joeycli0919@gmail.com>

* feat: implement signer service (#119)

* feat: implement signer service

* feat: add api auth and ip whitelist for signer

* refactor: redesign the interface of singer service

* refactor: use greenfield-go-sdk

* fix: msg to be signed should not be pre-hashed

* feat: add VerifyBucketApproval, VerifyObjectApproval interface

* feat: add signer client

---------

Co-authored-by: joeylichang <joeycli0919@gmail.com>

* feat: client opt (#129)

* feat: implement gateway challenge workflow (#127)

* feat: implement gateway challenge workflow

* feat: support get range object

* read:block_syncer

* read:block_syncer

* read:block-syncer

* read:block-syncer

* fix: use env var to get bucket url (#130)

* fix: use env var to get bucket url

* fix: improve loading config from env function

* fix: rename variable names

* fix: change piece store readme.md

---------

Co-authored-by: DylanYong <dylan.y@nodereal.io>

* read:toml

* feat: stone node sends piece data to gateway (#128)

* feat: stone node sends piece data to gateway

* feat: alloc resp add bucket name and object name

* fix: fix errors of stone node uint test

* fix: fix gateway config

* fix: add gateway syncer rpc ut

* fix: add one log in gateway sync piece handler func

* fix: add detailed log in gateway sync piece handler

---------

Co-authored-by: DylanYong <dylan.y@nodereal.io>

* read:cmd_complete

* read:del

* read:test-job

* read:block-syncer-frame

* read:fix

* fix: upgrade greenfield version to fix the signing bug (#133)

* ci: fix release job

* dep: upgrade greenfield version

* fix: unit test for gnfd sign client

* fix: signer adapt to on-chain logic (#136)

* feat: add metadata service to sp (#132)

* feat: init commit

* feat: register metadata service and run on 9733 port

* feat: impl ListObjectsByBucketName api & model update

* feat: cleanup files and add metadata service sdk

* feat: add mock and unit tests

* feat: uniform error return values

* feat: metadata service case_driver update

---------

Co-authored-by: BarryTong65 <barrytong.work@gmail.com>
Co-authored-by: joeycli <joeycli0919@gmail.com>

* read:del

* read:block-syncer-update

* read:block-syncer-db

* fix: use greenfield-go-sdk and upgrade lib version (#135)

* fix: use greenfield-go-sdk and upgrade lib version

* ci: rename main to master

* fix: update greenfield-common version

---------

Co-authored-by: DylanYong <dylan.y@nodereal.io>

* feat: add chain client to sp (#131)

* feat: impl the interaction between sp and chain interface

* fix: return bucket id from auth object

* feat: add check authorization

* feat: add chain client to stonehub

* feat: add chain client to uploader/downloader

* feat: implement get approval workflow

* feat: implement object seal and integrity hash sign workflow

* chore: update dependencies

* feat:implement secondary sp integrity hash sign workflow

* test: add signer and chain to onebox

* fix: fix itergrated test bug

---------

Co-authored-by: joeylichang <joeycli0919@gmail.com>

---------

Co-authored-by: joeycli <joeycli0919@gmail.com>
Co-authored-by: dylanhuang <j75689@gmail.com>
Co-authored-by: constwz <changbohao30@gmail.com>
Co-authored-by: VM <112189277+sysvm@users.noreply.github.com>
Co-authored-by: DylanYong <dylan.y@nodereal.io>
Co-authored-by: constwz <122766871+constwz@users.noreply.github.com>
Co-authored-by: Annie <108039750+annielz@users.noreply.github.com>
Co-authored-by: BarryTong65 <barrytong.work@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants