Automation support #10
No reviewers
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
dependencies
Epic
good first issue
hacktoberfest
help wanted
icebox
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbry.go#10
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "automation-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This addresses https://github.com/lbryio/internal-issues/issues/165
@nikooo777 Is this ready for review?
negative Tom :) it's work in progress
@lyoshenka there is a lot of work in here, It's not yet ready to be merged but if you want you can take a look at it already and let me know what I should change I'm happy with it.
There is some code reuse that I'd like to address and logging is inconsistent: some goes to slack and some doesn't.
overall these changes look very messy. I know my ytsync code was messy to begin with, so I'm partially to blame as well. but now that we're planning to use the code for a while, we should come up with a coherent structure and move towards cleaner code. i can discuss with you if you want.
this is not common to
cmd
. this is common toytsync
. you also don't need a separatecommon.go
file. just put it in an existing filewhat is this?
don't hardcode this url. the API domain and endpoints should be configured somewhere
keep the cmd package very small. it should just gather the CLI options and call a function in the ytsync package.
lbry.go
is shared across many different projects. keep your changes inytsync
package as much as possible.are you making calls to the live API here? this is a very weak test. and you're including the auth_token in public code that's visible on github?
please avoid having a util package as much as possible. it becomes a dump for random code. this function is only used in the cmd package, so it can just be declared there
i think this is gonna be in beamer's PR, but it should not go into
util
either. we should make our ownslack
package.this should be SendErrorToSlack. and really, it should be it's own package called
slack
so you can simplyslack.Error("stuff")
instead ofutil.SendErrorToSlack("stuff")
lbry.go is a general package used in lots of other places. you can't have a general util function called sendToSlack that says YTSYNC in the message. all ytsync-specific stuff should go into the ytsync package
this doesn't test anything
this needs a better name
@ -39,1 +42,4 @@
log.Debugf("Source channel has %d videos", numOnSource)
if numOnSource == 0 {
return nil
}
why?
@ -140,6 +156,7 @@ func (s *Sync) ensureEnoughUTXOs() error {
}
func (s *Sync) waitUntilUTXOsConfirmed() error {
origin := time.Now()
restarting the daemon should be its own function
does this still happen with lbryumx?
@ -197,3 +206,3 @@
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) error {
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
//download and thumbnail can be done in parallel
err := v.download()
err is not a delete error here, its the publish error
use
errors.Prefix
so you don't lose the original trace@ -254,1 +330,3 @@
log.Println(err.Error())
s.grp.Stop()
SendErrorToSlack("Failed to setup the wallet for a refill: %v", err)
break
what i meant was, why not just download the thumbnail from youtube to s3. why do we need some remote JS function running to do this?
also, if you're gonna answer questions in comments, delete the question and simply explain what the code is doing.
just to make this clear. the first parameter is the auth token, which is just a number as I'm using this "test" locally. The second parameter is a channel ID.
I basically wrote tests to run the portion of code without having to compile and run the whole program, I believe more code should be tested in a better way. I don't think any of the tests here actually test anything.
Also yesh, I'm calling a local API, not the live API, but the right approach would be to mock the API.
@ -39,1 +42,4 @@
log.Debugf("Source channel has %d videos", numOnSource)
if numOnSource == 0 {
return nil
}
The main reason is that while we publish for 0.01 LBC, the fees are up to 0.1LBC.
In a future approach we'll have to change this to just calculate the fees and add 0.01LBC on top of it
the other solution we discussed worked too :)
@ -39,1 +42,4 @@
log.Debugf("Source channel has %d videos", numOnSource)
if numOnSource == 0 {
return nil
}
oh, that makes sense. when i wrote this, we did not have fees based on claim name length
https://github.com/lbryio/lbry/issues/1192#issuecomment-392816078
@lyoshenka if @nikooo777 is using this in production does it really make sense to continue to block merging this?
https://github.com/lbryio/lbry.go/issues/22
why the switch from
ytsync
toselfsync
. This package is calledlbry.go
, so its very general.selfsync
is too generic a name.@ -37,8 +46,11 @@ func SendToSlackChannel(channel, username, message string) error {
}
these functions should not be in slack.go. first of all, they log the error twice, since
sendToSlack
already calls log.Debugln. second, all they do is add an emoji. you can put these functions someplace in the ytsync package if they are used a lot there, but they should not be out here.however, using
fmt.Sprintf
is a nice touch. i support adding that to the existing Send functions.name is not that clear. if you saw two functions
InSlice
andContainedInSlice
, could you tell what the difference was?I'd call this something like
SubstringInSlice
also please use the same var names as InSlice (
str
,values
) for consistency, unless different names would add clarity.perhaps these constants should be shared with internal-apis? then they're not defined in two places.
maybe include the erroneous response in the error?
os.Getenv() should not be used here. that should happen in
cmd
. syncmanager should be initialized with the correct keys. that way it can be used in tests, in other packages, etcblobfiles dir should be configurable
@ -37,6 +40,9 @@ func (s *Sync) walletSetup() error {
}
fyi this can happen if the channel owner also publishes other videos into the channel
checking the message is not the right way to detect if the dir exists. google it or ask me if you're not sure
v.dir+"/"+v.id
should be a function, since its used in multiple places. maybevideoDir()
?@ -195,3 +204,3 @@
}
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) error {
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
why are we ignoring the error? do errors happen here? i'd at least log it. same above.
@ -116,3 +170,4 @@
logShutdownError(processDeathError)
} else {
walletErr := os.Rename(defaultWalletDir, walletBackupDir)
if walletErr != nil {
this is pretty confusing. id rather put the rest of FullCycle into another function, call that function, then check the error message and run this deferred stuff on it
its kinda redundant to have two Prefix-ings. you can just do
e = errors.Prefix(msg + ":" + err.Error(), e)
since you now have a SyncManager that gets configured, this stuff should come from the SyncManager. it should not be set here. as before, calling os.Getenv() here is weird. I know my code did this before, but that should be changed now.
👍
the other functions you added to util/slack.go should go here as well
fatalErrorSubstrings
you're right. I had this built when ytsync was still there, that's why it had a different name. I will change it back.
good idea! should i put them in a package of their own?
Ok! I'll move them there
Will export it to an env var
@ -37,6 +40,9 @@ func (s *Sync) walletSetup() error {
}
yes if we'll allow publishing to channels while we also keep them in sync then this will be the case. otherwise this happens when channel owners delete videos from their youtube channel
@ -195,3 +204,3 @@
}
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) error {
func (v YoutubeVideo) Sync(daemon *jsonrpc.Client, claimAddress string, amount float64, channelName string) (*SyncSummary, error) {
the error is logged within the function. I had the same thoughts the other day and couldn't understand my reasoning until when I checked the function itself. Perhaps I should drop logging within the function and log it here? Also we ignore the error because deleting is not something that will compromise publishing and we can take care of that "offline"
Actually, the way they reside in the code will make them available through the ytsync package once this is merged in master. So nothing to change here I believe
Actually, this is not meant to check if a directory exists, instead it's meant to report any error other than "file exists". This is due to the fact that each video has its own subdirectory to avoid name conflicts and if for some reasons the video was previously downloaded (ie on a retry attempt) the directory doesn't have to be re-created.
If however you think I should check for the directory before calling mkdir then I will adapt the code.