You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2020/04/30 18:58:25 UTC

[GitHub] [trafficcontrol] mattjackson220 opened a new pull request #4676: updated /deliveryservices/{{ID}}/servers and /deliveryservices/{{ID}}…

mattjackson220 opened a new pull request #4676:
URL: https://github.com/apache/trafficcontrol/pull/4676


   …/servers/eligible to use multiple interfaces
   
   <!--
   ************ STOP!! ************
   If this Pull Request is intended to fix a security vulnerability, DO NOT submit it! Instead, contact
   the Apache Software Foundation Security Team at security@trafficcontrol.apache.org and follow the
   guidelines at https://www.apache.org/security/ regarding vulnerability disclosure.
   -->
   ## What does this PR (Pull Request) do?
   <!-- Explain the changes you made here. If this fixes an Issue, identify it by
   replacing the text in the checkbox item with the Issue number e.g.
   
   - [x] This PR fixes #9001 OR is not related to any Issue
   
   ^ This will automatically close Issue number 9001 when the Pull Request is
   merged (The '#' is important).
   
   Be sure you check the box properly, see the "The following criteria are ALL
   met by this PR" section for details.
   -->
   
   - [x] This PR fixes #4614  and fixes #4615  is not related to any Issue <!-- You can check for an issue here: https://github.com/apache/trafficcontrol/issues -->
   
   
   ## Which Traffic Control components are affected by this PR?
   <!-- Please delete all components from this list that are NOT affected by this
   Pull Request. Also, feel free to add the name of a tool or script that is
   affected but not on the list.
   
   Additionally, if this Pull Request does NOT affect documentation, please
   explain why documentation is not required. -->
   
   - Documentation
   - Traffic Ops
   
   ## What is the best way to verify this PR?
   <!-- Please include here ALL the steps necessary to test your Pull Request. If
   it includes tests (and most should), outline here the steps needed to run the
   tests. If not, lay out the manual testing procedure and please explain why
   tests are unnecessary for this Pull Request. -->
   
   ## If this is a bug fix, what versions of Traffic Control are affected?
   <!-- If this PR fixes a bug, please list here all of the affected versions - to
   the best of your knowledge. It's also pretty helpful to include a commit hash
   of where 'master' is at the time this PR is opened (if it affects master),
   because what 'master' means will change over time. For example, if this PR
   fixes a bug that's present in master (at commit hash '1df853c8'), in v4.0.0,
   and in the current 4.0.1 Release candidate (e.g. RC1), then this list would
   look like:
   
   - master (1df853c8)
   - 4.0.0
   - 4.0.1 (RC1)
   
   If you don't know what other versions might have this bug, AND don't know how
   to find the commit hash of 'master', then feel free to leave this section
   blank (or, preferably, delete it entirely).
    -->
   
   
   ## The following criteria are ALL met by this PR
   <!-- Check the boxes to signify that the associated statement is true. To
   "check a box", replace the space inside of the square brackets with an 'x'.
   e.g.
   
   - [ x] <- Wrong
   - [x ] <- Wrong
   - [] <- Wrong
   - [*] <- Wrong
   - [x] <- Correct!
   
   -->
   
   - [x] This PR includes tests
   - [x] This PR includes documentation
   - [x] This PR includes an update to CHANGELOG.md
   - [x] This PR includes any and all required license headers
   - [x] This PR does not include a database migration
   - [x] This PR **DOES NOT FIX A SERIOUS SECURITY VULNERABILITY** (see [the Apache Software Foundation's security guidelines](https://www.apache.org/security/) for details)
   
   
   ## Additional Information
   <!-- If you would like to include any additional information on the PR for
   potential reviewers please put it here.
   
   Some examples of this would be:
   
   - Before and after screenshots/gifs of the Traffic Portal if it is affected
   - Links to other dependent Pull Requests
   - References to relevant context (e.g. new/updates to dependent libraries,
   mailing list records, blueprints)
   
   Feel free to leave this section blank (or, preferably, delete it entirely).
   -->
   
   <!--
   Licensed to the Apache Software Foundation (ASF) under one
   or more contributor license agreements.  See the NOTICE file
   distributed with this work for additional information
   regarding copyright ownership.  The ASF licenses this file
   to you under the Apache License, Version 2.0 (the
   "License"); you may not use this file except in compliance
   with the License.  You may obtain a copy of the License at
   
       http://www.apache.org/licenses/LICENSE-2.0
   
   Unless required by applicable law or agreed to in writing,
   software distributed under the License is distributed on an
   "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   KIND, either express or implied.  See the License for the
   specific language governing permissions and limitations
   under the License.
   -->
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #4676: updated /deliveryservices/{{ID}}/servers and /deliveryservices/{{ID}}…

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #4676:
URL: https://github.com/apache/trafficcontrol/pull/4676#discussion_r418610396



##########
File path: docs/source/api/v3/deliveryservices_id_servers.rst
##########
@@ -54,20 +54,23 @@ Response Structure
 :iloIpNetmask:   The IPv4 subnet mask of the lights-out-management port\ [#ilowikipedia]_
 :iloPassword:    The password of the of the lights-out-management user - displays as ``******`` unless the requesting user has the 'admin' role)\ [#ilowikipedia]_
 :iloUsername:    The user name for lights-out-management\ [#ilowikipedia]_
-:interfaceMtu:   The :abbr:`MTU (Maximum Transmission Unit)` to configure for ``interfaceName``
+:interfaces:     An array of interface and IP address information
 
-	.. seealso:: `The Wikipedia article on Maximum Transmission Unit <https://en.wikipedia.org/wiki/Maximum_transmission_unit>`_
+	:max_bandwidth:  The maximum allowed bandwidth for this interface to be considered "healthy" by Traffic Monitor. This has no effect if `monitor` is not true. Values are in kb/s. The value `0` means "no limit".

Review comment:
       This should actually be "`null` means 'no limit'" - that's one thing that's changed since the blueprint was merged

##########
File path: lib/go-tc/servers.go
##########
@@ -286,3 +307,88 @@ type ServerQueueUpdate struct {
 	ServerID util.JSONIntStr `json:"serverId"`
 	Action   string          `json:"action"`
 }
+
+// ServerInterface is the data associated with an interface
+type ServerInterface struct {
+	MaxBandwidth int64  `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool   `json:"monitor" db:"monitor"`
+	Mtu          int64  `json:"mtu" db:"mtu"`
+	Name         string `json:"name" db:"name"`
+	Server       int    `json:"server" db:"server"`
+}
+
+// ServerIpAddress is the data associated with an IP address

Review comment:
       same as above RE: period

##########
File path: docs/source/api/v3/deliveryservices_id_servers_eligible.rst
##########
@@ -59,20 +59,23 @@ Response Structure
 :iloIpNetmask:   The IPv4 subnet mask of the lights-out-management port\ [#ilowikipedia]_
 :iloPassword:    The password of the of the lights-out-management user - displays as ``******`` unless the requesting user has the 'admin' role)\ [#ilowikipedia]_
 :iloUsername:    The user name for lights-out-management\ [#ilowikipedia]_
-:interfaceMtu:   The :abbr:`MTU (Maximum Transmission Unit)` to configure for ``interfaceName``
+:interfaces:     An array of interface and IP address information
 
-	.. seealso:: `The Wikipedia article on Maximum Transmission Unit <https://en.wikipedia.org/wiki/Maximum_transmission_unit>`_
+	:max_bandwidth:  The maximum allowed bandwidth for this interface to be considered "healthy" by Traffic Monitor. This has no effect if `monitor` is not true. Values are in kb/s. The value `0` means "no limit".

Review comment:
       Same as above RE `null` vs `0`

##########
File path: lib/go-tc/servers.go
##########
@@ -267,6 +274,20 @@ type ServerDetail struct {
 	XMPPPasswd         *string           `json:"xmppPasswd" db:"xmpp_passwd"`
 }
 
+// LegacyInterfaceDetails is the details for interfaces on servers for API v1 and v2

Review comment:
       nit: GoDocs should end with a period.

##########
File path: lib/go-tc/deliveryservice_servers.go
##########
@@ -114,3 +100,13 @@ type DSServer struct {
 	ServerCapabilities          []string             `json:"-" db:"server_capabilities"`
 	DeliveryServiceCapabilities []string             `json:"-" db:"deliveryservice_capabilities"`
 }
+
+type DSServerV11 struct {
+	DSServer
+	LegacyInterfaceDetails
+}
+
+type DSServerV30 struct {
+	DSServer
+	ServerInterfaces *[]ServerInterfaceInfo `json:"interfaces" db:"interfaces"`
+}

Review comment:
       GoDoc on these?

##########
File path: lib/go-tc/servers.go
##########
@@ -286,3 +307,88 @@ type ServerQueueUpdate struct {
 	ServerID util.JSONIntStr `json:"serverId"`
 	Action   string          `json:"action"`
 }
+
+// ServerInterface is the data associated with an interface
+type ServerInterface struct {
+	MaxBandwidth int64  `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool   `json:"monitor" db:"monitor"`
+	Mtu          int64  `json:"mtu" db:"mtu"`
+	Name         string `json:"name" db:"name"`
+	Server       int    `json:"server" db:"server"`
+}
+
+// ServerIpAddress is the data associated with an IP address
+type ServerIpAddress struct {
+	Address        string `json:"address" db:"address"`
+	Gateway        string `json:"gateway" db:"gateway"`
+	Interface      string `json:"interface,omitempty" db:"interface"`
+	Server         int    `json:"server,omitempty" db:"server"`
+	ServiceAddress bool   `json:"service_address" db:"service_address"`
+}
+
+// ServerInterfaceInfo is the combined data from both IP address information and interface information
+type ServerInterfaceInfo struct {
+	IpAddresses  []ServerIpAddress `json:"ipAddresses" db:"ipAddresses"`
+	MaxBandwidth int64             `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool              `json:"monitor" db:"monitor"`
+	Mtu          int               `json:"mtu" db:"mtu"`

Review comment:
       MTU should be `uint` (or `uint64`) - can't ever be valid as a negative number

##########
File path: lib/go-tc/servers.go
##########
@@ -286,3 +307,88 @@ type ServerQueueUpdate struct {
 	ServerID util.JSONIntStr `json:"serverId"`
 	Action   string          `json:"action"`
 }
+
+// ServerInterface is the data associated with an interface

Review comment:
       same as above RE: period

##########
File path: lib/go-tc/servers.go
##########
@@ -286,3 +307,88 @@ type ServerQueueUpdate struct {
 	ServerID util.JSONIntStr `json:"serverId"`
 	Action   string          `json:"action"`
 }
+
+// ServerInterface is the data associated with an interface
+type ServerInterface struct {
+	MaxBandwidth int64  `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool   `json:"monitor" db:"monitor"`
+	Mtu          int64  `json:"mtu" db:"mtu"`
+	Name         string `json:"name" db:"name"`
+	Server       int    `json:"server" db:"server"`
+}
+
+// ServerIpAddress is the data associated with an IP address
+type ServerIpAddress struct {
+	Address        string `json:"address" db:"address"`
+	Gateway        string `json:"gateway" db:"gateway"`
+	Interface      string `json:"interface,omitempty" db:"interface"`
+	Server         int    `json:"server,omitempty" db:"server"`
+	ServiceAddress bool   `json:"service_address" db:"service_address"`
+}
+
+// ServerInterfaceInfo is the combined data from both IP address information and interface information

Review comment:
       same as above RE: period

##########
File path: lib/go-tc/servers.go
##########
@@ -286,3 +307,88 @@ type ServerQueueUpdate struct {
 	ServerID util.JSONIntStr `json:"serverId"`
 	Action   string          `json:"action"`
 }
+
+// ServerInterface is the data associated with an interface
+type ServerInterface struct {
+	MaxBandwidth int64  `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool   `json:"monitor" db:"monitor"`
+	Mtu          int64  `json:"mtu" db:"mtu"`
+	Name         string `json:"name" db:"name"`
+	Server       int    `json:"server" db:"server"`
+}
+
+// ServerIpAddress is the data associated with an IP address
+type ServerIpAddress struct {
+	Address        string `json:"address" db:"address"`
+	Gateway        string `json:"gateway" db:"gateway"`
+	Interface      string `json:"interface,omitempty" db:"interface"`
+	Server         int    `json:"server,omitempty" db:"server"`
+	ServiceAddress bool   `json:"service_address" db:"service_address"`
+}
+
+// ServerInterfaceInfo is the combined data from both IP address information and interface information
+type ServerInterfaceInfo struct {
+	IpAddresses  []ServerIpAddress `json:"ipAddresses" db:"ipAddresses"`
+	MaxBandwidth int64             `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool              `json:"monitor" db:"monitor"`
+	Mtu          int               `json:"mtu" db:"mtu"`
+	Name         string            `json:"name" db:"name"`
+}
+
+// Value implements the driver.Valuer interface
+// marshals struct to json to pass back as a json.RawMessage
+func (sii *ServerInterfaceInfo) Value() (driver.Value, error) {
+	b, err := json.Marshal(sii)
+	return b, err
+}
+
+// Scan implements the sql.Scanner interface
+// expects json.RawMessage and unmarshals to a deliveryservice struct
+func (sii *ServerInterfaceInfo) Scan(src interface{}) error {
+	b, ok := src.([]byte)
+	if !ok {
+		return fmt.Errorf("expected deliveryservice in byte array form; got %T", src)
+	}
+
+	return json.Unmarshal([]byte(b), sii)
+}
+
+// ConvertInterfaceInfotoV11 converts ServerInterfaceInfo to LegacyInterfaceDetails for v1 and v2 compatibility

Review comment:
       Same as above RE: period.

##########
File path: lib/go-tc/servers.go
##########
@@ -286,3 +307,88 @@ type ServerQueueUpdate struct {
 	ServerID util.JSONIntStr `json:"serverId"`
 	Action   string          `json:"action"`
 }
+
+// ServerInterface is the data associated with an interface
+type ServerInterface struct {
+	MaxBandwidth int64  `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool   `json:"monitor" db:"monitor"`
+	Mtu          int64  `json:"mtu" db:"mtu"`
+	Name         string `json:"name" db:"name"`
+	Server       int    `json:"server" db:"server"`
+}
+
+// ServerIpAddress is the data associated with an IP address
+type ServerIpAddress struct {
+	Address        string `json:"address" db:"address"`
+	Gateway        string `json:"gateway" db:"gateway"`
+	Interface      string `json:"interface,omitempty" db:"interface"`
+	Server         int    `json:"server,omitempty" db:"server"`
+	ServiceAddress bool   `json:"service_address" db:"service_address"`
+}
+
+// ServerInterfaceInfo is the combined data from both IP address information and interface information
+type ServerInterfaceInfo struct {
+	IpAddresses  []ServerIpAddress `json:"ipAddresses" db:"ipAddresses"`
+	MaxBandwidth int64             `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool              `json:"monitor" db:"monitor"`
+	Mtu          int               `json:"mtu" db:"mtu"`
+	Name         string            `json:"name" db:"name"`
+}
+
+// Value implements the driver.Valuer interface
+// marshals struct to json to pass back as a json.RawMessage
+func (sii *ServerInterfaceInfo) Value() (driver.Value, error) {
+	b, err := json.Marshal(sii)
+	return b, err
+}
+
+// Scan implements the sql.Scanner interface
+// expects json.RawMessage and unmarshals to a deliveryservice struct

Review comment:
       Same as above RE: complete sentences

##########
File path: lib/go-tc/deliveryservice_servers.go
##########
@@ -114,3 +100,13 @@ type DSServer struct {
 	ServerCapabilities          []string             `json:"-" db:"server_capabilities"`
 	DeliveryServiceCapabilities []string             `json:"-" db:"deliveryservice_capabilities"`
 }
+
+type DSServerV11 struct {
+	DSServer
+	LegacyInterfaceDetails
+}
+
+type DSServerV30 struct {

Review comment:
       Why not make DSServer point to the current definition of a Delivery Service Server? Coupling to the API version means that things stop making sense unless we update that every time the API version changes; like if we have DSServerV30 then APIv3.1 comes out and no changes are made to the structure, we're either using a confusingly version structure, or we have to remember to do something like `type DSServer31 = DSServer30` and then do a find/replace to update things.

##########
File path: lib/go-tc/servers.go
##########
@@ -286,3 +307,88 @@ type ServerQueueUpdate struct {
 	ServerID util.JSONIntStr `json:"serverId"`
 	Action   string          `json:"action"`
 }
+
+// ServerInterface is the data associated with an interface
+type ServerInterface struct {
+	MaxBandwidth int64  `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool   `json:"monitor" db:"monitor"`
+	Mtu          int64  `json:"mtu" db:"mtu"`
+	Name         string `json:"name" db:"name"`
+	Server       int    `json:"server" db:"server"`
+}
+
+// ServerIpAddress is the data associated with an IP address
+type ServerIpAddress struct {
+	Address        string `json:"address" db:"address"`
+	Gateway        string `json:"gateway" db:"gateway"`
+	Interface      string `json:"interface,omitempty" db:"interface"`
+	Server         int    `json:"server,omitempty" db:"server"`
+	ServiceAddress bool   `json:"service_address" db:"service_address"`
+}
+
+// ServerInterfaceInfo is the combined data from both IP address information and interface information
+type ServerInterfaceInfo struct {
+	IpAddresses  []ServerIpAddress `json:"ipAddresses" db:"ipAddresses"`
+	MaxBandwidth int64             `json:"max_bandwidth" db:"max_bandwidth"`
+	Monitor      bool              `json:"monitor" db:"monitor"`
+	Mtu          int               `json:"mtu" db:"mtu"`
+	Name         string            `json:"name" db:"name"`
+}
+
+// Value implements the driver.Valuer interface
+// marshals struct to json to pass back as a json.RawMessage

Review comment:
       nit: GoDocs should consist of complete sentences with proper capitalization and terminated by periods.

##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/servers/servers.go
##########
@@ -554,17 +611,27 @@ func dssSelectQuery() string {
 	s.ilo_ip_netmask,
 	s.ilo_password,
 	s.ilo_username,
-	COALESCE(s.interface_mtu, ` + strconv.Itoa(JumboFrameBPS) + `) as interface_mtu,
-	s.interface_name,
-	s.ip6_address,
-	s.ip6_gateway,
-	s.ip_address,
-	s.ip_gateway,
-	s.ip_netmask,
+	ARRAY (
+SELECT ( json_build_object (
+'ipAddresses', ARRAY (
+SELECT ( json_build_object (
+'address', ip_address.address,
+'gateway', ip_address.gateway,
+'service_address', ip_address.service_address
+))

Review comment:
       Does `github.com/lib/pq` not support nested arrays?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 commented on a change in pull request #4676: updated /deliveryservices/{{ID}}/servers and /deliveryservices/{{ID}}…

Posted by GitBox <gi...@apache.org>.
ocket8888 commented on a change in pull request #4676:
URL: https://github.com/apache/trafficcontrol/pull/4676#discussion_r440904681



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/eligible.go
##########
@@ -86,13 +105,26 @@ s.ilo_ip_gateway,
 s.ilo_ip_netmask,
 s.ilo_password,
 s.ilo_username,
-COALESCE(s.interface_mtu, ` + strconv.Itoa(JumboFrameBPS) + `) as interface_mtu,
-s.interface_name,
-s.ip6_address,
-s.ip6_gateway,
-s.ip_address,
-s.ip_gateway,
-s.ip_netmask,
+	ARRAY (
+SELECT ( json_build_object (

Review comment:
       True enough. This is also still how `/servers/details` is being done.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] rawlinp commented on a change in pull request #4676: updated /deliveryservices/{{ID}}/servers and /deliveryservices/{{ID}}…

Posted by GitBox <gi...@apache.org>.
rawlinp commented on a change in pull request #4676:
URL: https://github.com/apache/trafficcontrol/pull/4676#discussion_r440462810



##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/eligible.go
##########
@@ -86,13 +105,26 @@ s.ilo_ip_gateway,
 s.ilo_ip_netmask,
 s.ilo_password,
 s.ilo_username,
-COALESCE(s.interface_mtu, ` + strconv.Itoa(JumboFrameBPS) + `) as interface_mtu,
-s.interface_name,
-s.ip6_address,
-s.ip6_gateway,
-s.ip_address,
-s.ip_gateway,
-s.ip_netmask,
+	ARRAY (
+SELECT ( json_build_object (

Review comment:
       So this does worry me a bit still. When reviewing @ocket8888's PR I found that this query using `json_build_object` is like 12x slower than querying the interfaces and IPs separately (without using `json_build_object`) and manually populating the servers structs with that data. Also, we should really be making the same query here as we would in the /servers API. It seems like we could make this better by sharing that code/query here.
   
   Locally (which I typically assume performs much better than in Prod), for a DS w/ ~1000 servers assigned, this API takes 850ms for me, whereas before this PR, it takes ~75ms.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [trafficcontrol] ocket8888 merged pull request #4676: updated /deliveryservices/{{ID}}/servers and /deliveryservices/{{ID}}…

Posted by GitBox <gi...@apache.org>.
ocket8888 merged pull request #4676:
URL: https://github.com/apache/trafficcontrol/pull/4676


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org