1
0
Fork 0
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:
Jana Radhakrishnan 2016-04-08 23:27:15 -07:00
commit 77c66f968b
2 changed files with 4 additions and 7 deletions

View file

@ -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 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 If the remote process can decode the request, but cannot complete the operation, it must send a response in the form
{ {

View file

@ -3,7 +3,6 @@ package remote
import ( import (
"fmt" "fmt"
"net" "net"
"strings"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"github.com/docker/docker/pkg/plugins" "github.com/docker/docker/pkg/plugins"
@ -14,10 +13,6 @@ import (
"github.com/docker/libnetwork/types" "github.com/docker/libnetwork/types"
) )
const (
missingMethod = "404 page not found"
)
type driver struct { type driver struct {
endpoint *plugins.Client endpoint *plugins.Client
networkType string networkType string
@ -260,7 +255,7 @@ func (d *driver) ProgramExternalConnectivity(nid, eid string, options map[string
Options: options, Options: options,
} }
err := d.call("ProgramExternalConnectivity", data, &api.ProgramExternalConnectivityResponse{}) 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 // It is not mandatory yet to support this method
return nil return nil
} }
@ -274,7 +269,7 @@ func (d *driver) RevokeExternalConnectivity(nid, eid string) error {
EndpointID: eid, EndpointID: eid,
} }
err := d.call("RevokeExternalConnectivity", data, &api.RevokeExternalConnectivityResponse{}) 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 // It is not mandatory yet to support this method
return nil return nil
} }