You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by rs...@apache.org on 2024/01/24 15:45:49 UTC

(trafficcontrol) branch 8.0.x updated (d1d28ee37c -> 6cb2bca67c)

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

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


    from d1d28ee37c Documentation cleanup (#7798)
     new 3878228f04 Include commits since last release in RPM build number (#7896)
     new 44ede89f28 Get build number from BUILD_NUMBER file if not in a repo (#7922)
     new 6cb2bca67c t3c RPM DB check to work with rocky linux 9 (#7866)

The 3 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                                       |   4 +-
 build/functions.sh                                 |  11 ++-
 cache-config/t3c-apply/config/config.go            | 110 ++++++++++++++++-----
 docs/source/api/v3/about.rst                       |   2 +-
 docs/source/api/v4/about.rst                       |   2 +-
 docs/source/api/v5/about.rst                       |   2 +-
 experimental/traffic-portal/server.config.ts       |   5 +-
 infrastructure/cdn-in-a-box/Makefile               |  16 ++-
 traffic_ops/testing/api/conf/traffic-ops-test.conf |   8 +-
 9 files changed, 124 insertions(+), 36 deletions(-)


(trafficcontrol) 03/03: t3c RPM DB check to work with rocky linux 9 (#7866)

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

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

commit 6cb2bca67c27f926ff4b8f84de7818e7a8191b0d
Author: Joe Pappano <jo...@cable.comcast.com>
AuthorDate: Tue Nov 14 13:08:53 2023 -0700

    t3c RPM DB check to work with rocky linux 9 (#7866)
    
    (cherry picked from commit 7a3e1e0f5566b315252ad8bc9bfe195cc8807096)
---
 CHANGELOG.md                            |   1 +
 cache-config/t3c-apply/config/config.go | 110 ++++++++++++++++++++++++--------
 2 files changed, 86 insertions(+), 25 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index da1c64196c..af6c7a096f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -189,6 +189,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 - [#7688](https://github.com/apache/trafficcontrol/pull/7688) *Traffic Ops*: Fixed secured parameters being visible when role has proper permissions.
 - [#7697](https://github.com/apache/trafficcontrol/pull/7697) *Traffic Ops*: Fixed `iloPassword` and `xmppPassword` checking for priv-level instead of using permissions.
 - [#7817](https://github.com/apache/trafficcontrol/pull/7817) *Traffic Control Cache Config (t3c)*: Fixed issue that would cause null ptr panic on client fallback.
+- [#7866](https://github.com/apache/trafficcontrol/pull/7866) *Traffic Control Cache Config (t3c)*: Fixed rpm db check to work with rocky linux 9.
 
 ### Removed
 - [#7808](https://github.com/apache/trafficcontrol/pull/7808) *Traffic Router*: Set SOA `minimum` field to a custom value defined in the `tld.soa.minimum` param, and remove the previously added `dns.negative.caching.ttl` property.
diff --git a/cache-config/t3c-apply/config/config.go b/cache-config/t3c-apply/config/config.go
index e21f9279fd..7f977cec1e 100644
--- a/cache-config/t3c-apply/config/config.go
+++ b/cache-config/t3c-apply/config/config.go
@@ -191,29 +191,6 @@ func directoryExists(dir string) (bool, os.FileInfo) {
 	return info.IsDir(), info
 }
 
-const rpmDir = "/var/lib/rpm"
-
-// verifies the rpm database files. if there is any database corruption
-// it will return false
-func verifyRpmDB() bool {
-	exclude := regexp.MustCompile(`(^\.|^__)`)
-	dbFiles, err := os.ReadDir(rpmDir)
-	if err != nil {
-		return false
-	}
-	for _, file := range dbFiles {
-		if exclude.Match([]byte(file.Name())) {
-			continue
-		}
-		cmd := exec.Command("/usr/lib/rpm/rpmdb_verify", rpmDir+"/"+file.Name())
-		err := cmd.Run()
-		if err != nil || cmd.ProcessState.ExitCode() > 0 {
-			return false
-		}
-	}
-	return true
-}
-
 // derives the ATS Installation directory from
 // the rpm config file list.
 func GetTSPackageHome() string {
@@ -251,6 +228,68 @@ func GetTSPackageHome() string {
 	return tsHome
 }
 
+const (
+	rpmDBBdb             = "bdb"
+	rpmDBSquLite         = "sqlite"
+	rpmDBUnknown         = "unknown"
+	rpmDBVerifyCmd       = "/usr/lib/rpm/rpmdb_verify"
+	sqliteRpmDbVerifyCmd = "/bin/sqlite3"
+	rpmDir               = "/var/lib/rpm"
+	sqliteRpmDB          = "rpmdb.sqlite"
+)
+
+// getRpmDBBackend uses "%_db_backend" macro to get the database type
+func getRpmDBBackend() (string, error) {
+	var outBuf bytes.Buffer
+	cmd := exec.Command("/bin/rpm", "-E", "%_db_backend")
+	cmd.Stdout = &outBuf
+	err := cmd.Run()
+	if err != nil {
+		return rpmDBUnknown, err
+	}
+	return strings.TrimSpace(outBuf.String()), nil
+}
+
+// isSqliteInstalled looks to see if the sqlite3 executable
+// is installed which is needed to do the db verify
+func isSqliteInstalled() bool {
+	sqliteUtil := isCommandAvailable("/bin/sqlite3")
+	return sqliteUtil
+}
+
+// verifies the rpm database files. if there is any database corruption
+// it will return false
+func verifyRpmDB(rpmDir string) bool {
+	exclude := regexp.MustCompile(`(^\.|^__)`)
+	dbFiles, err := os.ReadDir(rpmDir)
+	if err != nil {
+		return false
+	}
+	for _, file := range dbFiles {
+		if exclude.Match([]byte(file.Name())) {
+			continue
+		}
+		cmd := exec.Command(rpmDBVerifyCmd, rpmDir+"/"+file.Name())
+		err := cmd.Run()
+		if err != nil || cmd.ProcessState.ExitCode() > 0 {
+			return false
+		}
+	}
+	return true
+}
+
+// verifySqliteRpmDB runs PRAGMA quick_check
+// requires /bin/sqlite3
+func verifySqliteRpmDB(sqliteDB string) bool {
+	args := []string{sqliteDB, `PRAGMA quick_check`}
+	cmd := exec.Command(sqliteRpmDbVerifyCmd, args...)
+	err := cmd.Run()
+	if err != nil || cmd.ProcessState.ExitCode() > 0 {
+		return false
+	}
+	return true
+}
+
 func GetCfg(appVersion string, gitRevision string) (Cfg, error) {
 	var err error
 	toInfoLog := []string{}
@@ -499,7 +538,29 @@ If any of the related flags are also set, they override the mode's default behav
 		os.Setenv("TO_PASS", toPass)
 	}
 
-	rpmDBisOk := verifyRpmDB()
+	rpmDBisOk := true
+	rpmDBType, err := getRpmDBBackend()
+	if err != nil {
+		toInfoLog = append(toInfoLog, fmt.Sprintf("error getting db type: %s", err.Error()))
+		rpmDBType = rpmDBUnknown
+	}
+
+	if rpmDBType == rpmDBSquLite {
+		sqliteUtil := isSqliteInstalled()
+		toInfoLog = append(toInfoLog, fmt.Sprintf("RPM database is %s", rpmDBSquLite))
+		if sqliteUtil {
+			rpmDBisOk = verifySqliteRpmDB(rpmDir + "/" + sqliteRpmDB)
+			toInfoLog = append(toInfoLog, fmt.Sprintf("RPM database is ok: %t", rpmDBisOk))
+		} else {
+			toInfoLog = append(toInfoLog, "/bin/sqlite3 not available, RPM database not checked")
+		}
+	} else if rpmDBType == rpmDBBdb {
+		toInfoLog = append(toInfoLog, fmt.Sprintf("RPM database is %s", rpmDBBdb))
+		rpmDBisOk = verifyRpmDB(rpmDir)
+		toInfoLog = append(toInfoLog, fmt.Sprintf("RPM database is ok: %t", rpmDBisOk))
+	} else {
+		toInfoLog = append(toInfoLog, fmt.Sprintf("RPM DB type is %s DB check will be skipped", rpmDBUnknown))
+	}
 
 	if *installPackagesPtr && !rpmDBisOk {
 		if t3cutil.StrToMode(*runModePtr) == t3cutil.ModeBadAss {
@@ -509,7 +570,6 @@ If any of the related flags are also set, they override the mode's default behav
 		}
 	}
 
-	toInfoLog = append(toInfoLog, fmt.Sprintf("rpm database is ok: %t", rpmDBisOk))
 	// set TSHome
 	var tsHome = ""
 	if *tsHomePtr != "" {


(trafficcontrol) 01/03: Include commits since last release in RPM build number (#7896)

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

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

commit 3878228f041b0ea931a8df8fda82cf0e62e26eeb
Author: Zach Hoffman <zr...@apache.org>
AuthorDate: Thu Jan 11 12:34:08 2024 -0700

    Include commits since last release in RPM build number (#7896)
    
    * Use number of commits since last release in build number
    
    Previously, the number of commits ever was used, to ensure that a build
    from a later child commit will always be considered a higher version
    number.
    
    Because the version number increases each time the release version
    increases, counting only the commits since the last release tag is
    sufficient.
    
    * Set pipefail and escape $() in Makefile
    
    * Include --long to always get relative commit count
    
    * Use pipefail shell option within bash
    
    * Fall back to commit count of 0 in TPv2
    
    (cherry picked from commit 21d7c9a7109652f091d3b03cdadb9a89d4118865)
---
 CHANGELOG.md                                       |  3 ++-
 build/functions.sh                                 | 11 ++++++++++-
 docs/source/api/v3/about.rst                       |  2 +-
 docs/source/api/v4/about.rst                       |  2 +-
 docs/source/api/v5/about.rst                       |  2 +-
 experimental/traffic-portal/server.config.ts       |  5 ++++-
 infrastructure/cdn-in-a-box/Makefile               |  2 +-
 traffic_ops/testing/api/conf/traffic-ops-test.conf |  8 ++++----
 8 files changed, 24 insertions(+), 11 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 66b5e324f9..da1c64196c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,8 +3,9 @@ All notable changes to this project will be documented in this file.
 
 The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
 
-## [8.0.0] - 2024-01-17
+## [8.0.0] - 2024-01-24
 ### Added
+- [#7896](https://github.com/apache/trafficcontrol/pull/7896) *ATC Build system*: Count commits since the last release, not commits.
 - [#7672](https://github.com/apache/trafficcontrol/pull/7672) *Traffic Control Health Client*: Added peer monitor flag while using `strategies.yaml`.
 - [#7609](https://github.com/apache/trafficcontrol/pull/7609) *Traffic Portal*: Added Scope Query Param to SSO login.
 - [#7450](https://github.com/apache/trafficcontrol/pull/7450) *Traffic Ops*: Removed hypnotoad section and added listen field to traffic_ops_golang section in order to simplify cdn config.
diff --git a/build/functions.sh b/build/functions.sh
index 97355df8ec..718516d833 100755
--- a/build/functions.sh
+++ b/build/functions.sh
@@ -93,7 +93,16 @@ getBuildNumber() {
 	local in_git=''
 	if isInGitTree; then
 		local commits sha
-		commits="$(git rev-list HEAD 2>/dev/null | wc -l | awk '{print $1}')" # awk is for BSD compatibility
+		# The number of commits since the last tag
+		if ! commits="$(git describe --long --tags \
+			--match='RELEASE-[0-9].[0-9].[0-9]' \
+			--match='RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]' \
+			--match='v[0-9].[0-9].[0-9]' \
+			--match='v[0-9][0-9].[0-9][0-9].[0-9][0-9]' |
+			awk -F- '{print $(NF-1)}')";
+		then
+			commits=0
+		fi
 		sha="$(git rev-parse --short=8 HEAD)"
 		echo "$commits.$sha"
 	else
diff --git a/docs/source/api/v3/about.rst b/docs/source/api/v3/about.rst
index 259956146c..39fa050c08 100644
--- a/docs/source/api/v3/about.rst
+++ b/docs/source/api/v3/about.rst
@@ -45,7 +45,7 @@ No parameters available.
 Response Structure
 ------------------
 :commitHash:    The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
-:commits:       The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by running ``git rev-list HEAD | wc -l``.
+:commits:       The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
 :goVersion:     The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
 :release:       The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
 :name:          The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
diff --git a/docs/source/api/v4/about.rst b/docs/source/api/v4/about.rst
index f0e56831c3..78b7e38258 100644
--- a/docs/source/api/v4/about.rst
+++ b/docs/source/api/v4/about.rst
@@ -46,7 +46,7 @@ No parameters available.
 Response Structure
 ------------------
 :commitHash:    The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
-:commits:       The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by running ``git rev-list HEAD | wc -l``.
+:commits:       The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
 :goVersion:     The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
 :release:       The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
 :name:          The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
diff --git a/docs/source/api/v5/about.rst b/docs/source/api/v5/about.rst
index 7841e66921..62af25b199 100644
--- a/docs/source/api/v5/about.rst
+++ b/docs/source/api/v5/about.rst
@@ -46,7 +46,7 @@ No parameters available.
 Response Structure
 ------------------
 :commitHash:    The `Git <https://git-scm.com/>`_ commit hash that Traffic Ops was built at.
-:commits:       The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by running ``git rev-list HEAD | wc -l``.
+:commits:       The number of commits in the branch of the commit that Traffic Ops was built at, including that commit. Calculated by extracting the commit count from running ``git describe --tags --long``.
 :goVersion:     The version of `Go <https://golang.org/>`_ that was used to build Traffic Ops.
 :release:       The major version of CentOS or Red Hat Enterprise Linux that the build environment was running.
 :name:          The human-readable name of the `RPM <https://rpm-packaging-guide.github.io/#packaging-software>`_ file.
diff --git a/experimental/traffic-portal/server.config.ts b/experimental/traffic-portal/server.config.ts
index 83657b7f2a..26485be520 100644
--- a/experimental/traffic-portal/server.config.ts
+++ b/experimental/traffic-portal/server.config.ts
@@ -340,9 +340,12 @@ export async function getVersion(path?: string): Promise<ServerVersion> {
 	};
 
 	try {
-		ver.commits = String(execSync("git rev-list HEAD", {encoding: "utf8"}).split("\n").length);
 		ver.hash = execSync("git rev-parse --short=8 HEAD", {encoding: "utf8"}).trimEnd();
+		ver.commits = String(execSync("git describe --long --tags " +
+			"--match=RELEASE-[0-9].[0-9].[0-9] --match=RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9] " +
+			"--match=v[0-9].[0-9].[0-9] --match=v[0-9][0-9].[0-9][0-9].[0-9][0-9]", {encoding: "utf8"}).split("-").slice(-2)[0]);
 	} catch (e) {
+		ver.commits = "0";
 		console.warn("getting git parts of version:", e);
 	}
 
diff --git a/infrastructure/cdn-in-a-box/Makefile b/infrastructure/cdn-in-a-box/Makefile
index 6d9ca65a80..f0890f989c 100644
--- a/infrastructure/cdn-in-a-box/Makefile
+++ b/infrastructure/cdn-in-a-box/Makefile
@@ -40,7 +40,7 @@ TC_DIR := $(CIAB_DIR_RELATIVE)../..
 PKG_COMMAND := $(TC_DIR)/pkg
 PKG_FLAGS := -v -$(RHEL_VERSION)
 BUILD_SUFFIX := _build
-BUILD_NUMBER := $(shell git rev-list HEAD 2>/dev/null | wc -l | tr -d '[[:space:]]').$(shell git rev-parse --short=8 HEAD)
+BUILD_NUMBER := $(shell bash -c 'set -o pipefail -o xtrace; git describe --long --tags --match="RELEASE-[0-9].[0-9].[0-9]" --match="RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]" --match="v[0-9].[0-9].[0-9]" --match="v[0-9][0-9].[0-9][0-9].[0-9][0-9]" | awk -F- "{print \$$(NF-1)}"' || echo 0).$(shell git rev-parse --short=8 HEAD)
 BUILD_ARCH   := $(shell docker run --name=ciab-get-$(BASE_IMAGE)-$(RHEL_VERSION)-arch --rm $(BASE_IMAGE):$(RHEL_VERSION) rpm --eval %_arch )
 TC_VERSION := $(shell cat "$(TC_DIR)/VERSION")
 TOMCAT_VERSION := $(shell grep '^\s*TOMCAT_VERSION=' "$(TC_DIR)/traffic_router/build/build_rpm.sh"  | cut -d= -f2)
diff --git a/traffic_ops/testing/api/conf/traffic-ops-test.conf b/traffic_ops/testing/api/conf/traffic-ops-test.conf
index 1143dc0979..075e7ba707 100644
--- a/traffic_ops/testing/api/conf/traffic-ops-test.conf
+++ b/traffic_ops/testing/api/conf/traffic-ops-test.conf
@@ -15,7 +15,7 @@
     "use_ims": true,
     "role_based_permissions": false,
     "trafficOps": {
-        "URL": "https://localhost:6443",
+        "URL": "https://localhost:8443",
         "password": "twelve",
         "users": {
             "disallowed": "disallowed",
@@ -28,10 +28,10 @@
         }
     },
     "trafficOpsDB": {
-        "dbname": "traffic_ops_development",
-        "description": "dev database traffic_ops_development",
+        "dbname": "to_test",
+        "description": "test database traffic_ops_development",
         "hostname": "localhost",
-        "password": "twelve12",
+        "password": "twelve",
         "port": "5432",
         "type": "Pg",
         "user": "traffic_ops"


(trafficcontrol) 02/03: Get build number from BUILD_NUMBER file if not in a repo (#7922)

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

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

commit 44ede89f289407114cb67f4b12ba21688e3c01e0
Author: Zach Hoffman <zr...@apache.org>
AuthorDate: Wed Jan 24 08:35:14 2024 -0700

    Get build number from BUILD_NUMBER file if not in a repo (#7922)
    
    * Break $(shell) function into multiple lines for readability
    
    * Get build number from BUILD_NUMBER file if not in a git repo
    
    (cherry picked from commit 13488f86e3e14b8e0d6d8a8403b59032f86a0482)
---
 infrastructure/cdn-in-a-box/Makefile | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/infrastructure/cdn-in-a-box/Makefile b/infrastructure/cdn-in-a-box/Makefile
index f0890f989c..71e2e2e23b 100644
--- a/infrastructure/cdn-in-a-box/Makefile
+++ b/infrastructure/cdn-in-a-box/Makefile
@@ -40,7 +40,21 @@ TC_DIR := $(CIAB_DIR_RELATIVE)../..
 PKG_COMMAND := $(TC_DIR)/pkg
 PKG_FLAGS := -v -$(RHEL_VERSION)
 BUILD_SUFFIX := _build
-BUILD_NUMBER := $(shell bash -c 'set -o pipefail -o xtrace; git describe --long --tags --match="RELEASE-[0-9].[0-9].[0-9]" --match="RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]" --match="v[0-9].[0-9].[0-9]" --match="v[0-9][0-9].[0-9][0-9].[0-9][0-9]" | awk -F- "{print \$$(NF-1)}"' || echo 0).$(shell git rev-parse --short=8 HEAD)
+BUILD_NUMBER := $(shell bash -c ' \
+	set -o errexit -o pipefail -o xtrace; \
+	git rev-parse --is-inside-work-tree >/dev/null; \
+	output="$$(git describe \
+		--long \
+		--tags \
+		--match="RELEASE-[0-9].[0-9].[0-9]" \
+		--match="RELEASE-[0-9][0-9].[0-9][0-9].[0-9][0-9]" \
+		--match="v[0-9].[0-9].[0-9]" \
+		--match="v[0-9][0-9].[0-9][0-9].[0-9][0-9]" | \
+		awk -F- "{print \$$(NF-1)}" || \
+		echo 0)"; \
+	output+=".$$(git rev-parse --short=8 HEAD)"; \
+	echo "$$output"' || \
+	cat $(TC_DIR)/BUILD_NUMBER)
 BUILD_ARCH   := $(shell docker run --name=ciab-get-$(BASE_IMAGE)-$(RHEL_VERSION)-arch --rm $(BASE_IMAGE):$(RHEL_VERSION) rpm --eval %_arch )
 TC_VERSION := $(shell cat "$(TC_DIR)/VERSION")
 TOMCAT_VERSION := $(shell grep '^\s*TOMCAT_VERSION=' "$(TC_DIR)/traffic_router/build/build_rpm.sh"  | cut -d= -f2)