mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #1061 from darrenstahlmsft/WindowsNetworkQos
Added maximum egress bandwidth qos for Windows
This commit is contained in:
commit
292ea3fe43
3 changed files with 43 additions and 1 deletions
|
@ -12,4 +12,7 @@ const (
|
|||
|
||||
// Interface of the network
|
||||
Interface = "com.docker.network.windowsshim.interface"
|
||||
|
||||
// QosPolicies of the endpoint
|
||||
QosPolicies = "com.docker.endpoint.windowsshim.qospolicies"
|
||||
)
|
||||
|
|
|
@ -42,6 +42,7 @@ type endpointConfiguration struct {
|
|||
MacAddress net.HardwareAddr
|
||||
PortBindings []types.PortBinding
|
||||
ExposedPorts []types.TransportPort
|
||||
QosPolicies []types.QosPolicy
|
||||
}
|
||||
|
||||
type hnsEndpoint struct {
|
||||
|
@ -257,6 +258,26 @@ func (d *driver) DeleteNetwork(nid string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func convertQosPolicies(qosPolicies []types.QosPolicy) ([]json.RawMessage, error) {
|
||||
var qps []json.RawMessage
|
||||
|
||||
// Enumerate through the qos policies specified by the user and convert
|
||||
// them into the internal structure matching the JSON blob that can be
|
||||
// understood by the HCS.
|
||||
for _, elem := range qosPolicies {
|
||||
encodedPolicy, err := json.Marshal(hcsshim.QosPolicy{
|
||||
Type: "QOS",
|
||||
MaximumOutgoingBandwidthInBytes: elem.MaxEgressBandwidth,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
qps = append(qps, encodedPolicy)
|
||||
}
|
||||
return qps, nil
|
||||
}
|
||||
|
||||
func convertPortBindings(portBindings []types.PortBinding) ([]json.RawMessage, error) {
|
||||
var pbs []json.RawMessage
|
||||
|
||||
|
@ -347,6 +368,14 @@ func parseEndpointOptions(epOptions map[string]interface{}) (*endpointConfigurat
|
|||
}
|
||||
}
|
||||
|
||||
if opt, ok := epOptions[QosPolicies]; ok {
|
||||
if policies, ok := opt.([]types.QosPolicy); ok {
|
||||
ec.QosPolicies = policies
|
||||
} else {
|
||||
return nil, fmt.Errorf("Invalid endpoint configuration")
|
||||
}
|
||||
}
|
||||
|
||||
return ec, nil
|
||||
}
|
||||
|
||||
|
@ -375,11 +404,16 @@ func (d *driver) CreateEndpoint(nid, eid string, ifInfo driverapi.InterfaceInfo,
|
|||
}
|
||||
|
||||
endpointStruct.Policies, err = convertPortBindings(ec.PortBindings)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
qosPolicies, err := convertQosPolicies(ec.QosPolicies)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
endpointStruct.Policies = append(endpointStruct.Policies, qosPolicies...)
|
||||
|
||||
configurationb, err := json.Marshal(endpointStruct)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -12,6 +12,11 @@ import (
|
|||
// UUID represents a globally unique ID of various resources like network and endpoint
|
||||
type UUID string
|
||||
|
||||
// QosPolicy represents a quality of service policy on an endpoint
|
||||
type QosPolicy struct {
|
||||
MaxEgressBandwidth uint64
|
||||
}
|
||||
|
||||
// TransportPort represent a local Layer 4 endpoint
|
||||
type TransportPort struct {
|
||||
Proto Protocol
|
||||
|
|
Loading…
Add table
Reference in a new issue