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

Bugfix/5405 parent child tenant update #5474

Merged

Conversation

tcfdev
Copy link
Collaborator

@tcfdev tcfdev commented Jan 27, 2021

What does this PR (Pull Request) do?

Which Traffic Control components are affected by this PR?

  • Traffic Ops

No documentation is required as this is a bug fix to align with expected behavior.

What is the best way to verify this PR?

A Go Unit Test has been added to ensure this behavior is ensured in the future.

Manual testing can be performed for verification as well.

  • In Traffic Portal, attempt to update a Tenant to select a child as the new parent. The action should not be allowed and an error message will be displayed at the top of the Tenant Update page.

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 OR I have explained why tests are unnecessary
  • This PR includes documentation OR I have explained why documentation is unnecessary
  • This PR includes an update to CHANGELOG.md OR such an update is not necessary
  • 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)

Additional Information

Some additional cleanup was performed as well, such as using the same name for the receiver throughout tenant.go and comments added.

Taylor Frey added 3 commits January 27, 2021 16:06
As it stands currently, there is a bug where you can update a Tenant
and select a child of said tenant to be the new parent.
This causes a circular reference in the database with the adjanceny
list and then prevents the child and parent from being returned in the
recursive CTE, which makes it appear as though those values have been
deleted.
> Note that should this happen it is still possible to salvage the data
by manually editing the `tenants` table and fixing the incorrect
parent/child relationship.

To prevent the problem, a check is done to ensure the chosen ParentID
does not reside in the current list of children when attempting to
update the Tenant.
@mitchell852 mitchell852 added Traffic Ops related to Traffic Ops bug something isn't working as intended high impact impacts the basic function, deployment, or operation of a CDN labels Jan 28, 2021
Comment on lines 214 to 216
usererr, syserr, statusCode := ten.isUpdatable()
if usererr != nil || syserr != nil {
return usererr, syserr, statusCode
Copy link
Contributor

Choose a reason for hiding this comment

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

just for consistency in the project, would you mind changing these to userErr and sysErr? and in a couple places down below as well? sorry for such a nitpicky comment

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Hey! Great catch. I had it in my head to dbl chk before submitting, but apparently missed it. Thanks for getting that.

Copy link
Contributor

@mattjackson220 mattjackson220 left a comment

Choose a reason for hiding this comment

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

Looks great! unit and API tests pass, manual testing works as expected

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 high impact impacts the basic function, deployment, or operation of a CDN Traffic Ops related to Traffic Ops
Projects
None yet
Development

Successfully merging this pull request may close these issues.

User can update parent tenant to have their child tenant as a new parent
3 participants