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

Worker builds binary in case the binary doesn't match the worker arch #200

Merged
merged 52 commits into from
Sep 4, 2019

Conversation

Skarlso
Copy link
Member

@Skarlso Skarlso commented Jul 25, 2019

@michelvocks Alright! This works, but, as you can see I had to export two of the none exported functions, NewBuild and GitPull. I can't use the Create one directly because that tries to store things in the db to which the worker doesn't have access to.

I'll try to refactor this, I just wanted to share with you the current progress.

@Skarlso Skarlso added the Needs Work The PR still requires some work from the submitter. label Jul 25, 2019
@codecov-io
Copy link

codecov-io commented Jul 25, 2019

Codecov Report

Merging #200 into master will increase coverage by 0.01%.
The diff coverage is 51.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #200      +/-   ##
==========================================
+ Coverage   62.11%   62.13%   +0.01%     
==========================================
  Files          48       49       +1     
  Lines        3944     4046     +102     
==========================================
+ Hits         2450     2514      +64     
- Misses       1086     1117      +31     
- Partials      408      415       +7
Impacted Files Coverage Δ
workers/agent/agent.go 49.63% <40.44%> (+0.95%) ⬆️
store/sha_pair.go 63.15% <63.15%> (ø)
workers/server/worker.go 50% <68%> (+1.94%) ⬆️
store/store.go 74.28% <70%> (+6.78%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7c0f920...5ca5149. Read the comment docs.

workers/agent/agent.go Outdated Show resolved Hide resolved
workers/agent/agent.go Outdated Show resolved Hide resolved
workers/agent/agent.go Outdated Show resolved Hide resolved
workers/proto/worker.pb.go Outdated Show resolved Hide resolved
workers/server/worker.go Show resolved Hide resolved
@Skarlso Skarlso force-pushed the issues_194_worker_builds_binary branch from 05ceb45 to f491cca Compare July 26, 2019 20:54
@Skarlso
Copy link
Member Author

Skarlso commented Jul 26, 2019

@michelvocks So this works, however. On the previous iteration I wasn't saving the pipeline as a new create run. Now I am with create. On the previous iteration this lead to a nice thing where it didn't rebuild the pipeline again once the worker rebuild it for itself. Now it's always rebuilding and I'm not exactly sure why. Probably because I'm always creating a new CreatePipeline entry?

I also refactored a code a bit. ;)

go.sum Outdated Show resolved Hide resolved
@Skarlso
Copy link
Member Author

Skarlso commented Aug 22, 2019

This f*cker runs for 44 seconds.

@Skarlso Skarlso force-pushed the issues_194_worker_builds_binary branch from 1029308 to 48ca7f6 Compare August 25, 2019 20:01
@Skarlso
Copy link
Member Author

Skarlso commented Aug 25, 2019

@michelvocks Alright, this is as ready as it gets. I'll add some more coverage later on. Tell me if you like the SHAPair approach. :)

store/memdb/memdb.go Outdated Show resolved Hide resolved
workers/agent/agent.go Outdated Show resolved Hide resolved
workers/agent/agent.go Outdated Show resolved Hide resolved
@Skarlso
Copy link
Member Author

Skarlso commented Sep 3, 2019

Buuu

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x78 pc=0x10b10eb]

goroutine 246 [running]:
github.com/gaia-pipeline/gaia/handlers.(*mockStorageService).PipelineGetScheduled(0xc0002ec000, 0x32, 0xd65c103098ff4d62, 0x49b949fa3e89058a, 0x64e2d54e4c776eb3, 0x729f546e92990536, 0x542df71cb26c69b0)
	<autogenerated>:1 +0x6b
github.com/gaia-pipeline/gaia/workers/scheduler.(*Scheduler).schedule(0xc0000dca20)
	/go/src/github.com/gaia-pipeline/gaia/workers/scheduler/scheduler.go:234 +0xd1
github.com/gaia-pipeline/gaia/workers/scheduler.(*Scheduler).Init.func1(0xc0003ec870, 0xc0000dca20)
	/go/src/github.com/gaia-pipeline/gaia/workers/scheduler/scheduler.go:126 +0x4d
created by github.com/gaia-pipeline/gaia/workers/scheduler.(*Scheduler).Init
	/go/src/github.com/gaia-pipeline/gaia/workers/scheduler/scheduler.go:121 +0xdd
FAIL	github.com/gaia-pipeline/gaia/handlers	7.157s
Exited with code 1

:(

I'll try to take a look at this and fix it. It's bat that it can do that.

return err

// Make sure buckets exist
setP.update(userBucket)
Copy link
Member Author

@Skarlso Skarlso Sep 3, 2019

Choose a reason for hiding this comment

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

@michelvocks Sorry, I had to refactor this in this batch. It was too repetitive. :) Besides, you touch it you own it. :D

Copy link
Member

Choose a reason for hiding this comment

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

😄 good job!

@Skarlso Skarlso force-pushed the issues_194_worker_builds_binary branch from ba5371f to e098b75 Compare September 3, 2019 12:40
@Skarlso
Copy link
Member Author

Skarlso commented Sep 3, 2019

Testing

Vagrant: vagrant init ubuntu/bionic64.
vim Vagrantfile -> uncomment public_network.
vagrant up
git clone gaia
checkout the pr
get a gaia config which creates a worker that points to the host machines IP address
run it -- it should connect
---- works ----

  • create a pipeline and run that pipeline
  • worker should rebuild the pipeline and execute it successfully

Screenshot 2019-09-03 at 17 23 06

  • run it again
    Huh, nope.. SHA mismatch. -- Gotta check this. :/
    Oh I know why. Because uniqueID is actually always Unique. :D I need pipelineID here. :)
  • worker should just run what it already has without rebuilding
    YESS!!
2019-09-03T15:42:55.064Z [INFO ] Gaia: received work from Gaia primary instance...
2019-09-03T15:42:55.134Z [DEBUG] Gaia: record found for pipeline... comparing.
2019-09-03T15:42:55.878Z [DEBUG] plugin: starting plugin: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang args=[]
2019-09-03T15:42:55.878Z [DEBUG] plugin: waiting for RPC address: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang
2019-09-03T15:42:56.150Z [DEBUG] plugin: plugin process exited: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang
2019-09-03T15:42:58.032Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:42:58.033Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...
2019-09-03T15:42:58.549Z [DEBUG] plugin: starting plugin: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang args=[]
2019-09-03T15:42:58.549Z [DEBUG] plugin: waiting for RPC address: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang
2019-09-03T15:42:58.561Z [DEBUG] plugin.test-worker-rebuild-2_golang: 2019/09/03 15:42:58 CreateUser has been started!
2019-09-03T15:43:01.031Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:43:01.033Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...

Found the record and moved on the run the rebuilt binary.

Success
Screenshot 2019-09-03 at 17 43 59

  • change the pipeline

  • worker should rebuild again since the original pipeline changed
    Worked!

  • Stop the worker then re-send the same pipeline. It should still work.

^C2019-09-03T15:44:43.786Z [INFO ] Gaia: exit signal received. Exiting...
vagrant@ubuntu-bionic:~/goproject/gaia$ ./main
2019-09-03T15:44:46.029Z [DEBUG] Gaia: executeable path found: path=/home/vagrant/goproject/gaia
2019-09-03T15:44:49.033Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:44:49.036Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...
2019-09-03T15:44:52.034Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:44:52.035Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...
2019-09-03T15:44:55.034Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:44:55.035Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...
2019-09-03T15:44:58.034Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:44:58.036Z [INFO ] Gaia: received work from Gaia primary instance...
2019-09-03T15:44:58.112Z [DEBUG] Gaia: record found for pipeline... comparing.
2019-09-03T15:44:58.562Z [DEBUG] plugin: starting plugin: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang args=[]
2019-09-03T15:44:58.563Z [DEBUG] plugin: waiting for RPC address: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang
2019-09-03T15:44:58.833Z [DEBUG] plugin: plugin process exited: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang
2019-09-03T15:45:01.034Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:45:01.041Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...
2019-09-03T15:45:01.430Z [DEBUG] plugin: starting plugin: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang args=[]
2019-09-03T15:45:01.431Z [DEBUG] plugin: waiting for RPC address: path=/home/vagrant/goproject/gaia/pipelines/test-worker-rebuild-2_golang
2019-09-03T15:45:01.447Z [DEBUG] plugin.test-worker-rebuild-2_golang: 2019/09/03 15:45:01 CreateUser has been started!
2019-09-03T15:45:04.036Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:45:04.045Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...
2019-09-03T15:45:06.448Z [DEBUG] plugin.test-worker-rebuild-2_golang: 2019/09/03 15:45:06 CreateUser has been finished!
2019-09-03T15:45:06.450Z [DEBUG] plugin.test-worker-rebuild-2_golang: 2019/09/03 15:45:06 MigrateDB has been started!
2019-09-03T15:45:07.033Z [TRACE] Gaia: try to pull work from Gaia primary instance...
2019-09-03T15:45:07.034Z [TRACE] Gaia: got no work from Gaia primary instance. Will try it again after a while...

ALL TESTS PASSED

@Skarlso Skarlso added the Ready To Merge PR is ready to be merged into master label Sep 4, 2019
Copy link
Member

@michelvocks michelvocks left a comment

Choose a reason for hiding this comment

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

LGTM ❤️

store/sha_pair.go Outdated Show resolved Hide resolved
store/sha_pair.go Outdated Show resolved Hide resolved
store/sha_pair.go Outdated Show resolved Hide resolved
@Skarlso Skarlso merged commit 32bf82c into gaia-pipeline:master Sep 4, 2019
@Skarlso Skarlso deleted the issues_194_worker_builds_binary branch September 4, 2019 10:55
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 51.63399% with 74 lines in your changes missing coverage. Please review.

Project coverage is 62.13%. Comparing base (7c0f920) to head (5ca5149).
Report is 55 commits behind head on master.

Files with missing lines Patch % Lines
workers/agent/agent.go 40.44% 43 Missing and 10 partials ⚠️
workers/server/worker.go 68.00% 5 Missing and 3 partials ⚠️
store/sha_pair.go 63.15% 4 Missing and 3 partials ⚠️
store/store.go 70.00% 3 Missing and 3 partials ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #200      +/-   ##
==========================================
+ Coverage   62.11%   62.13%   +0.01%     
==========================================
  Files          48       49       +1     
  Lines        3944     4046     +102     
==========================================
+ Hits         2450     2514      +64     
- Misses       1086     1117      +31     
- Partials      408      415       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs review Ready To Merge PR is ready to be merged into master
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants