You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by zr...@apache.org on 2021/09/15 00:00:42 UTC

[trafficcontrol] branch 6.0.x updated (bfcf6b6 -> 3a96b26)

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

zrhoffman pushed a change to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git.


    from bfcf6b6  Update Traffic Router to version 6.0.0 (#6194)
     new 7b3a4a8  Fix t3c-apply default hostname to be short (#6187)
     new 3a96b26  Fix DSRs not showing TLS version restrictions (#6206)

The 2 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                                       |   1 +
 cache-config/t3c-apply/config/config.go            |   2 +
 cache-config/testing/docker/docker-compose.yml     |   1 +
 .../ort-tests/t3c-os-hostname-short_test.go        | 127 +++++++++++++++++++++
 .../FormEditDeliveryServiceRequestController.js    |   2 +
 5 files changed, 133 insertions(+)
 create mode 100644 cache-config/testing/ort-tests/t3c-os-hostname-short_test.go

[trafficcontrol] 02/02: Fix DSRs not showing TLS version restrictions (#6206)

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

zrhoffman pushed a commit to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 3a96b26c53262cbee9c79cf985f90725676b9a65
Author: ocket8888 <oc...@gmail.com>
AuthorDate: Tue Sep 14 11:28:59 2021 -0600

    Fix DSRs not showing TLS version restrictions (#6206)
    
    (cherry picked from commit 4f1988c18cc0cf20ec3d28a02e681d95d6fd903f)
---
 .../edit/FormEditDeliveryServiceRequestController.js                    | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js b/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js
index 1208169..a29dc3c 100644
--- a/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js
+++ b/traffic_portal/app/src/modules/private/deliveryServiceRequests/edit/FormEditDeliveryServiceRequestController.js
@@ -26,6 +26,8 @@ var FormEditDeliveryServiceRequestController = function(deliveryServiceRequest,
 
 	$scope.changeType = $scope.dsRequest.changeType;
 
+	$scope.restrictTLS = ((dsr)=>dsr.tlsVersions instanceof Array && dsr.tlsVersions.length > 0)($scope.dsRequest.requested ?? $scope.dsRequest.original);
+
 	$scope.requestStatus = $scope.dsRequest.status;
 
 	$scope.deliveryServiceName = angular.copy(($scope.dsRequest.requested) ? $scope.dsRequest.requested.xmlId : $scope.dsRequest.original.xmlId);

[trafficcontrol] 01/02: Fix t3c-apply default hostname to be short (#6187)

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

zrhoffman pushed a commit to branch 6.0.x
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git

commit 7b3a4a8e745edf6b9e0d85c977c8d90ef986deb7
Author: Robert O Butts <ro...@users.noreply.github.com>
AuthorDate: Mon Sep 13 10:13:04 2021 -0600

    Fix t3c-apply default hostname to be short (#6187)
    
    Fixes #6174
    
    (cherry picked from commit fee39e2b353a03356d6a2717b83e4e1e5383d821)
---
 CHANGELOG.md                                       |   1 +
 cache-config/t3c-apply/config/config.go            |   2 +
 cache-config/testing/docker/docker-compose.yml     |   1 +
 .../ort-tests/t3c-os-hostname-short_test.go        | 127 +++++++++++++++++++++
 4 files changed, 131 insertions(+)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ed62ce2..af5057b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -102,6 +102,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#6066](https://github.com/apache/trafficcontrol/issues/6066) - Fixed missing/incorrect indices on some tables
 - [#6169](https://github.com/apache/trafficcontrol/issues/6169) - Fixed t3c-update not updating server status when a fallback to a previous Traffic Ops API version occurred
 - [#5576](https://github.com/apache/trafficcontrol/issues/5576) - Inconsistent Profile Name restrictions
+- [#6174](https://github.com/apache/trafficcontrol/issues/6174) - Fixed t3c-apply with no hostname failing if the OS hostname returns a full FQDN
 - Fixed Federations IMS so TR federations watcher will get updates.
 - [#5129](https://github.com/apache/trafficcontrol/issues/5129) - Updated TM so that it returns a 404 if the endpoint is not supported.
 
diff --git a/cache-config/t3c-apply/config/config.go b/cache-config/t3c-apply/config/config.go
index 6bfdcc9..ba33260 100644
--- a/cache-config/t3c-apply/config/config.go
+++ b/cache-config/t3c-apply/config/config.go
@@ -369,6 +369,8 @@ If any of the related flags are also set, they override the mode's default behav
 		if err != nil {
 			return Cfg{}, errors.New("Could not get the hostname from the O.S., please supply a hostname: " + err.Error())
 		}
+		// strings.Split always returns a slice with at least 1 element, so we don't need a len check
+		cacheHostName = strings.Split(cacheHostName, ".")[0]
 	}
 
 	useGit := StrToUseGitFlag(*useGitStr)
diff --git a/cache-config/testing/docker/docker-compose.yml b/cache-config/testing/docker/docker-compose.yml
index f5d9215..cba6697 100644
--- a/cache-config/testing/docker/docker-compose.yml
+++ b/cache-config/testing/docker/docker-compose.yml
@@ -85,6 +85,7 @@ services:
         RHEL_VERSION: ${RHEL_VERSION:-8}
       context: .
       dockerfile: ort_test/Dockerfile
+    cap_add: ['SYS_ADMIN'] # necessary for hostname tests
     depends_on:
       - yumserver
       - to_server
diff --git a/cache-config/testing/ort-tests/t3c-os-hostname-short_test.go b/cache-config/testing/ort-tests/t3c-os-hostname-short_test.go
new file mode 100644
index 0000000..747e113
--- /dev/null
+++ b/cache-config/testing/ort-tests/t3c-os-hostname-short_test.go
@@ -0,0 +1,127 @@
+package orttest
+
+/*
+   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.
+*/
+
+import (
+	"strings"
+	"testing"
+
+	"github.com/apache/trafficcontrol/cache-config/t3cutil"
+	"github.com/apache/trafficcontrol/cache-config/testing/ort-tests/tcdata"
+)
+
+func TestT3cApplyOSHostnameShort(t *testing.T) {
+	t.Log("------------- Starting TestT3cApplyOSHostnameShort tests ---------------")
+	tcd.WithObjs(t, []tcdata.TCObj{
+		tcdata.CDNs, tcdata.Types, tcdata.Tenants, tcdata.Parameters,
+		tcdata.Profiles, tcdata.ProfileParameters, tcdata.Statuses,
+		tcdata.Divisions, tcdata.Regions, tcdata.PhysLocations,
+		tcdata.CacheGroups, tcdata.Servers, tcdata.Topologies,
+		tcdata.DeliveryServices}, func() {
+		doTestT3cApplyOSHostnameShort(t)
+	})
+	t.Log("------------- End of TestT3cApplyOSHostnameShort tests ---------------")
+}
+
+func doTestT3cApplyOSHostnameShort(t *testing.T) {
+	// verifies that when no hostname is passed,
+	// t3c-apply will get the OS hostname,
+	// and use the short name (which is what will be in Traffic Ops),
+	// and not the full FQDN.
+
+	startingHost, errCode := getHostName()
+	if errCode != 0 {
+		t.Fatalf("getting the hostname failed: code %v message %v", errCode, startingHost)
+	}
+
+	t.Logf("original host is " + startingHost)
+
+	cacheHostName := "atlanta-edge-03"
+
+	if msg, code := setHostName(cacheHostName); code != 0 {
+		t.Fatalf("setting the hostname failed: code %v message %v", code, msg)
+	}
+
+	defer func() {
+		if msg, code := setHostName(startingHost); code != 0 {
+			t.Fatalf("setting the hostname back to the original '%v' failed: code %v message %v", startingHost, code, msg)
+		} else {
+			t.Logf("set hostname back to original '" + startingHost + "'")
+		}
+	}()
+
+	// verify the host was really set
+	if newHost, errCode := getHostName(); errCode != 0 {
+		t.Fatalf("getting the hostname failed: code %v message %v", errCode, newHost)
+	} else if newHost != cacheHostName {
+		t.Fatalf("setting hostname claimed it succeeded, but was '%v' expected '%v'", newHost, cacheHostName)
+	} else {
+		t.Logf("set hostname to '" + newHost + "'")
+	}
+
+	t.Logf("calling t3c-apply with no host flag, with a short hostname")
+	if stdOut, exitCode := t3cApplyNoHost(); exitCode != 0 {
+		t.Fatalf("t3c-apply with no hostname arg and and system hostname '%v' failed: code '%v' output '%v'\n", cacheHostName, exitCode, stdOut)
+	}
+
+	fqdnHostName := cacheHostName + ".fqdn.example.test"
+	if msg, code := setHostName(fqdnHostName); code != 0 {
+		t.Fatalf("setting the hostname failed: code %v message %v", code, msg)
+	}
+
+	// verify the host was really set
+	if newHost, errCode := getHostName(); errCode != 0 {
+		t.Fatalf("getting the hostname failed: code %v message %v", errCode, newHost)
+	} else if newHost != fqdnHostName {
+		t.Fatalf("setting hostname claimed it succeeded, but was '%v' expected '%v'", newHost, fqdnHostName)
+	} else {
+		t.Logf("set hostname to '" + newHost + "'")
+	}
+
+	t.Logf("calling t3c-apply with no host flag, with a fqdn hostname")
+	if stdOut, exitCode := t3cApplyNoHost(); exitCode != 0 {
+		t.Fatalf("t3c-apply with no hostname arg and and system hostname '%v' failed: code '%v' output '%v'\n", cacheHostName, exitCode, stdOut)
+	}
+}
+
+func setHostName(host string) (string, int) {
+	stdOut, stdErr, exitCode := t3cutil.Do("hostname", host)
+	return "out: " + string(stdOut) + " err: " + string(stdErr), exitCode
+}
+
+func getHostName() (string, int) {
+	stdOut, stdErr, exitCode := t3cutil.Do("hostname")
+	if exitCode == 0 {
+		return strings.TrimSpace(string(stdOut)), 0
+	}
+	return "out: " + string(stdOut) + " err: " + string(stdErr), exitCode
+}
+
+func t3cApplyNoHost() (string, int) {
+	args := []string{
+		"apply",
+		"--traffic-ops-insecure=true",
+		"--traffic-ops-timeout-milliseconds=3000",
+		"--traffic-ops-user=" + tcd.Config.TrafficOps.Users.Admin,
+		"--traffic-ops-password=" + tcd.Config.TrafficOps.UserPassword,
+		"--traffic-ops-url=" + tcd.Config.TrafficOps.URL,
+		"-vv",
+		"--omit-via-string-release=true",
+		"--git=" + "yes",
+		"--run-mode=" + "badass",
+	}
+	_, stdErr, exitCode := t3cutil.Do("t3c", args...)
+	return string(stdErr), exitCode
+}