Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#4654](https://github.com/apache/trafficcontrol/pull/4654) *Traffic Ops, Traffic Portal* Switched Delivery Service active state to a three-value system, adding a state that will be used to prevent cache servers from deploying DS configuration.

### Fixed
- [#7231](https://github.com/apache/trafficcontrol/pull/7231) *Traffic Ops, Traffic Portal* Fixed `sharedUserNames` display while retrieving CDN locks.
- [#7216](https://github.com/apache/trafficcontrol/pull/7216) *Traffic Portal* Fixed sort for Server's Capabilities Table
- [#4428](https://github.com/apache/trafficcontrol/issues/4428) *Traffic Ops* Fixed Internal Server Error with POST to `profileparameters` when POST body is empty
- [#7179](https://github.com/apache/trafficcontrol/issues/7179) *Traffic Portal* Fixed search filter for Delivery Service Table
Expand Down
11 changes: 5 additions & 6 deletions traffic_ops/traffic_ops_golang/cdn_lock/cdn_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import (
"github.com/lib/pq"
)

const readQuery = `SELECT username, cdn, message, soft, (select array_agg(u.username) AS shared_usernames from cdn_lock_user u join cdn_lock c on c.username = u.owner and c.cdn = u.cdn), last_updated FROM cdn_lock`

const readQuery = `SELECT c.username, c.cdn, c.message, c.soft, c.last_updated, ARRAY_REMOVE(ARRAY_AGG(DISTINCT(u.username)), null) AS shared_usernames FROM cdn_lock_user u FULL JOIN cdn_lock c ON c.username = u.owner AND c.cdn = u.cdn`
const insertQueryWithoutSharedUserNames = `INSERT INTO cdn_lock (username, cdn, message, soft) VALUES ($1, $2, $3, $4) RETURNING username, cdn, message, soft, last_updated`

const insertQueryWithSharedUserNames = `WITH first_insert AS (
Expand Down Expand Up @@ -77,8 +76,8 @@ func Read(w http.ResponseWriter, r *http.Request) {
defer inf.Close()

cols := map[string]dbhelpers.WhereColumnInfo{
"cdn": {Column: "cdn_lock.cdn", Checker: nil},
"username": {Column: "cdn_lock.username", Checker: nil},
"cdn": {Column: "c.cdn", Checker: nil},
"username": {Column: "c.username", Checker: nil},
}

where, orderBy, pagination, queryValues, errs := dbhelpers.BuildWhereAndOrderByAndPagination(inf.Params, cols)
Expand All @@ -90,7 +89,7 @@ func Read(w http.ResponseWriter, r *http.Request) {
}

cdnLock := []tc.CDNLock{}
query := readQuery + where + orderBy + pagination
query := readQuery + where + orderBy + pagination + " GROUP BY c.cdn"
rows, err := inf.Tx.NamedQuery(query, queryValues)
if err != nil {
api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, errors.New("querying cdn locks: "+err.Error()))
Expand All @@ -100,7 +99,7 @@ func Read(w http.ResponseWriter, r *http.Request) {

for rows.Next() {
var cLock tc.CDNLock
if err = rows.Scan(&cLock.UserName, &cLock.CDN, &cLock.Message, &cLock.Soft, pq.Array(&cLock.SharedUserNames), &cLock.LastUpdated); err != nil {
if err = rows.Scan(&cLock.UserName, &cLock.CDN, &cLock.Message, &cLock.Soft, &cLock.LastUpdated, pq.Array(&cLock.SharedUserNames)); err != nil {
api.HandleErr(w, r, tx, http.StatusInternalServerError, nil, errors.New("scanning cdn locks: "+err.Error()))
return
}
Expand Down
2 changes: 1 addition & 1 deletion traffic_portal/app/src/common/modules/locks/locks.tpl.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
<div id="locksContainer">
<div class="alert alert-dark" ng-repeat="l in locks">
<button type="button" class="close" title="Unlock {{l.cdn}}" ng-click="confirmUnlock(l)"><i class="fa fa-unlock"></i></button>
<div ng-bind-html="l.cdn + ' is ' + ((l.soft) ? 'soft' : 'hard') + ' locked by ' + l.userName + ' (' + l.message + ')' + ' and shared by ' + ((l.sharedUserNames) ? l.sharedUserNames : 'no one else') | linky:'_blank'"></div>
<div ng-bind-html="l.cdn + ' is ' + ((l.soft) ? 'soft' : 'hard') + ' locked by ' + l.userName + ' (' + l.message + ')' + ' and shared by ' + ((l.sharedUserNames && (l.sharedUserNames).length != 0) ? l.sharedUserNames : 'no one else') | linky:'_blank'"></div>
</div>
</div>