You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by ma...@apache.org on 2020/03/11 14:25:11 UTC
[trafficcontrol] branch master updated: Deprecate keys/ping (#4470)
This is an automated email from the ASF dual-hosted git repository.
mattjackson 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 b3250fb Deprecate keys/ping (#4470)
b3250fb is described below
commit b3250fb58892953336a63e3415324b6b90d5b96c
Author: Steve Hamrick <sh...@users.noreply.github.com>
AuthorDate: Wed Mar 11 08:25:02 2020 -0600
Deprecate keys/ping (#4470)
* Use correct name
* Fix
* Merge
* Address reviews
* Fix docs
---
CHANGELOG.md | 1 +
docs/source/api/v1/keys_ping.rst | 73 ++++++++++++++++++++++++
traffic_ops/traffic_ops_golang/ping/keys.go | 10 ++--
traffic_ops/traffic_ops_golang/routing/routes.go | 1 -
4 files changed, 80 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8ec3fb7..482fb48 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -64,6 +64,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- /divisions/name/:name
- /hwinfo/dtdata
- /jobs/:id
+ - /keys/ping
- /logs/:days/days
- /parameters/:id/profiles
- /parameters/:id/unassigned_profiles
diff --git a/docs/source/api/v1/keys_ping.rst b/docs/source/api/v1/keys_ping.rst
new file mode 100644
index 0000000..de2202a
--- /dev/null
+++ b/docs/source/api/v1/keys_ping.rst
@@ -0,0 +1,73 @@
+..
+..
+.. 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.
+..
+.. _to-api-keys-ping:
+
+*************
+``keys/ping``
+*************
+Checks whether :ref:`tv-overview` is online.
+
+.. deprecated:: ATCv4
+
+``GET``
+=======
+:Auth. Required: Yes
+:Roles Required: None
+:Response Type: Object
+
+Request Structure
+-----------------
+No parameters available.
+
+.. code-block:: http
+ :caption: Request Example
+
+ GET /api/1.1/keys/ping HTTP/1.1
+ User-Agent: python-requests/2.22.0
+ Accept-Encoding: gzip, deflate
+ Accept: */*
+ Connection: keep-alive
+ Cookie: mojolicious=...
+
+Response Structure
+------------------
+:server: The hostname and port of :ref:`tv-overview`.
+:status: The `reason phrase <https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html#sec6.1.1>`_ of the response that :ref:`to-overview` received from :ref:`tv-overview`.
+
+.. code-block:: http
+ :caption: Response Example
+
+ HTTP/1.1 200 OK
+ Access-Control-Allow-Credentials: true
+ Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Set-Cookie, Cookie
+ Access-Control-Allow-Methods: POST,GET,OPTIONS,PUT,DELETE
+ Access-Control-Allow-Origin: *
+ Content-Encoding: gzip
+ Content-Type: application/json
+ Set-Cookie: mojolicious=...; Path=/; Expires=Mon, 24 Feb 2020 21:09:31 GMT; Max-Age=3600; HttpOnly
+ Whole-Content-Sha512: Y/Br43Y5SXXBIneAgHANBXDP0hqO4Lkguk0vmuTU7xktZq3EldK5SX9OkEm9gzRkPKjQVUy0hhldsq6Ax46k7A==
+ X-Server-Name: traffic_ops_golang/
+ Date: Mon, 24 Feb 2020 20:09:31 GMT
+ Content-Length: 166
+
+ { "alerts": [{
+ "level": "warning",
+ "text": "This endpoint is deprecated, please use /vault/ping instead"
+ }],
+ "response": {
+ "status": "OK",
+ "server": "trafficvault.infra.ciab.test:8087"
+ }
+ }
diff --git a/traffic_ops/traffic_ops_golang/ping/keys.go b/traffic_ops/traffic_ops_golang/ping/keys.go
index 98b15b3..eabb512 100644
--- a/traffic_ops/traffic_ops_golang/ping/keys.go
+++ b/traffic_ops/traffic_ops_golang/ping/keys.go
@@ -20,25 +20,27 @@ package ping
*/
import (
- "errors"
"net/http"
+ "github.com/apache/trafficcontrol/lib/go-util"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/riaksvc"
)
+const API_VAULT_PING = "/vault/ping"
+
func Keys(w http.ResponseWriter, r *http.Request) {
inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil)
if userErr != nil || sysErr != nil {
- api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+ api.HandleDeprecatedErr(w, r, nil, errCode, userErr, sysErr, util.StrPtr(API_VAULT_PING))
return
}
defer inf.Close()
pingResp, err := riaksvc.Ping(inf.Tx.Tx, inf.Config.RiakAuthOptions, inf.Config.RiakPort)
if err != nil {
- api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError, nil, errors.New("error pinging Riak keys: "+err.Error()))
+ api.HandleDeprecatedErr(w, r, nil, http.StatusInternalServerError, err, nil, util.StrPtr(API_VAULT_PING))
return
}
- api.WriteResp(w, r, pingResp.Status)
+ api.WriteAlertsObj(w, r, http.StatusOK, api.CreateDeprecationAlerts(util.StrPtr(API_VAULT_PING)), pingResp)
}
diff --git a/traffic_ops/traffic_ops_golang/routing/routes.go b/traffic_ops/traffic_ops_golang/routing/routes.go
index cbdf95b..7adac0c 100644
--- a/traffic_ops/traffic_ops_golang/routing/routes.go
+++ b/traffic_ops/traffic_ops_golang/routing/routes.go
@@ -266,7 +266,6 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) {
//Ping
{api.Version{2, 0}, http.MethodGet, `ping$`, ping.PingHandler(), 0, NoAuth, nil, 2555661597, noPerlBypass},
{api.Version{2, 0}, http.MethodGet, `vault/ping/?$`, ping.Vault, auth.PrivLevelReadOnly, Authenticated, nil, 2884012114, noPerlBypass},
- {api.Version{2, 0}, http.MethodGet, `keys/ping/?$`, ping.Keys, auth.PrivLevelReadOnly, Authenticated, nil, 218416022, noPerlBypass},
//Profile: CRUD
{api.Version{2, 0}, http.MethodGet, `profiles/?$`, api.ReadHandler(&profile.TOProfile{}), auth.PrivLevelReadOnly, Authenticated, nil, 268758589, noPerlBypass},