-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into machine-pool-auto-scaling
- Loading branch information
Showing
34 changed files
with
1,004 additions
and
457 deletions.
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
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
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
42 changes: 42 additions & 0 deletions
42
cmd/metal-api/internal/datastore/migrations/05_allocation_uuids.go
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,42 @@ | ||
package migrations | ||
|
||
import ( | ||
r "gopkg.in/rethinkdb/rethinkdb-go.v6" | ||
|
||
"github.com/google/uuid" | ||
"github.com/metal-stack/metal-api/cmd/metal-api/internal/datastore" | ||
) | ||
|
||
func init() { | ||
datastore.MustRegisterMigration(datastore.Migration{ | ||
Name: "generate allocation uuids for already allocated machines", | ||
Version: 5, | ||
Up: func(db *r.Term, session r.QueryExecutor, rs *datastore.RethinkStore) error { | ||
machines, err := rs.ListMachines() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
for _, m := range machines { | ||
m := m | ||
|
||
if m.Allocation == nil { | ||
continue | ||
} | ||
|
||
if m.Allocation.UUID != "" { | ||
continue | ||
} | ||
|
||
newMachine := m | ||
newMachine.Allocation.UUID = uuid.New().String() | ||
|
||
err = rs.UpdateMachine(&m, &newMachine) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
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
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.