You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/07/23 21:08:19 UTC

[trafficcontrol] branch master updated (d58d66e -> c88aa2a)

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

dewrich pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git.


    from d58d66e  add quotes around listen field name in error message
     new 3859919  ensure tenant set where needed; add not null constraint
     new 93f6644  add tenant to extension user
     new 491dd56  update changelog for use_tenancy
     new c88aa2a  assign "unassigned" tenants

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGELOG.md                   |  6 +++---
 traffic_ops/app/db/patches.sql | 33 +++++++++++++++++++++++++++++++++
 traffic_ops/app/db/seeds.sql   |  5 ++++-
 3 files changed, 40 insertions(+), 4 deletions(-)


[trafficcontrol] 01/04: ensure tenant set where needed; add not null constraint

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 38599198c02b4339874e5f7f23966af63046ed4c
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Mon Jul 9 16:11:58 2018 -0600

    ensure tenant set where needed; add not null constraint
---
 traffic_ops/app/db/patches.sql | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/traffic_ops/app/db/patches.sql b/traffic_ops/app/db/patches.sql
index 6fe87d1..16cbb8f 100644
--- a/traffic_ops/app/db/patches.sql
+++ b/traffic_ops/app/db/patches.sql
@@ -39,3 +39,20 @@ ALTER TABLE deliveryservice ADD CONSTRAINT routing_name_not_empty CHECK (length(
 -- altering any enum values within a transaction block and by default
 -- goose runs migrations within a transaction.
 ALTER TYPE profile_type ADD VALUE IF NOT EXISTS 'GROVE_PROFILE';
+
+-- If tenancy is not needed, simply default to the root tenant.  This will help
+-- to eliminate the use_tenancy property
+INSERT INTO tenant (name, active, parent_id) VALUES ('root', true, NULL)
+ON CONFLICT DO NOTHING;
+
+UPDATE tm_user SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
+WHERE tenant_id IS NULL;
+ALTER TABLE tm_user ALTER COLUMN tenant_id SET NOT NULL;
+
+UPDATE deliveryservice SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
+WHERE tenant_id IS NULL;
+ALTER TABLE deliveryservice ALTER COLUMN tenant_id SET NOT NULL;
+
+UPDATE origin SET tenant = (SELECT id FROM tenant WHERE name = 'root')
+WHERE tenant IS NULL;
+ALTER TABLE origin ALTER COLUMN tenant SET NOT NULL;


[trafficcontrol] 03/04: update changelog for use_tenancy

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 491dd56d8138474edcf0ea259b21192176eb5a6f
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Tue Jul 10 10:14:19 2018 -0600

    update changelog for use_tenancy
---
 CHANGELOG.md | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 7c974f8..ade8dc8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -10,9 +10,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
   - /api/1.3/origins `(GET,POST,PUT,DELETE)`
   - /api/1.3/coordinates `(GET,POST,PUT,DELETE)`
 - Delivery Service Origins Refactor: The Delivery Service API now creates/updates an Origin entity on Delivery Service creates/updates, and the `org_server_fqdn` column in the `deliveryservice` table has been removed. The `org_server_fqdn` data is now computed from the Delivery Service's primary origin (note: the name of the primary origin is the `xml_id` of its delivery service).
-- Cachegroup-Coordinate Refactor: The Cachegroup API now creates/updates a Coordinate entity on Cachegroup creates/updates, and the `latitude` and `longitude` columns in the `cachegroup` table have been replaced with `coordinate` (a foreign key to Coordinate). Coordinates created from Cachegroups are given the name 'from_cachegroup_\<cachegroup name\>'.
-- Geolocation-based Client Steering: two new steering target types are available to use for CLIENT_STEERING delivery services: `STEERING_GEO_ORDER` and `STEERING_GEO_WEIGHT`. When targets of these types have an Origin with a Coordinate, Traffic Router will order and prioritize them based upon the shortest total distance from client -> edge -> origin. Co-located targets are grouped together and can be weighted or ordered within the same location using `STEERING_GEO_WEIGHT` or `STEERING_GE [...]
-
+- Cachegroup-Coordinate Refactor: The Cachegroup API now creates/updates a Coordinate entity on Cachegroup creates/updates, and the `latitude` and `longitude` columns in the `cachegroup` table have been replaced with `coordinate` (a foreign key to Coordinate). Coordinates created from Cachegroups are given the name `from_cachegroup_\<cachegroup name\>`.
+- Geolocation-based Client Steering: two new steering target types are available to use for `CLIENT_STEERING` delivery services: `STEERING_GEO_ORDER` and `STEERING_GEO_WEIGHT`. When targets of these types have an Origin with a Coordinate, Traffic Router will order and prioritize them based upon the shortest total distance from client -> edge -> origin. Co-located targets are grouped together and can be weighted or ordered within the same location using `STEERING_GEO_WEIGHT` or `STEERING_ [...]
+- Tenancy is now the default behavior in Traffic Ops.  All database entries that reference a tenant now have a default of the root tenant.  This eliminates the need for the `use_tenancy` global parameter and will allow for code to be simplified as a result. If all user and delivery services reference the root tenant, then there will be no difference from having `use_tenancy` set to 0.
 
 ## [2.2.0] - 2018-06-07
 ### Added


[trafficcontrol] 04/04: assign "unassigned" tenants

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit c88aa2acc4c80039d047ee95fa599c4af5ea9630
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Thu Jul 12 12:41:29 2018 -0600

    assign "unassigned" tenants
---
 traffic_ops/app/db/patches.sql | 36 ++++++++++++++++++++++++++----------
 traffic_ops/app/db/seeds.sql   |  1 +
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/traffic_ops/app/db/patches.sql b/traffic_ops/app/db/patches.sql
index 16cbb8f..a72cd72 100644
--- a/traffic_ops/app/db/patches.sql
+++ b/traffic_ops/app/db/patches.sql
@@ -42,17 +42,33 @@ ALTER TYPE profile_type ADD VALUE IF NOT EXISTS 'GROVE_PROFILE';
 
 -- If tenancy is not needed, simply default to the root tenant.  This will help
 -- to eliminate the use_tenancy property
-INSERT INTO tenant (name, active, parent_id) VALUES ('root', true, NULL)
-ON CONFLICT DO NOTHING;
 
-UPDATE tm_user SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
-WHERE tenant_id IS NULL;
-ALTER TABLE tm_user ALTER COLUMN tenant_id SET NOT NULL;
+DO
+$tenantnotnull$
+BEGIN
+    IF EXISTS (SELECT value FROM parameter WHERE name = 'use_tenancy' AND config_file = 'global' AND value = '1') THEN
+        -- tenancy turned ON -- anything without a tenant gets the "unassigned" tenant
+        UPDATE tm_user SET tenant_id = (SELECT id FROM tenant WHERE name = 'unassigned')
+        WHERE tenant_id IS NULL;
+        UPDATE deliveryservice SET tenant_id = (SELECT id FROM tenant WHERE name = 'unassigned')
+        WHERE tenant_id IS NULL;
+        UPDATE origin SET tenant = (SELECT id FROM tenant WHERE name = 'unassigned')
+        WHERE tenant IS NULL;
+    ELSE
+        -- tenancy turned OFF -- anything without a tenant gets the "root" tenant
+        UPDATE tm_user SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
+        WHERE tenant_id IS NULL;
+        UPDATE deliveryservice SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
+        WHERE tenant_id IS NULL;
+        UPDATE origin SET tenant = (SELECT id FROM tenant WHERE name = 'root')
+        WHERE tenant IS NULL;
+    END IF;
+END
+$tenantnotnull$;
 
-UPDATE deliveryservice SET tenant_id = (SELECT id FROM tenant WHERE name = 'root')
-WHERE tenant_id IS NULL;
+-- add constraints so we can depend on everything being assigned a tenant
+ALTER TABLE tm_user ALTER COLUMN tenant_id SET NOT NULL;
 ALTER TABLE deliveryservice ALTER COLUMN tenant_id SET NOT NULL;
-
-UPDATE origin SET tenant = (SELECT id FROM tenant WHERE name = 'root')
-WHERE tenant IS NULL;
 ALTER TABLE origin ALTER COLUMN tenant SET NOT NULL;
+-- get rid of the use_tenancy flag
+DELETE FROM parameter WHERE name = 'use_tenancy' AND config_file = 'global';
diff --git a/traffic_ops/app/db/seeds.sql b/traffic_ops/app/db/seeds.sql
index 9dc20f0..2783d9e 100644
--- a/traffic_ops/app/db/seeds.sql
+++ b/traffic_ops/app/db/seeds.sql
@@ -81,6 +81,7 @@ insert into role (name, description, priv_level) values ('disallowed', 'Block al
 
 -- tenants
 insert into tenant (name, active, parent_id) values ('root', true, null) ON CONFLICT DO NOTHING;
+insert into tenant (name, active, parent_id) values ('unassigned', true, (select id from tenant where name='root')) ON CONFLICT DO NOTHING;
 
 -- capabilities
 insert into capability (name, description) values ('all-read', 'Full read access') ON CONFLICT (name) DO NOTHING;


[trafficcontrol] 02/04: add tenant to extension user

Posted by de...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 93f6644b90038efaece15fb679367ce77e7e5a22
Author: Dan Kirkwood <da...@apache.org>
AuthorDate: Tue Jul 10 09:48:53 2018 -0600

    add tenant to extension user
---
 traffic_ops/app/db/seeds.sql | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/traffic_ops/app/db/seeds.sql b/traffic_ops/app/db/seeds.sql
index 5928970..9dc20f0 100644
--- a/traffic_ops/app/db/seeds.sql
+++ b/traffic_ops/app/db/seeds.sql
@@ -404,7 +404,9 @@ insert into type (name, description, use_in_table) values ('STEERING_GEO_ORDER',
 insert into type (name, description, use_in_table) values ('STEERING_GEO_WEIGHT', 'Geo-weighted steering target', 'steering_target') ON CONFLICT (name) DO NOTHING;
 
 -- users
-insert into tm_user (username, role, full_name, token) values ('extension', (select id from role where name = 'operations'), 'Extension User, DO NOT DELETE', '91504CE6-8E4A-46B2-9F9F-FE7C15228498') ON CONFLICT DO NOTHING;
+insert into tm_user (username, role, full_name, token, tenant_id) values ('extension',
+    (select id from role where name = 'operations'), 'Extension User, DO NOT DELETE', '91504CE6-8E4A-46B2-9F9F-FE7C15228498',
+    (select id from tenant where name = 'root')) ON CONFLICT DO NOTHING;
 
 -- to extensions
 -- some of the old ones do not get a new place, and there will be 'gaps' in the column usage.... New to_extension add will have to take care of that.