Skip to content
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

Set server XMPPID to hostname if empty #5725

Merged
merged 9 commits into from
Apr 9, 2021

Conversation

zrhoffman
Copy link
Member

@zrhoffman zrhoffman commented Apr 8, 2021

What does this PR (Pull Request) do?

This PR also adds a migration to set the XMPPID to the hostname for each server in the database for which the xmpp_id field is empty.

Which Traffic Control components are affected by this PR?

  • Traffic Ops

What is the best way to verify this PR?

  • Run the TO API tests
  • Running an SQL query directly against the database, set the XMPPID for a server to NULL or an empty string, then try updating it using Traffic Portal

If this is a bug fix, what versions of Traffic Control are affected?

The following criteria are ALL met by this PR

  • This PR includes tests
  • This PR contains documentation
  • This PR includes an update to CHANGELOG.md
  • This PR includes any and all required license headers
  • This PR DOES NOT FIX A SERIOUS SECURITY VULNERABILITY (see the Apache Software Foundation's security guidelines for details)

@zrhoffman zrhoffman added bug something isn't working as intended Traffic Ops related to Traffic Ops labels Apr 8, 2021
@zrhoffman zrhoffman requested a review from rawlinp April 9, 2021 16:47
@mitchell852
Copy link
Member

mitchell852 commented Apr 9, 2021

there is some incorrect documentation regarding XMPPID. want to fix that too? lots of this:

xmppId
An identifier to be used in XMPP communications with the server - in nearly all cases this will be the same as hostName

a better description may be something like:

xmppId
A poorly named property of a server used by Traffic Router for consistent hashing. On create, this is set to a UUID, however, legacy behaviour would use server hostname if this value was undefined.

^^ Pretty sure I got that wrong. Maybe @rawlinp has a better definition.

traffic_ops/traffic_ops_golang/server/servers.go Outdated Show resolved Hide resolved
traffic_ops/traffic_ops_golang/server/servers.go Outdated Show resolved Hide resolved
@rawlinp
Copy link
Contributor

rawlinp commented Apr 9, 2021

A poorly named property of a server used by Traffic Router for consistent hashing. On create, this is set to a UUID, however, legacy behaviour would use server hostname if this value was undefined.

This is pretty good, but I would add that it's an immutable property.

@rimashah25
Copy link
Contributor

rimashah25 commented Apr 9, 2021

there is some incorrect documentation regarding XMPPID. want to fix that too? lots of this:

xmppId
An identifier to be used in XMPP communications with the server - in nearly all cases this will be the same as hostName

Isn't that part of v1 docs.. soon to go away? I checked the codebase and couldn't find the above mention in any other documentation.

@mitchell852
Copy link
Member

there is some incorrect documentation regarding XMPPID. want to fix that too? lots of this:

xmppId
An identifier to be used in XMPP communications with the server - in nearly all cases this will be the same as hostName

Isn't that part of v1 docs.. soon to go away? I checked the codebase and couldn't find the above mention in any other documentation.

you are right @rimashah25 and it looks like it's better defined elsewhere:

xmppId
A system-generated UUID used to generate a server hashId for use in Traffic Router’s consistent hashing algorithm. This value is set when a server is created and cannot be changed afterwards.

@zrhoffman
Copy link
Member Author

there is some incorrect documentation regarding XMPPID. want to fix that too? lots of this:

xmppId
An identifier to be used in XMPP communications with the server - in nearly all cases this will be the same as hostName

Isn't that part of v1 docs.. soon to go away? I checked the codebase and couldn't find the above mention in any other documentation.

you are right @rimashah25 and it looks like it's better defined elsewhere:

xmppId
A system-generated UUID used to generate a server hashId for use in Traffic Router’s consistent hashing algorithm. This value is set when a server is created and cannot be changed afterwards.

Using the newer XMPPID definition for API v1 in a20cdf0.

@zrhoffman zrhoffman requested a review from rawlinp April 9, 2021 20:29
Copy link
Contributor

@rawlinp rawlinp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good now, just nitpicking the changelog and title :)

CHANGELOG.md Outdated
@@ -47,6 +47,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
- [#5405](https://github.com/apache/trafficcontrol/issues/5405) - Prevent Tenant update from choosing child as new parent
- [#5384](https://github.com/apache/trafficcontrol/issues/5384) - New grids will now properly remember the current page number.
- [#5548](https://github.com/apache/trafficcontrol/issues/5548) - Don't return a `403 Forbidden` when the user tries to get servers of a non-existent DS using `GET /servers?dsId={{nonexistent DS ID}}`
- [#5724](https://github.com/apache/trafficcontrol/issues/5724) - Generate XMPPID on update if the server had none
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this PR no longer generates UUIDs for XMPPID, we should probably say Set XMPPID to hostname if the server had none, don't error on server update when XMPPID is empty.

Also, would the title would make more sense now as "Set server XMPPID to hostname if empty"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated PR title and updated changelog entry in 04f137b.

@zrhoffman zrhoffman changed the title Generate XMPPID on server update if it is empty Set server XMPPID to hostname if empty Apr 9, 2021
@rawlinp rawlinp merged commit f599571 into apache:master Apr 9, 2021
@rawlinp
Copy link
Contributor

rawlinp commented Apr 9, 2021

Also if this PR is considered for backporting to a release branch, the backport should not include the DB migration. The code fix alone should be sufficient for fixing the bug.

@zrhoffman zrhoffman deleted the generate-xmppid-if-empty branch April 9, 2021 22:04
zrhoffman added a commit to zrhoffman/trafficcontrol that referenced this pull request Apr 27, 2021
* Generate XMPPID on server update if it is empty

* Hyphenate traffic-ops.yml

* Simplify condition

* Do not persistently set XMPPID on PUT if it is empty

* Remove xmpp_id from SQL query

* Include hostname in warning

* Use newer definition of XMPPID for API v1

* More accurate changelog entry

(cherry picked from commit f599571)
ocket8888 pushed a commit that referenced this pull request Apr 27, 2021
* Generate XMPPID on server update if it is empty

* Hyphenate traffic-ops.yml

* Simplify condition

* Do not persistently set XMPPID on PUT if it is empty

* Remove xmpp_id from SQL query

* Include hostname in warning

* Use newer definition of XMPPID for API v1

* More accurate changelog entry

(cherry picked from commit f599571)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something isn't working as intended Traffic Ops related to Traffic Ops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PUT /api/3.x/servers with no xmppId (hashId) results in an internal server error
4 participants