You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by oc...@apache.org on 2021/01/08 21:44:02 UTC
[trafficcontrol] branch master updated: Cascade server delete to ip
address and interfaces (#5402)
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 34f136c Cascade server delete to ip address and interfaces (#5402)
34f136c is described below
commit 34f136c192515b222be81c9091d1964f277330ad
Author: mattjackson220 <33...@users.noreply.github.com>
AuthorDate: Fri Jan 8 14:43:50 2021 -0700
Cascade server delete to ip address and interfaces (#5402)
* Cascade server delete to ip address and interfaces
* updated changelog
---
CHANGELOG.md | 1 +
...0000000_server_interface_ip_address_cascade.sql | 38 ++++++++++++++++++++++
traffic_ops/traffic_ops_golang/server/servers.go | 6 ----
3 files changed, 39 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7298bce..83519a2 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
of just column filters
- #2881 Some API endpoints have incorrect Content-Types
- [#5311](https://github.com/apache/trafficcontrol/issues/5311) - Better TO log messages when failures calling TM CacheStats
+- [#5364](https://github.com/apache/trafficcontrol/issues/5364) - Cascade server deletes to delete corresponding IP addresses and interfaces
- [#5390](https://github.com/apache/trafficcontrol/issues/5390) - Improve the way TO deals with delivery service server assignments
## [5.0.0] - 2020-10-20
diff --git a/traffic_ops/app/db/migrations/2021010600000000_server_interface_ip_address_cascade.sql b/traffic_ops/app/db/migrations/2021010600000000_server_interface_ip_address_cascade.sql
new file mode 100644
index 0000000..851e31e
--- /dev/null
+++ b/traffic_ops/app/db/migrations/2021010600000000_server_interface_ip_address_cascade.sql
@@ -0,0 +1,38 @@
+/*
+
+ Licensed 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.
+*/
+
+-- +goose Up
+-- SQL in section 'Up' is executed when this migration is applied
+ALTER TABLE interface
+ DROP CONSTRAINT interface_server_fkey,
+ ADD CONSTRAINT interface_server_fkey FOREIGN KEY (server) REFERENCES server(id) ON DELETE CASCADE ON UPDATE CASCADE;
+
+ALTER TABLE ip_address
+ DROP CONSTRAINT ip_address_interface_fkey,
+ ADD CONSTRAINT ip_address_interface_fkey FOREIGN KEY (server) REFERENCES server(id) ON DELETE CASCADE ON UPDATE CASCADE,
+ DROP CONSTRAINT ip_address_server_fkey,
+ ADD CONSTRAINT ip_address_server_fkey FOREIGN KEY (interface, server) REFERENCES interface(name, server) ON DELETE CASCADE ON UPDATE CASCADE;
+
+-- +goose Down
+-- SQL section 'Down' is executed when this migration is rolled back
+ALTER TABLE interface
+ DROP CONSTRAINT interface_server_fkey,
+ ADD CONSTRAINT interface_server_fkey FOREIGN KEY (server) REFERENCES server(id) ON DELETE RESTRICT ON UPDATE CASCADE;
+
+ALTER TABLE ip_address
+ DROP CONSTRAINT ip_address_interface_fkey,
+ ADD CONSTRAINT ip_address_interface_fkey FOREIGN KEY (server) REFERENCES server(id) ON DELETE RESTRICT ON UPDATE CASCADE,
+ DROP CONSTRAINT ip_address_server_fkey,
+ ADD CONSTRAINT ip_address_server_fkey FOREIGN KEY (interface, server) REFERENCES interface(name, server) ON DELETE RESTRICT ON UPDATE CASCADE;
diff --git a/traffic_ops/traffic_ops_golang/server/servers.go b/traffic_ops/traffic_ops_golang/server/servers.go
index f2d8a65..2aeb2ea 100644
--- a/traffic_ops/traffic_ops_golang/server/servers.go
+++ b/traffic_ops/traffic_ops_golang/server/servers.go
@@ -1795,12 +1795,6 @@ func Delete(w http.ResponseWriter, r *http.Request) {
return
}
- userErr, sysErr, errCode = deleteInterfaces(id, tx)
- if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, tx, errCode, userErr, sysErr)
- return
- }
-
if result, err := tx.Exec(deleteServerQuery, id); err != nil {
log.Errorf("Raw error: %v", err)
userErr, sysErr, errCode = api.ParseDBError(err)