Upgrade go-marathon to 15ea23e.
Our vendored copy contains a bug that causes unavailable Marathon nodes to never be marked as available again due to a misconstruction in the URL to the Marathon health check / ping endpoint used by go-marathon internally. A fix[1] has been published. [1]https://github.com/gambol99/go-marathon/pull/283
This commit is contained in:
parent
2e762e76f3
commit
219a6372b0
10 changed files with 126 additions and 72 deletions
64
vendor/github.com/gambol99/go-marathon/application.go
generated
vendored
64
vendor/github.com/gambol99/go-marathon/application.go
generated
vendored
|
@ -89,6 +89,8 @@ type Application struct {
|
|||
TaskStats map[string]TaskStats `json:"taskStats,omitempty"`
|
||||
User string `json:"user,omitempty"`
|
||||
UpgradeStrategy *UpgradeStrategy `json:"upgradeStrategy,omitempty"`
|
||||
UnreachableStrategy *UnreachableStrategy `json:"unreachableStrategy,omitempty"`
|
||||
KillSelection string `json:"killSelection,omitempty"`
|
||||
Uris *[]string `json:"uris,omitempty"`
|
||||
Version string `json:"version,omitempty"`
|
||||
VersionInfo *VersionInfo `json:"versionInfo,omitempty"`
|
||||
|
@ -453,7 +455,7 @@ func (r *Application) DeploymentIDs() []*DeploymentID {
|
|||
// CheckHTTP adds a HTTP check to an application
|
||||
// port: the port the check should be checking
|
||||
// interval: the interval in seconds the check should be performed
|
||||
func (r *Application) CheckHTTP(uri string, port, interval int) (*Application, error) {
|
||||
func (r *Application) CheckHTTP(path string, port, interval int) (*Application, error) {
|
||||
if r.Container == nil || r.Container.Docker == nil {
|
||||
return nil, ErrNoApplicationContainer
|
||||
}
|
||||
|
@ -464,7 +466,7 @@ func (r *Application) CheckHTTP(uri string, port, interval int) (*Application, e
|
|||
}
|
||||
health := NewDefaultHealthCheck()
|
||||
health.IntervalSeconds = interval
|
||||
*health.Path = uri
|
||||
*health.Path = path
|
||||
*health.PortIndex = portIndex
|
||||
// step: add to the checks
|
||||
r.AddHealthCheck(*health)
|
||||
|
@ -555,6 +557,20 @@ func (r *Application) EmptyUpgradeStrategy() *Application {
|
|||
return r
|
||||
}
|
||||
|
||||
// SetUnreachableStrategy sets the unreachable strategy.
|
||||
func (r *Application) SetUnreachableStrategy(us UnreachableStrategy) *Application {
|
||||
r.UnreachableStrategy = &us
|
||||
return r
|
||||
}
|
||||
|
||||
// EmptyUnreachableStrategy explicitly empties the unreachable strategy -- use this if
|
||||
// you need to empty the unreachable strategy of an application that already has
|
||||
// the unreachable strategy set (setting it to nil will keep the current value).
|
||||
func (r *Application) EmptyUnreachableStrategy() *Application {
|
||||
r.UnreachableStrategy = &UnreachableStrategy{}
|
||||
return r
|
||||
}
|
||||
|
||||
// String returns the json representation of this application
|
||||
func (r *Application) String() string {
|
||||
s, err := json.MarshalIndent(r, "", " ")
|
||||
|
@ -611,9 +627,9 @@ func (r *marathonClient) HasApplicationVersion(name, version string) (bool, erro
|
|||
// ApplicationVersions is a list of versions which has been deployed with marathon for a specific application
|
||||
// name: the id used to identify the application
|
||||
func (r *marathonClient) ApplicationVersions(name string) (*ApplicationVersions, error) {
|
||||
uri := fmt.Sprintf("%s/versions", buildURI(name))
|
||||
path := fmt.Sprintf("%s/versions", buildPath(name))
|
||||
versions := new(ApplicationVersions)
|
||||
if err := r.apiGet(uri, nil, versions); err != nil {
|
||||
if err := r.apiGet(path, nil, versions); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return versions, nil
|
||||
|
@ -623,9 +639,9 @@ func (r *marathonClient) ApplicationVersions(name string) (*ApplicationVersions,
|
|||
// name: the id used to identify the application
|
||||
// version: the version (normally a timestamp) you wish to change to
|
||||
func (r *marathonClient) SetApplicationVersion(name string, version *ApplicationVersion) (*DeploymentID, error) {
|
||||
uri := fmt.Sprintf(buildURI(name))
|
||||
path := fmt.Sprintf(buildPath(name))
|
||||
deploymentID := new(DeploymentID)
|
||||
if err := r.apiPut(uri, version, deploymentID); err != nil {
|
||||
if err := r.apiPut(path, version, deploymentID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -639,7 +655,7 @@ func (r *marathonClient) Application(name string) (*Application, error) {
|
|||
Application *Application `json:"app"`
|
||||
}
|
||||
|
||||
if err := r.apiGet(buildURI(name), nil, &wrapper); err != nil {
|
||||
if err := r.apiGet(buildPath(name), nil, &wrapper); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -650,7 +666,7 @@ func (r *marathonClient) Application(name string) (*Application, error) {
|
|||
// name: the id used to identify the application
|
||||
// opts: GetAppOpts request payload
|
||||
func (r *marathonClient) ApplicationBy(name string, opts *GetAppOpts) (*Application, error) {
|
||||
u, err := addOptions(buildURI(name), opts)
|
||||
path, err := addOptions(buildPath(name), opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -658,7 +674,7 @@ func (r *marathonClient) ApplicationBy(name string, opts *GetAppOpts) (*Applicat
|
|||
Application *Application `json:"app"`
|
||||
}
|
||||
|
||||
if err := r.apiGet(u, nil, &wrapper); err != nil {
|
||||
if err := r.apiGet(path, nil, &wrapper); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -671,8 +687,8 @@ func (r *marathonClient) ApplicationBy(name string, opts *GetAppOpts) (*Applicat
|
|||
func (r *marathonClient) ApplicationByVersion(name, version string) (*Application, error) {
|
||||
app := new(Application)
|
||||
|
||||
uri := fmt.Sprintf("%s/versions/%s", buildURI(name), version)
|
||||
if err := r.apiGet(uri, nil, app); err != nil {
|
||||
path := fmt.Sprintf("%s/versions/%s", buildPath(name), version)
|
||||
if err := r.apiGet(path, nil, app); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -779,10 +795,10 @@ func (r *marathonClient) appExistAndRunning(name string) bool {
|
|||
// name: the id used to identify the application
|
||||
// force: used to force the delete operation in case of blocked deployment
|
||||
func (r *marathonClient) DeleteApplication(name string, force bool) (*DeploymentID, error) {
|
||||
uri := buildURIWithForceParam(name, force)
|
||||
path := buildPathWithForceParam(name, force)
|
||||
// step: check of the application already exists
|
||||
deployID := new(DeploymentID)
|
||||
if err := r.apiDelete(uri, nil, deployID); err != nil {
|
||||
if err := r.apiDelete(path, nil, deployID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -794,8 +810,8 @@ func (r *marathonClient) DeleteApplication(name string, force bool) (*Deployment
|
|||
func (r *marathonClient) RestartApplication(name string, force bool) (*DeploymentID, error) {
|
||||
deployment := new(DeploymentID)
|
||||
var options struct{}
|
||||
uri := buildURIWithForceParam(fmt.Sprintf("%s/restart", name), force)
|
||||
if err := r.apiPost(uri, &options, deployment); err != nil {
|
||||
path := buildPathWithForceParam(fmt.Sprintf("%s/restart", name), force)
|
||||
if err := r.apiPost(path, &options, deployment); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -810,9 +826,9 @@ func (r *marathonClient) ScaleApplicationInstances(name string, instances int, f
|
|||
changes := new(Application)
|
||||
changes.ID = validateID(name)
|
||||
changes.Instances = &instances
|
||||
uri := buildURIWithForceParam(name, force)
|
||||
path := buildPathWithForceParam(name, force)
|
||||
deployID := new(DeploymentID)
|
||||
if err := r.apiPut(uri, changes, deployID); err != nil {
|
||||
if err := r.apiPut(path, changes, deployID); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
@ -823,22 +839,22 @@ func (r *marathonClient) ScaleApplicationInstances(name string, instances int, f
|
|||
// application: the structure holding the application configuration
|
||||
func (r *marathonClient) UpdateApplication(application *Application, force bool) (*DeploymentID, error) {
|
||||
result := new(DeploymentID)
|
||||
uri := buildURIWithForceParam(application.ID, force)
|
||||
if err := r.apiPut(uri, application, result); err != nil {
|
||||
path := buildPathWithForceParam(application.ID, force)
|
||||
if err := r.apiPut(path, application, result); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func buildURIWithForceParam(path string, force bool) string {
|
||||
uri := buildURI(path)
|
||||
func buildPathWithForceParam(rootPath string, force bool) string {
|
||||
path := buildPath(rootPath)
|
||||
if force {
|
||||
uri += "?force=true"
|
||||
path += "?force=true"
|
||||
}
|
||||
return uri
|
||||
return path
|
||||
}
|
||||
|
||||
func buildURI(path string) string {
|
||||
func buildPath(path string) string {
|
||||
return fmt.Sprintf("%s/%s", marathonAPIApps, trimRootPath(path))
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue