-
Notifications
You must be signed in to change notification settings - Fork 243
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
Skarlso
merged 52 commits into
gaia-pipeline:master
from
Skarlso:issues_194_worker_builds_binary
Sep 4, 2019
Merged
Changes from all commits
Commits
Show all changes
52 commits
Select commit
Hold shift + click to select a range
265fb7d
Initial try to build binary by worker.
9557f27
A little bit of refactoring.
a56c272
Cleaning up the errorous binary.
Skarlso 763462d
A different approach.
Skarlso fc756b9
Creating an api which the worker can call to get information about th…
Skarlso 0e241f5
Skeleton of the api
Skarlso 43fab8f
Added more logic.
Skarlso f355109
Using the name instead
Skarlso 4bde3b2
Moar info
Skarlso 8c346ad
Added correct error display.
Skarlso 3ab6e20
RPC endpoint.
b19d052
Changed impl to gRPC
0b67ca3
Fixed wording and nil panic
Skarlso 5b22447
Using the ID instead.
Skarlso 52843de
Cannot save pipeline run
Skarlso 0045758
GitPull the repo...
Skarlso 73d8c18
Handling error
Skarlso 23198f9
It works!
Skarlso d5acea1
Agent test build failure.
Skarlso 9d19530
linter
Skarlso 7c5648b
Trying out createpipeline again.
Skarlso c5ff190
Extracting rebuilding of binary.
Skarlso 0e76372
Linting fix
Skarlso b625ee5
mergin...
Skarlso 4e00b1f
Merge branch 'master' into issues_194_worker_builds_binary
Skarlso c1dbc53
Fixed version of protoc-gen-go
Skarlso ef7784d
Create the skeleton for the sha pair work
7768c37
The skeleton is there. Daughter woke up I will have to continue this …
Skarlso 3cd8a84
Small adjustments.
Skarlso 30444f5
Added metadata uniqueid to shapair.
Skarlso 9ac6e38
Using pipelinID as string.
Skarlso 0fc686b
Working on checking if there was a record or not.
Skarlso b9ac24b
Fixed condition.
Skarlso 899b2bf
Added re-try of the failed operation after the binary has been rebuilt.
Skarlso 315db17
Fixed the test.
Skarlso ba10c67
Added test and nil check for private key.
Skarlso 3efb482
Deleting it for now... And then I will try to fix that.
Skarlso 91b094d
Removed gosdk.
Skarlso 1130104
Added a basic test case for the re-builder.
Skarlso c9e1bdf
Added test for the pipeline rebuilder.
820ff51
Some more coverage.
3c31dfb
TODO: Fix whatever is adding an extra run to the update workflow. It …
178a795
Fixed the test which was causing problems.
f773964
Passed test.
48ca7f6
Added moar coverage for the worker.
Skarlso 47ea5c9
Added coverage to sha pair methods.
Skarlso f2c29d2
Merge branch 'master' into issues_194_worker_builds_binary
e4744b9
Shifted the sha storing process into bolt db.
e098b75
Added tests and fixed bucket names.
ca090e3
Changed to PipelineID instead of UniqueID which was unique per run in…
41b0432
Fixed comments.
5ca5149
Renamed uniqueID field to pipelineid so it does not get accidentally …
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package store | ||
|
||
import ( | ||
"encoding/json" | ||
|
||
bolt "github.com/coreos/bbolt" | ||
"github.com/gaia-pipeline/gaia" | ||
) | ||
|
||
// UpsertSHAPair creates or updates a record for a SHA pair of the original SHA and the | ||
// rebuilt Worker SHA for a pipeline. | ||
func (s *BoltStore) UpsertSHAPair(pair gaia.SHAPair) error { | ||
return s.db.Update(func(tx *bolt.Tx) error { | ||
// Get bucket | ||
b := tx.Bucket(shaPairBucket) | ||
|
||
// Marshal SHAPair struct | ||
m, err := json.Marshal(pair) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// Put SHAPair | ||
return b.Put(itob(pair.PipelineID), m) | ||
}) | ||
} | ||
|
||
// GetSHAPair returns a pair of shas for this pipeline run. | ||
func (s *BoltStore) GetSHAPair(pipelineID int) (ok bool, pair gaia.SHAPair, err error) { | ||
return ok, pair, s.db.View(func(tx *bolt.Tx) error { | ||
// Get bucket | ||
b := tx.Bucket(shaPairBucket) | ||
|
||
// Get SHAPair | ||
v := b.Get(itob(pipelineID)) | ||
|
||
// Check if we found the SHAPair | ||
if v == nil { | ||
ok = false | ||
return nil | ||
} | ||
|
||
// Unmarshal SHAPair struct | ||
err := json.Unmarshal(v, &pair) | ||
if err != nil { | ||
return err | ||
} | ||
ok = true | ||
return nil | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
package store | ||
|
||
import ( | ||
"bytes" | ||
"io/ioutil" | ||
"os" | ||
"testing" | ||
|
||
"github.com/gaia-pipeline/gaia" | ||
) | ||
|
||
func TestGetSHAPair(t *testing.T) { | ||
// Create tmp folder | ||
tmp, err := ioutil.TempDir("", "TestGetSHAPAir") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(tmp) | ||
|
||
store := NewBoltStore() | ||
gaia.Cfg.Bolt.Mode = 0600 | ||
err = store.Init(tmp) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer store.Close() | ||
|
||
pair := gaia.SHAPair{} | ||
pair.PipelineID = 1 | ||
pair.Original = []byte("original") | ||
pair.Worker = []byte("worker") | ||
err = store.UpsertSHAPair(pair) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
ok, p, err := store.GetSHAPair(1) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !ok { | ||
t.Fatalf("sha pair not found") | ||
} | ||
|
||
if p.PipelineID != pair.PipelineID { | ||
t.Fatalf("pipeline id match error. want %d got %d", pair.PipelineID, p.PipelineID) | ||
} | ||
if !bytes.Equal(p.Worker, pair.Worker) { | ||
t.Fatalf("worker sha match error. want %s got %s", pair.Worker, p.Worker) | ||
} | ||
if !bytes.Equal(p.Original, pair.Original) { | ||
t.Fatalf("original sha match error. want %s got %s", pair.Original, p.Original) | ||
} | ||
} | ||
|
||
func TestUpsertSHAPair(t *testing.T) { | ||
// Create tmp folder | ||
tmp, err := ioutil.TempDir("", "TestUpsertSHAPair") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(tmp) | ||
|
||
store := NewBoltStore() | ||
gaia.Cfg.Bolt.Mode = 0600 | ||
err = store.Init(tmp) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer store.Close() | ||
|
||
pair := gaia.SHAPair{} | ||
pair.PipelineID = 1 | ||
pair.Original = []byte("original") | ||
pair.Worker = []byte("worker") | ||
err = store.UpsertSHAPair(pair) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
// Test is upsert overwrites existing records. | ||
pair.Original = []byte("original2") | ||
err = store.UpsertSHAPair(pair) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
ok, p, err := store.GetSHAPair(1) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
if !ok { | ||
t.Fatalf("sha pair not found") | ||
} | ||
|
||
if p.PipelineID != pair.PipelineID { | ||
t.Fatalf("pipeline id match error. want %d got %d", pair.PipelineID, p.PipelineID) | ||
} | ||
if !bytes.Equal(p.Worker, pair.Worker) { | ||
t.Fatalf("worker sha match error. want %s got %s", pair.Worker, p.Worker) | ||
} | ||
if !bytes.Equal(p.Original, pair.Original) { | ||
t.Fatalf("original sha match error. want %s got %s", pair.Original, p.Original) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😄 good job!