mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1094 from aboch/rd
Use newly introduce plugins method to validate plugin response
This commit is contained in:
commit
77c66f968b
2 changed files with 4 additions and 7 deletions
|
@ -31,6 +31,8 @@ The remote driver protocol is a set of RPCs, issued as HTTP POSTs with JSON payl
|
|||
|
||||
If the remote process cannot decode, or otherwise detects a syntactic problem with the HTTP request or payload, it must respond with an HTTP error status (4xx or 5xx).
|
||||
|
||||
If the remote process http server receives a request for an unknown URI, it should respond with the HTTP StatusCode `404 Not Found`. This allows libnetwork to detect when a remote driver does not implement yet a newly added method, therefore not to deem the request as failed.
|
||||
|
||||
If the remote process can decode the request, but cannot complete the operation, it must send a response in the form
|
||||
|
||||
{
|
||||
|
|
|
@ -3,7 +3,6 @@ package remote
|
|||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
|
||||
log "github.com/Sirupsen/logrus"
|
||||
"github.com/docker/docker/pkg/plugins"
|
||||
|
@ -14,10 +13,6 @@ import (
|
|||
"github.com/docker/libnetwork/types"
|
||||
)
|
||||
|
||||
const (
|
||||
missingMethod = "404 page not found"
|
||||
)
|
||||
|
||||
type driver struct {
|
||||
endpoint *plugins.Client
|
||||
networkType string
|
||||
|
@ -260,7 +255,7 @@ func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string
|
|||
Options: options,
|
||||
}
|
||||
err := d.call("ProgramExternalConnectivity", data, &api.ProgramExternalConnectivityResponse{})
|
||||
if err != nil && strings.Contains(err.Error(), missingMethod) {
|
||||
if err != nil && plugins.IsNotFound(err) {
|
||||
// It is not mandatory yet to support this method
|
||||
return nil
|
||||
}
|
||||
|
@ -274,7 +269,7 @@ func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
|
|||
EndpointID: eid,
|
||||
}
|
||||
err := d.call("RevokeExternalConnectivity", data, &api.RevokeExternalConnectivityResponse{})
|
||||
if err != nil && strings.Contains(err.Error(), missingMethod) {
|
||||
if err != nil && plugins.IsNotFound(err) {
|
||||
// It is not mandatory yet to support this method
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue