Adding force Implicit and force Explicit recon to gorealis. (#81)
This commit is contained in:
parent
231793df71
commit
2306d6180f
3 changed files with 69 additions and 2 deletions
|
@ -605,6 +605,20 @@ func main() {
|
||||||
log.Fatalf("error: %+v\n", err.Error())
|
log.Fatalf("error: %+v\n", err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case "forceExplicitRecon":
|
||||||
|
fmt.Println("Force an explicit recon")
|
||||||
|
err := r.ForceExplicitTaskReconciliation(nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error: %+v\n", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
case "forceImplicitRecon":
|
||||||
|
fmt.Println("Force an implicit recon")
|
||||||
|
err := r.ForceImplicitTaskReconciliation()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatalf("error: %+v\n", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Fatal("Command not supported")
|
log.Fatal("Command not supported")
|
||||||
}
|
}
|
||||||
|
|
37
realis.go
37
realis.go
|
@ -78,6 +78,10 @@ type Realis interface {
|
||||||
GetQuota(role string) (*aurora.Response, error)
|
GetQuota(role string) (*aurora.Response, error)
|
||||||
Snapshot() error
|
Snapshot() error
|
||||||
PerformBackup() error
|
PerformBackup() error
|
||||||
|
// Force an Implicit reconciliation between Mesos and Aurora
|
||||||
|
ForceImplicitTaskReconciliation() error
|
||||||
|
// Force an Explicit reconciliation between Mesos and Aurora
|
||||||
|
ForceExplicitTaskReconciliation(batchSize *int32) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type realisClient struct {
|
type realisClient struct {
|
||||||
|
@ -1112,3 +1116,36 @@ func (r *realisClient) PerformBackup() error {
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *realisClient) ForceImplicitTaskReconciliation() error {
|
||||||
|
|
||||||
|
_, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) {
|
||||||
|
return r.adminClient.TriggerImplicitTaskReconciliation()
|
||||||
|
})
|
||||||
|
|
||||||
|
if retryErr != nil {
|
||||||
|
return errors.Wrap(retryErr, "Unable to recover connection")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *realisClient) ForceExplicitTaskReconciliation(batchSize *int32) error {
|
||||||
|
|
||||||
|
if batchSize != nil && *batchSize < 1 {
|
||||||
|
return errors.New("Invalid batch size.")
|
||||||
|
}
|
||||||
|
settings := aurora.NewExplicitReconciliationSettings()
|
||||||
|
|
||||||
|
settings.BatchSize = batchSize
|
||||||
|
|
||||||
|
_, retryErr := r.thriftCallWithRetries(func() (*aurora.Response, error) {
|
||||||
|
return r.adminClient.TriggerExplicitTaskReconciliation(settings)
|
||||||
|
})
|
||||||
|
|
||||||
|
if retryErr != nil {
|
||||||
|
return errors.Wrap(retryErr, "Unable to recover connection")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
|
@ -18,11 +18,10 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/paypal/gorealis"
|
"github.com/paypal/gorealis"
|
||||||
"github.com/paypal/gorealis/gen-go/apache/aurora"
|
"github.com/paypal/gorealis/gen-go/apache/aurora"
|
||||||
"github.com/paypal/gorealis/response"
|
"github.com/paypal/gorealis/response"
|
||||||
|
@ -294,6 +293,7 @@ func TestRealisClient_CreateService(t *testing.T) {
|
||||||
IsService(true)
|
IsService(true)
|
||||||
|
|
||||||
settings := realis.NewUpdateSettings()
|
settings := realis.NewUpdateSettings()
|
||||||
|
settings.UpdateGroupSize = 2
|
||||||
job.InstanceCount(3)
|
job.InstanceCount(3)
|
||||||
resp, result, err := r.CreateService(job, settings)
|
resp, result, err := r.CreateService(job, settings)
|
||||||
|
|
||||||
|
@ -521,3 +521,19 @@ func TestRealisClient_SetQuota(t *testing.T) {
|
||||||
fmt.Print("GetQuota Result", result.String())
|
fmt.Print("GetQuota Result", result.String())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRealisClient_ForceImplicitTaskReconciliation(t *testing.T) {
|
||||||
|
err := r.ForceImplicitTaskReconciliation()
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestRealisClient_ForceExplicitTaskReconciliation(t *testing.T) {
|
||||||
|
// Default value
|
||||||
|
err := r.ForceExplicitTaskReconciliation(nil)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
|
||||||
|
// Custom batch value
|
||||||
|
var batchSize int32 = 32
|
||||||
|
err = r.ForceExplicitTaskReconciliation(&batchSize)
|
||||||
|
assert.NoError(t, err)
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue