This is an automated email from the ASF dual-hosted git repository.
ocket8888 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 64564a0 Fixes the inability to clone ds assignments across servers
when 1+ ds is assigned a topology (#4905)
64564a0 is described below
commit 64564a0057299eb47a2c485ca814db888d5f5bd4
Author: Jeremy Mitchell <[email protected]>
AuthorDate: Thu Jul 23 11:49:31 2020 -0600
Fixes the inability to clone ds assignments across servers when 1+ ds is
assigned a topology (#4905)
* allows topology-based delivery services to be assigned to caches using
POST api/1.x|2.x|3.x/servers/{server-id}/deliveryservices
* in TP, disables ability to assign topology-based delivery services
individually to a server
---
.../api/v3/servers_to_deliveryservice_assignment_test.go | 12 ++++++------
traffic_ops/traffic_ops_golang/server/servers_assignment.go | 9 ---------
.../TableAssignDeliveryServicesController.js | 3 +++
.../table.assignDeliveryServices.tpl.html | 2 +-
4 files changed, 10 insertions(+), 16 deletions(-)
diff --git
a/traffic_ops/testing/api/v3/servers_to_deliveryservice_assignment_test.go
b/traffic_ops/testing/api/v3/servers_to_deliveryservice_assignment_test.go
index 2945229..65d6575 100644
--- a/traffic_ops/testing/api/v3/servers_to_deliveryservice_assignment_test.go
+++ b/traffic_ops/testing/api/v3/servers_to_deliveryservice_assignment_test.go
@@ -192,11 +192,11 @@ func AssignTopologyBasedDeliveryService(t *testing.T) {
t.Fatal("Fetch DS information returned unknown ID")
}
alerts, reqInf, err :=
TOSession.AssignDeliveryServiceIDsToServerID(*server.ID, []int{*firstDS.ID},
false)
- if err == nil {
- t.Errorf("Expected bad assignment to fail, but it didn't!
(alerts: %v)", alerts)
+ if err != nil {
+ t.Errorf("Expected assignment to succeed, but it didn't!
(alerts: %v)", alerts)
}
- if reqInf.StatusCode < http.StatusBadRequest || reqInf.StatusCode >=
http.StatusInternalServerError {
- t.Fatalf("assigning Topology-based delivery service to server -
expected: 400-level status code, actual: %d", reqInf.StatusCode)
+ if reqInf.StatusCode >= http.StatusBadRequest {
+ t.Fatalf("assigning Topology-based delivery service to server -
expected: non-error status code, actual: %d", reqInf.StatusCode)
}
response, _, err := TOSession.GetServerIDDeliveryServices(*server.ID,
nil)
@@ -214,7 +214,7 @@ func AssignTopologyBasedDeliveryService(t *testing.T) {
}
}
- if found {
- t.Errorf(`Invalid Server/DS assignment was created!`)
+ if !found {
+ t.Errorf(`Valid Server/DS assignment was not created!`)
}
}
diff --git a/traffic_ops/traffic_ops_golang/server/servers_assignment.go
b/traffic_ops/traffic_ops_golang/server/servers_assignment.go
index 53b1bf9..8cfec3a 100644
--- a/traffic_ops/traffic_ops_golang/server/servers_assignment.go
+++ b/traffic_ops/traffic_ops_golang/server/servers_assignment.go
@@ -96,15 +96,6 @@ func AssignDeliveryServicesToServerHandler(w
http.ResponseWriter, r *http.Reques
api.HandleErr(w, r, inf.Tx.Tx, status, usrErr, sysErr)
return
}
- dses, sysErr :=
dbhelpers.GetDeliveryServicesWithTopologies(inf.Tx.Tx, dsList)
- if sysErr != nil {
- api.HandleErr(w, r, inf.Tx.Tx,
http.StatusInternalServerError, nil, sysErr)
- return
- }
- if len(dses) > 0 {
- api.HandleErr(w, r, inf.Tx.Tx, http.StatusBadRequest,
fmt.Errorf("delivery services %v are already assigned to a topology", dses),
nil)
- return
- }
}
// We already know the CDN exists because that's part of the serverInfo
query above
diff --git
a/traffic_portal/app/src/common/modules/table/serverDeliveryServices/TableAssignDeliveryServicesController.js
b/traffic_portal/app/src/common/modules/table/serverDeliveryServices/TableAssignDeliveryServicesController.js
index fb3674c..83c0821 100644
---
a/traffic_portal/app/src/common/modules/table/serverDeliveryServices/TableAssignDeliveryServicesController.js
+++
b/traffic_portal/app/src/common/modules/table/serverDeliveryServices/TableAssignDeliveryServicesController.js
@@ -35,6 +35,9 @@ var TableAssignDeliveryServicesController = function(server,
deliveryServices, a
return parseInt($(this).attr('id'));
}).get();
$scope.selectedDeliveryServices = _.map(deliveryServices,
function(ds) {
+ if (ds.topology) {
+ return ds;
+ }
if (visibleDSIds.includes(ds.id)) {
ds['selected'] = selected;
}
diff --git
a/traffic_portal/app/src/common/modules/table/serverDeliveryServices/table.assignDeliveryServices.tpl.html
b/traffic_portal/app/src/common/modules/table/serverDeliveryServices/table.assignDeliveryServices.tpl.html
index 7debe55..b532f4b 100644
---
a/traffic_portal/app/src/common/modules/table/serverDeliveryServices/table.assignDeliveryServices.tpl.html
+++
b/traffic_portal/app/src/common/modules/table/serverDeliveryServices/table.assignDeliveryServices.tpl.html
@@ -33,7 +33,7 @@ under the License.
</thead>
<tbody>
<tr id="{{::ds.id}}" class="ds-row" ng-class="::{'active':
ds.selected}" ng-repeat="ds in ::selectedDeliveryServices"
ng-click="ds.selected = !ds.selected; onChange()">
- <td><input type="checkbox" ng-model="ds.selected"></td>
+ <td><input type="checkbox" ng-model="ds.selected"
ng-disabled="ds.topology"></td>
<td data-search="^{{::ds.xmlId}}$">{{::ds.xmlId}}</td>
<td data-search="^{{::ds.displayName}}$">{{::ds.displayName}}</td>
<td data-search="^{{::ds.type}}$">{{::ds.type}}</td>