-
Notifications
You must be signed in to change notification settings - Fork 342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Renaming a host in TC, does not impact hash_id #4881
Conversation
Setting XMPPID to random UUID and not hostName that is seen in POST request
…o bugfix/CDN-1973
…o bugfix/CDN-1973
Added uuid package to vendor folder under traffic_ops_golang Updated CHANGELOG.md
…o bugfix/CDN-1973
…h id (aka xmppid) for a server.
@rimashah25 - so you probably want to update the api docs that say:
to something like:
or something like that. |
@mitchell852: Updated the documentation wrt xmppId |
@@ -47,6 +47,7 @@ import ( | |||
|
|||
"github.com/go-ozzo/ozzo-validation" | |||
"github.com/go-ozzo/ozzo-validation/is" | |||
"github.com/google/uuid" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using UUID to set xmppid to a random uuid
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticing an issue in the following case:
1.) Create a server
2.) Change the host name
3.) The xmpp_id doesn't change -> so far it looks great
4.) Do a PUT to change the server's xmpp ID with a json payload that has a different xmpp ID than the one in the database
5.) The Change doesn't take place in the DB (which is the expected behavior), however, we get back a message saying that the server was updated with the new xmpp ID. This is what the response looks like:
{"alerts":[{"text":"Server updated","level":"success"}],"response":{"cachegroup":"edgeserver","cachegroupId":2,"cdnId":1,"cdnName":"ALL","domainName":"rima2","guid":null,"hostName":"rimatest2","httpsPort":443,"id":10,"iloIpAddress":null,"iloIpGateway":null,"iloIpNetmask":null,"iloPassword":null,"iloUsername":null,"lastUpdated":"2020-07-17 14:51:47-06","mgmtIpAddress":null,"mgmtIpGateway":null,"mgmtIpNetmask":null,"offlineReason":null,"physLocation":"phys2","physLocationId":2,"profile":"TRAFFIC_OPS","profileDesc":"Traffic Ops profile","profileId":3,"rack":null,"revalPending":false,"routerHostName":null,"routerPortName":null,"status":"ONLINE","statusId":2,"tcpPort":80,"type":"EDGE","typeId":11,"updPending":false,"xmppId":"5fa51f60-6606-4c9d-8b60-2d78f96018zf","xmppPasswd":null,"interfaces":[{"ipAddresses":[{"address":"192.23.27.67","gateway":"255.255.245.0","serviceAddress":true},{"address":"123.45.67.89","gateway":"255.255.255.0","serviceAddress":false}],"maxBandwidth":5,"monitor":false,"mtu":1500,"name":"rima-interface"}]}}
The xmpp ID before this update was 5fa51f60-6606-4c9d-8b60-2d78f96018ae
in the database.
This remains the same even after the PUT
(which is what we want), however, notice how the response says that the server was updated with the new xmpp ID of 5fa51f60-6606-4c9d-8b60-2d78f96018zf
. We do not want this. The user should be notified that the server couldn't be updated because change of xmpp_id is not allowed
, or something to that effect.
I'm wondering if rather than simply ignoring the xmppId in the update query (which I believe is what it is doing) maybe it makes sense to return a 400 bad request if request.xmppId does not equal the xmpp_id found in the database for that server. i.e. if the user is trying to update xmppId, return 400 bad request with an alert of type error with a message like "xmppId cannot be changed". @ocket8888 - what do you think? xmppId is now immutable. if the user tries to change it on PUT which of the following should happen?
|
To keep with our API pattern, the fields should only be ignored if we're gonna remove it from responses. Changing it would be an invalid action on a field we admit exists, so it should be a 4XX error. |
…s with respect to xmppid
@mitchell852 @srijeet0406: I have updated the PR to reflect the changes based on this comment. |
@Rima - can you add message to let the user know what was wrong with the request? i.e. |
@mitchell852 Done. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a couple of comments on the code. The PUT
issue is fixed though, so good job on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good.
Unit tests and API tests pass.
Tested by changing the hostname of a server, made sure the xmpp_id doesn't change.
Tested by trying to PUT
an update to an existing server, by trying to change the xmpp_id, made sure the correct error message was received, and that the update didnt take place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In 2294f8f:
traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid
Submodule uuid added at bd4515
The actual files should be added, since the project does not use submodules.
This reverts commit 9a2d830.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since xmppId
is always no longer the hostname, CDN-in-a-Box won't finish starting up, because for some reason we were using xmppIds as hostnames:
current_servers_json=$(to-get 'api/'$TO_API_VERSION'/servers' 2>/dev/null | jq -c -e '[.response[] | .xmppId] | sort')
Would you please change .xmppId
there to .hostName
?
Done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like our OSS license compatibility checker complains about github.com/google/uuid
:
https://github.com/apache/trafficcontrol/runs/896246823
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/.travis.yml
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/CONTRIBUTORS
Error BSD-3-Clause! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/LICENSE
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/dce.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/doc.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/go.mod
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/hash.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/json_test.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/marshal.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/node.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/node_js.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/node_net.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/seq_test.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/sql.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/sql_test.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/time.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/util.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/uuid.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/uuid_test.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/version1.go
Error BSD-3-Clause~! traffic_ops/traffic_ops_golang/vendor/github.com/google/uuid/version4.go
From @alficles:
The punctuation at the end of the licenses means this:
~
: This license wasn't located in the file itself, but in a nearby LICENSE file and we assumed it applied.
!
: This license is fine, but you need to make sure that it's properly documented in the LICENSE file.
So, the uuid
dependency needs to be mentioned at the bottom of https://github.com/apache/trafficcontrol/blob/master/LICENSE
and https://github.com/google/uuid/blob/master/LICENSE needs to be added to https://github.com/apache/trafficcontrol/tree/master/licenses .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
API and unit tests pass, code is formatted correctly, weasel passes, code is clean
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm. creating a new server sets xmpp_id = uuid which is ultimately used for the hash id by traffic router. using a unique value like this will prevent any collisions between caches. also, checked that xmppId is immutable as changing it (and thus the hash id) would essentially invalidate a cache's cache which is not a very good thing.
What does this PR (Pull Request) do?
Which Traffic Control components are affected by this PR?
What is the best way to verify this PR?
If this is a bug fix, what versions of Traffic Control are affected?
The following criteria are ALL met by this PR
Additional Information
A new package, uuid, was added to traffic_ops_golang vendor folder.