Skip to content
This repository was archived by the owner on Nov 24, 2025. It is now read-only.

Fix TO Go DSS GET endpoints to check tenancy#2979

Merged
mitchell852 merged 1 commit intoapache:masterfrom
rob05c:to-go-dss-read-tenancy
Feb 5, 2019
Merged

Fix TO Go DSS GET endpoints to check tenancy#2979
mitchell852 merged 1 commit intoapache:masterfrom
rob05c:to-go-dss-read-tenancy

Conversation

@rob05c
Copy link
Member

@rob05c rob05c commented Oct 31, 2018

What does this PR do?

Fixes #2978

Which TC components are affected by this PR?

  • Documentation
  • Grove
  • Traffic Analytics
  • Traffic Monitor
  • Traffic Ops
  • Traffic Ops ORT
  • Traffic Portal
  • Traffic Router
  • Traffic Stats
  • Traffic Vault
  • Other _________

What is the best way to verify this PR?

With a Traffic Ops system and database set up with many delivery services, servers, and deliveryservice-server assignments:

Change your user's tenant to a tenant with fewer delivery services assigned, query the DSS read endpoints (deliveryservices/{xml_id}/servers and /deliveryserviceserver, verify only the DSes assigned to your user are returned.

Create a new tenant, with no delivery services assigned, change your user to that tenant, verify no DSes are returned.

Change your user to the root tenant, verify all delivery service server mappings are returned.

Check all that apply

  • This PR includes tests
  • This PR includes documentation updates
  • This PR includes an update to CHANGELOG.md
  • This PR includes all required license headers
  • This PR includes a database migration (ensure that migration sequence is correct)
  • This PR fixes a serious security flaw. Read more: www.apache.org/security

@rob05c rob05c added bug something isn't working as intended Traffic Ops related to Traffic Ops labels Oct 31, 2018
@rob05c
Copy link
Member Author

rob05c commented Oct 31, 2018

I'm labelling this bug, because it didn't replicate Perl, and it's the intuitively expected behavior. But, I honestly don't think it ever makes sense for a user or script to use this endpoint, without being the root tenant. Which is to say, I don't think it's ever useful to use Tenancy to manage this endpoint, rather than Capabilities. See my comments on #2978. Nevertheless, it's easier to mimic Perl than rethink the design at the moment.

@asfgit
Copy link
Contributor

asfgit commented Nov 1, 2018

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/2701/
Test PASSed.

@rob05c
Copy link
Member Author

rob05c commented Jan 30, 2019

This was fixed in #3081 - closing.

@rob05c rob05c closed this Jan 30, 2019
@rob05c
Copy link
Member Author

rob05c commented Jan 30, 2019

Ah, no it wasn't, my mistake. That PR fixed one endpoint, but not the other.

@rob05c rob05c reopened this Jan 30, 2019
@rob05c rob05c force-pushed the to-go-dss-read-tenancy branch from d3ab377 to 6053db1 Compare January 30, 2019 22:14
@asfgit
Copy link
Contributor

asfgit commented Jan 30, 2019

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/trafficcontrol-PR/3136/
Test PASSed.

@mitchell852
Copy link
Member

@ocket8888 is going to review this PR

Copy link
Contributor

@ocket8888 ocket8888 left a comment

Choose a reason for hiding this comment

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

Seems to work perfectly

@mitchell852 mitchell852 merged commit 5984799 into apache:master Feb 5, 2019
}

query, err := selectQuery(orderby, strconv.Itoa(limit), strconv.Itoa(offset))
tenancyEnabled, err := tenant.IsTenancyEnabledTx(tx.Tx)
Copy link
Contributor

Choose a reason for hiding this comment

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

late to the party, but tenancy is always enabled by default now so this check is unnecessary

Copy link
Contributor

Choose a reason for hiding this comment

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

But can it be turned off?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we decided to do that, but I don't think we actually did. The code still checks use_tenancy everywhere, and I think it's considered false if it doesn't exist.

I think this because the API Tests until recently broke horribly if you created that Parameter, suggesting Tenancy is disabled by default.

Also, I'm not opposed to making Tenancy "always on," but I do kind of think we should enable Capabilities at the same time (#2791). Tenancy isn't really useful without Capabilities to limit what users can do, and it could be deceptive, a CDN operator might think tenancy limits an admin/ops user, when it doesn't.

Copy link
Contributor

Choose a reason for hiding this comment

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

This has been my understanding, that tenancy is enabled by default, but still optional - though I have heard that the decision to make it not optional has been made (and not actually done yet).

Copy link
Contributor

Choose a reason for hiding this comment

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

It can be "turned off" by setting the parameter to false or deleting the parameter, but it is not really "turned off" at that point because we already have various places in the code that assume tenancy is always enabled (so they don't check the parameter). So "turning it off" doesn't completely turn it off, which is why we should really be preventing the deletion/update of the use_tenancy parameter to "turn off tenancy", since that really just leaves the system in an inconsistent state. Some things will check the tenancy parameter, whereas others already assume tenancy is always enabled.

We attempted to delete the use_tenancy parameter from the system but realized that there is too much existing code that depends on that parameter being there. The plan was to "fix" the existing code that checks the parameter by removing the parameter check and just assume that tenancy is always enabled. This was all discussed on the mailing list already; the decision to have it always enabled has already been made. Steps have already been made to enable it by default, but the existing code that checks the use_tenancy parameter has not been cleaned up yet.

tldr; tenancy should always be considered enabled, and existing code that checks the use_tenancy parameter needs to be fixed. Once all existing tenancy checks have been "fixed", the parameter can be deleted.

Copy link
Contributor

Choose a reason for hiding this comment

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

I definitely agree that should all be done, and the sooner the better. But until the use_tenancy parameter can actually be removed so that tenancy is a hard requirement of ATC it just seems safer to keep checking.

Copy link
Contributor

Choose a reason for hiding this comment

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

But until the use_tenancy parameter can actually be removed so that tenancy is a hard requirement of ATC it just seems safer to keep checking.

Then we should do our best to remove all the usages of the use_tenancy parameter from the codebase. I think the usage is fairly self-contained within helper functions, so maybe we can just change the helper functions to just return true. Then we can remove all the usages of the now-useless helper functions to clean up the code.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

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.

/api/1.x/deliveryserviceserver in Perl used to respect tenancy, but in Go doesn't

5 participants