This is an automated email from the ASF dual-hosted git repository.

rawlin 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 f59f7d389f Return the appropriate version based server structure on 
deletion (#6932)
f59f7d389f is described below

commit f59f7d389fdf4eb80fdde3e6c773beef8a1d031f
Author: Srijeet Chatterjee <[email protected]>
AuthorDate: Tue Jun 28 16:00:23 2022 -0600

    Return the appropriate version based server structure on deletion (#6932)
---
 CHANGELOG.md                                     |  1 +
 traffic_ops/traffic_ops_golang/server/servers.go | 22 ++++++++++++++++------
 2 files changed, 17 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2e965a12c0..b401e7b424 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -45,6 +45,7 @@ The format is based on [Keep a 
Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#6368](https://github.com/apache/trafficcontrol/pull/6368) Fixed validation 
response message from `/acme_accounts`
 - [#6603](https://github.com/apache/trafficcontrol/issues/6603) Fixed users 
with "admin" "Priv Level" not having Permission to view or delete DNSSEC keys.
 - Fixed Traffic Router to handle aggressive NSEC correctly.
+- [#6907](https://github.com/apache/trafficcontrol/issues/6907) Fixed Traffic 
Ops to return the correct server structure (based on the API version) upon a 
server deletion.
 - [#6626](https://github.com/apache/trafficcontrol/pull/6626) Fixed t3c 
Capabilities request failure issue which could result in malformed config.
 - [#6370](https://github.com/apache/trafficcontrol/pull/6370) Fixed docs for 
`POST` and response code for `PUT` to `/acme_accounts` endpoint
 - Only `operations` and `admin` roles should have the 
`DELIVERY-SERVICE:UPDATE` permission.
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go 
b/traffic_ops/traffic_ops_golang/server/servers.go
index c18a7b7764..457efc4cb3 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -2583,7 +2583,7 @@ func Delete(w http.ResponseWriter, r *http.Request) {
                return
        }
 
-       if inf.Version.Major >= 3 {
+       if inf.Version.Major >= 4 {
                api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server deleted", 
server)
        } else {
                csp, err := dbhelpers.GetCommonServerPropertiesFromV4(server, 
tx)
@@ -2592,13 +2592,23 @@ func Delete(w http.ResponseWriter, r *http.Request) {
                        api.HandleErr(w, r, tx, errCode, userErr, sysErr)
                        return
                }
-               serverV2, err := server.ToServerV2FromV4(csp)
-               if err != nil {
-                       api.HandleErr(w, r, tx, http.StatusInternalServerError, 
nil, err)
-                       return
+               if inf.Version.Major >= 3 {
+                       serverv3, err := server.ToServerV3FromV4(csp)
+                       if err != nil {
+                               api.HandleErr(w, r, tx, 
http.StatusInternalServerError, nil, err)
+                               return
+                       }
+                       api.WriteRespAlertObj(w, r, tc.SuccessLevel, "Server 
deleted", serverv3)
+               } else {
+                       serverV2, err := server.ToServerV2FromV4(csp)
+                       if err != nil {
+                               api.HandleErr(w, r, tx, 
http.StatusInternalServerError, nil, err)
+                               return
+                       }
+                       api.WriteRespAlertObj(w, r, tc.SuccessLevel, "server 
was deleted.", serverV2)
                }
-               api.WriteRespAlertObj(w, r, tc.SuccessLevel, "server was 
deleted.", serverV2)
        }
+
        changeLogMsg := fmt.Sprintf("SERVER: %s.%s, ID: %d, ACTION: deleted", 
*server.HostName, *server.DomainName, *server.ID)
        api.CreateChangeLogRawTx(api.ApiChange, changeLogMsg, inf.User, tx)
 }

Reply via email to