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

Cachegroup ui update with fallbacks#3203

Merged
mitchell852 merged 12 commits intoapache:masterfrom
mattjackson220:cachegroup_ui_update_with_fallbacks
Jan 25, 2019
Merged

Cachegroup ui update with fallbacks#3203
mitchell852 merged 12 commits intoapache:masterfrom
mattjackson220:cachegroup_ui_update_with_fallbacks

Conversation

@mattjackson220
Copy link
Copy Markdown
Contributor

@mattjackson220 mattjackson220 commented Jan 10, 2019

What does this PR do?

Fixes #1907

Updates the Cache Group page in Traffic Portal to include Cache Group Failovers and Fallback to Geo Failover checkbox, updates Cache Group API to include fallbackToClosest field, updates Traffic Portal documentation for changes

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?

Go to Topology -> Cache Groups.
Create a new Cache Group and select EDGE_LOC for the type.
Verify that the Failover Locations section appears at the bottom.
Add Cache Groups from the drop down menu.
Click Create and ensure the cachegroup_fallbacks table was updated.
Click Topology -> Cache Groups again. Find the group that was created.
Ensure the Failover Locations section is there and accurate with the groups you added.
Drag and Drop to reorder.
Click trash can on the right to delete a failover group.
Click Update and verify that the cachegroup_fallbacks table was updated.

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

… updated cache group API to allow control of cachegroup.fallbackToClosest through POST,PUT, and GET, updated documentation.
… updated cache group API to allow control of cachegroup.fallbackToClosest through POST,PUT, and GET, updated documentation.
@asfgit
Copy link
Copy Markdown
Contributor

asfgit commented Jan 10, 2019

Can one of the admins verify this patch?

@mitchell852 mitchell852 added Traffic Portal v1 related to Traffic Portal version 1 new feature A new feature, capability or behavior labels Jan 10, 2019
Copy link
Copy Markdown
Contributor

@chadgilloth chadgilloth left a comment

Choose a reason for hiding this comment

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

I checked out this branch and verified the UI changes by adding/removing/ordering fallbacks for new and edited Cache Groups.

Copy link
Copy Markdown
Member

@mitchell852 mitchell852 left a comment

Choose a reason for hiding this comment

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

a few suggestions

font-size: medium;
}

.allFallbacks{
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this file (_form.scss) is really intended for generic form styling. i would leave the drag and drop stuff here because that could potentially be used for any form. however, the stuff that is specific to the cache group form should go in it's own file. so you should create this:

traffic_portal/app/src/common/modules/form/cacheGroup/_form.cacheGroup.scss

then you can move all the cachegroup specific styles to that file.

and then you'll have to add that file to main.scss

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

}

$scope.getFallbackOptions = function() {
for (var i = 0; i < $scope.cacheGroups.length; i++) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you put some comments in this function? hard to figure out what it's doing exactly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

$scope.moveAbove = true;

$scope.updateFallbacks = function(cacheGroup) {
if (cacheGroup.fallbacks == null) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

can you put some comments in this function? hard to figure out what it's doing exactly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

<div class="allFallbacks" id="allFallbacks">
<div class="fallback" ng-repeat="fb in cacheGroup.fallbacks" dnd-enable="true" pageid="cacheGroupFallback">
<i class="fa fa-ellipsis-v fallback-grip drop-child" aria-hidden="true"></i>
<div class="fallback-list drop-child">{{ $index + 1 }}. {{fb}}</div>
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this should probalby be like:

{{ $index + 1 }}&nbsp;&nbsp;&nbsp;&nbsp;{{fb}}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@mitchell852 mitchell852 added Traffic Ops related to Traffic Ops documentation related to documentation labels Jan 16, 2019
Copy link
Copy Markdown
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.

You have two spaces after periods in a lot of places - I see this in the docs a lot for some reason. What's up with that? Do people think it looks better? The compiler will produce differing output for LaTeX (which ignores the extra space) and HTML (which I believe includes and renders it) so I'd prefer to avoid it, even if it is minor.


.. seealso:: :ref:`tp-configure-cache-groups`

#. Go to 'Topology', click on Cache Groups, and click on your desired Cache Group or click the + button to create a new Cache Group.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you make all instances of 'Cache Group' in the text into terms, so that they link to the glossary? You don't need to worry about it in section titles, and I'm not gonna make you do it in the API docs - there are a lot of instances in the API that need to be updated and they aren't the responsibility of this PR. They'll be done in a more general-purpose PR.

Example:

This links to the glossary: :term:`Cache Group`
Terms need to be followed by a space or punctuation, so to make it plural you need to do: :term:`Cache Group`\ s

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

.. _cachegroup-fallback-qht:

******************************
Configure CacheGroup Fallbacks
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For consistency please use "Cache Group" rather than "CacheGroup"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done


#. Go to 'Topology', click on Cache Groups, and click on your desired Cache Group or click the + button to create a new Cache Group.

.. figure:: cachegroup_fallback_qht/00.png
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The instructions make reference to a '+' button, but this screenshot cuts off said button.

I'm also not sold on showing production Cache Groups, imo it'd be better to use mock data (preferably with CDN-in-a-Box) to avoid any possible legal problems. Of course, I'm not a lawyer so maybe this is totally fine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done. and you are right, i removed the production Cache Groups


Failover Locations Delete

#. Click the Update button (if editing existing Cache Group) or the Create button (if creating new Cache Group) in order to save the Failovers to the Cache Group. No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This one's just a suggestion: you can use the guilabel text role to make things render like buttons

Example:

... or the :guilabel:`Create` button...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

ds_requests
steering
ciab
cachegroup_fallback No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the name of the file is cachegroup_fallback_qht.rst this won't include it. You could either change the filename or this line. It's up to you, but in my opinion it'd be best to change the filename; we already know it's a Quick How-to because it's in that section so I don't think the _qht adds any useful information.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

width:5%;
}

.hovering {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why couldn't you just use :hover?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done.

el.addEventListener(
'mouseover',
function(e) {
this.classList.add('hovering');
Copy link
Copy Markdown
Contributor

@ocket8888 ocket8888 Jan 16, 2019

Choose a reason for hiding this comment

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

Do you need this event listener? Is there a reason you can't write your CSS rule with e.g. .grabable:hover instead of .hovering?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done. i moved it into fallback:hover instead

</div>
</div>
<div class="form-group" ng-class="{'has-error': hasError(cacheGroupForm.fallbacks), 'has-feedback': hasError(cacheGroupForm.fallbacks)}" ng-hide="!isEdgeLoc(cacheGroup.typeId)">
<label class="control-label col-md-2 col-sm-2 col-xs-12">Failover Locations</label>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You seem to be mixing the terms "Failover Location" and "Failover Cache Group". This should really just use "Cache Group" everywhere (including in the documentation) because the user is selecting a Cache Group and Physical Locations are another object entirely which could cause confusion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
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.

So "Cache Group" should link to the glossary everywhere it appears in the documentation, even inside tables - the only exceptions are section titles and code-blocks. You could even do it in a figure title, though I won't make you.


******************************
Configure Cache Group Fallbacks
******************************
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You need to add an asterisk to the underline/overline to match the title length

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

| not_a_parent | parent.config | This is a boolean flag and is considered 'true' if it exists and has any value except 'false'. |
| | | This prevents servers with this parameter in their profile from being inserted into the ``parent.config`` generated for |
| | | servers with this server's Cache Group as a parent of their CacheGroup. This is primarily useful for when edge caches |
| | | servers with this server's Cache Group as a parent of their Cache Group. This is primarily useful for when edge caches |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This table is malformed. It should also link "Cache Group" to the glossary. (It should also use the .. table directive but that's not your problem)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

:Type: The Type of this Cache Group (see :ref:`tp-configure-types`)
:Latitude: A geographic latitude assigned to this Cache Group
:Longitude: A geographic longitude assigned to this Cache Group
:Name: The full name of this Cache Group
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Cache Group" should link to the glossary

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

width:5%;
}

.fallback:hover {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

You know, since this is a SCSS file you could use SCSS to put this inside of the .fallback rule. It'd look something like:

.fallback {
    background-color: #fff;

    &:hover {
        background: rgba(38,185,154,0.07);
    }
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Just a suggestion. I think it's a real shame that we spent all that time and effort fixing the sass compiler when 90% of our styling doesn't even make use of it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Copy Markdown
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.

Wow, man. You didn't need to link to the glossary everywhere - though I'm grateful you did because otherwise I would've - just the stuff you made/edited.

Copy link
Copy Markdown
Member

@mitchell852 mitchell852 left a comment

Choose a reason for hiding this comment

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

The code looks good from a TP perspective

@mitchell852
Copy link
Copy Markdown
Member

mitchell852 commented Jan 23, 2019

@mattjackson220 - If i edit an 'EDGE_LOC' cache group, i can add fallbacks just fine. So imagine that I add 2 fallbacks all is good. but if i change the CG type to 'MID_LOC' i still see the fallbacks in the database...my guess is this is probably fine and won't hurt anything. my guess is that fallbacks are simply ignored if type != EDGE_LOC but i just wanted to point it out in case there are any negative effects of this.

If you wanted to be really safe, I suppose on CG update if type != EDGE_LOC, you could set fallbacks = []. either in the UI or the API...or both. otherwise, this seems to work great in TP. nice work.

Copy link
Copy Markdown
Member

@rob05c rob05c left a comment

Choose a reason for hiding this comment

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

Go code looks good, tested traffic_ops_golang, everything behaves as expected, GET, GET /id PUT POST DELETE work as expected, passing fallbackToClosest sets and updates as expected, omitting it works as expected and sets the default in POST, null in PUT.

For anyone else reading this: this "new" field is in 1.1 not 1.5 because it's not actually new, the struct field and docs were added a long time ago, it's a bug that the app wasn't updating the field correctly.

This includes setting null in a PUT. That's unfortunately how PUT works. It unfortunately may cause issues for people with old files. But the alternative, behaving unexpectedly and in violation of the TC docs and RFC method, is even more dangerous.

Actually, @mattjackson220 now that I think of it: would you mind putting something in the CHANGELOG.md warning people about it, specifically that a PUT of an old cachegroup JSON without it (likely created from a GET) will result in a null field?

Other than that, everything in traffic_ops_golang looks good.

Note I only reviewed and tested traffic_ops_golang, not anything else in this PR.

… errors if fallbacks present on non-EDGE_LOC cache group. updated CHANGELOG
// removes Cache Group fallbacks if type has changed and is no longer EDGE_LOC
if (!$scope.isEdgeLoc(cacheGroup.typeId)) {
let currentFallbacksCount = cacheGroup.fallbacks.length;
for (var i = 0; i < currentFallbacksCount; i++) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it necessary to do this iteration? Could cacheGroup.fallbacks be set to an empty array, (or null/undefined, not sure which is appropriate tbh).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I did it this way so that it adds the previously selected fallbacks back into the list of available options in the drop down (and in the correct order where they started). Ultimately cacheGroup.fallbacks ends up as an empty array, but this also does the clean up to get them back as options

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I see

@ocket8888
Copy link
Copy Markdown
Contributor

I don't think this actually fixes #3003 . That issue is related to the /api/1.1/cachegroup_fallbacks endpoint which is still in Perl, and from what I can tell this didn't touch the Perl code, nor rewrite that (method of that) endpoint.

@mitchell852 mitchell852 merged commit f29e557 into apache:master Jan 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

documentation related to documentation new feature A new feature, capability or behavior Traffic Ops related to Traffic Ops Traffic Portal v1 related to Traffic Portal version 1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deterministic Cachegroup failover

6 participants