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

[Secrets Sync] enable access to Sync clients page for HVD clusters #26713

Conversation

andaley
Copy link
Contributor

@andaley andaley commented Apr 30, 2024

🛠️ Description

  • show sync clients in client count nav bar if there's a sync client history OR if the feature is able to be activated
  • show sync charts on overview page if sync client history OR if the feature is activated

🧹 move client count nav bar to its own component

📸 Screenshots

image

🏗️ How to Build and Test the Change

For OSS

  • sync client charts and tabs should be hidden
    For HVD (most easily accomplished by pulling this down locally and hard-coding isHvdManaged = true in the flags service)
  • sync client tab is shown
  • charts are hidden unless there's a sync client history

@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Apr 30, 2024
Copy link

CI Results: failed ❌

@andaley andaley changed the title UI/vault 26096/enable sync hvd clients page [Secrets Sync] enable access to Sync clients page for HVD clusters Apr 30, 2024
@andaley andaley modified the milestones: 1.17.0, 1.17.0-rc Apr 30, 2024
@andaley andaley changed the base branch from main to ui/VAULT-25468/enable-secrets-sync-hvd April 30, 2024 23:55
@andaley andaley force-pushed the ui/vault-26096/enable-sync-hvd-clients-page branch from a4f86e0 to 1717654 Compare April 30, 2024 23:56
@@ -151,32 +151,7 @@
</Hds::Alert>
{{/if}}

<nav class="tabs has-bottom-margin-s" aria-label="navigation for managing client counts">
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this file & its associated test were getting a bit hairy, so moved it into a separate component 🧹

@@ -40,12 +40,6 @@ module('Acceptance | clients | overview', function (hooks) {
timestamp.now.restore();
});

test('it should render the correct tabs', async function (assert) {
Copy link
Contributor Author

@andaley andaley May 1, 2024

Choose a reason for hiding this comment

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

this is now covered by the nav-bar-tests integration tests 😀

integration > acceptance tests for basic "does this thing show up on the DOM?"

Comment on lines 65 to 70
// we can't tell if HVD clusters have the feature or not, so we show it by default
// if the cluster is not HVD, show the tab if the feature is on the license
Copy link
Contributor

Choose a reason for hiding this comment

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

great comments! 👏

@andaley andaley force-pushed the ui/vault-26096/enable-sync-hvd-clients-page branch from 375f891 to 2e460d0 Compare May 1, 2024 16:25
@andaley andaley force-pushed the ui/vault-26096/enable-sync-hvd-clients-page branch from dc85aad to 36958d6 Compare May 2, 2024 00:51
'Secret sync': formatNumber([topNamespace.secret_syncs]),
};
for (const label in expectedStats) {
module('filtering charts', function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Was the decision to convert to modules to try and address the flakiness? In my experience, these tests weren't flaky before 🤔 , so if that isn't the case then could this refactor happen in a separate PR?

I completely agree with refactoring these into modules! But a separate PR would be make this one easier to review and check that test coverage has been added for the relevant logic updates. Historically, we've also had folks accidentally remove important test assertions for this area of the code base due to the intricacies of this dang dashboard 😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

that's correct, i moved them into separate tests to try to isolate the failures. what happened here was that i switched to using the sync mirage handler instead of the clients one at the top-level beforeEach hooks because making assertions on the secrets sync charts required secrets sync being included in the /activated-features response, which the clients handler didn't have. similarly, i assumed the sync handler would also be better to use here since it would include sync client data to populate the charts. however when i made this switch, the tests failed inconsistently, so i split the tests up to try and figure out if it was only specific aspects of the tests or if it was the whole ding-dang thing. 😂

as it turns out, the root of the problem lies somewhere in the differences between the sync and clients handlers, because yeah, splitting up the module didn't help much at all. i am reverting this change today and am investigating other options (potentially leaving the sync assertions out of these tests and instead making those assertions in a completely separate module so we can use the sync handler instead of clients). 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i looked at this for quite awhile today and these chart / chart filtering tests seem to be flaky; at least on our sidebranch. check out the video i left in slack for more (github wouldn't let me upload it here because the file size was too big 🙁 )

@Monkeychip and i talked about it while pairing today and assuming these tests are failing on other branches, we'll need to tackle the fixes in a separate PR.

@andaley andaley force-pushed the ui/vault-26096/enable-sync-hvd-clients-page branch from 64ef255 to 2a489c0 Compare May 2, 2024 23:43
@andaley andaley force-pushed the ui/vault-26096/enable-sync-hvd-clients-page branch from 2a489c0 to d603f00 Compare May 2, 2024 23:48
this.server.get('/sys/activation-flags', () => ({
data: { activated: ['secrets-sync'], unactivated: [] },
}));
syncHandler(this.server);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the sync handler sets up all the mocked endpoints that we had before anyway 😀

Comment on lines +283 to +285
.dom(CLIENT_COUNT.statTextValue('Secret sync'))
.doesNotExist('stat is hidden because feature is not activated');
assert.dom(CLIENT_COUNT.statTextValue('Entity')).exists('other stats are still visible');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

we were previously making a doesNotExist assertion on the wrong element. oops! i fixed that throughout this file and added a related assertion to ensure we don't get a falsely passing tests (i.e. if all the chart stats were missing for some reason).

Copy link
Contributor

@hellobontempo hellobontempo May 3, 2024

Choose a reason for hiding this comment

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

Whoops - probably my bad when I last refactored these to clean them up a bit. Great catch!

@@ -26,22 +27,9 @@ module('Integration | Component | clients | Clients::Page::Sync', function (hook
setupMirage(hooks);

hooks.beforeEach(async function () {
clientsHandler(this.server);
Copy link
Contributor Author

@andaley andaley May 3, 2024

Choose a reason for hiding this comment

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

i promise i didn't actually delete this! i just needed to split the tests out into two modules because i needed to use the syncHandler for some tests and no handler for another. mirage doesn't behave well if you try to switch between handlers within the same module, nor does it work when you try to overwrite a handler already in use. therefore it was easiest to split these up.

the whitespace here makes it look like a much bigger change; i recommend using github's "hide whitespace" feature to view this diff more easily.
Screenshot 2024-05-02 at 6 11 57 PM

@andaley andaley force-pushed the ui/vault-26096/enable-sync-hvd-clients-page branch from 04e3328 to 64d5338 Compare May 3, 2024 01:26
@andaley andaley marked this pull request as ready for review May 3, 2024 01:43
@andaley andaley requested a review from a team as a code owner May 3, 2024 01:43
Copy link

github-actions bot commented May 3, 2024

Build Results:
Build failed for these jobs: ui:failure. Please refer to this workflow to learn more: https://github.com/hashicorp/vault/actions/runs/8942185273

@@ -162,6 +164,22 @@ export default class ClientsCountsPageComponent extends Component<Args> {
return activity?.total;
}

get showSecretsSync(): boolean {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

since this value is only needed on one component, we don't need to compute this in the route to add to the model. better off calculating it closer to where we actually use the value, where we already have enough context to compute it. in other words, by calculating the value here we can simply pass it straight into the <NavBar /> which is the only place where it's used. 😀

return {
activity,
activityError,
config,
endTimestamp,
isSecretsSyncActivated,
Copy link
Contributor

Choose a reason for hiding this comment

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

Great idea moving this to the counts.ts component! Much clearer there than passing down from this route model hook 🥇

test('it should hide secrets sync charts', async function (assert) {
assert.dom(CHARTS.chart('Secrets sync usage')).doesNotExist();
test('it should hide secrets sync stats', async function (assert) {
assert.dom(CLIENT_COUNT.statTextValue('Secret sync')).doesNotExist();
Copy link
Contributor

Choose a reason for hiding this comment

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

In case it comes up in another review - this stat was intentionally labelled Secret sync (singular) because it's referring to the client type, not the secrets sync feature.

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

Great work and fantastic test updates ⭐

@andaley andaley merged commit 86430f9 into ui/VAULT-25468/enable-secrets-sync-hvd May 3, 2024
15 of 18 checks passed
@andaley andaley deleted the ui/vault-26096/enable-sync-hvd-clients-page branch May 3, 2024 16:46
Monkeychip added a commit that referenced this pull request May 9, 2024
* Allow Managed clusters to see Secrets Sync Overview and Sidebar nav (#26649)

* update badge text and allow hvd on secrets sync views

* update logic in Secrets Sync overview and cta for hvd.

* spacing

* rearrange based on pr feedback

* fix return on badgeText and cluster nav test

* fix landing cta tests

* update test to reflect new changes

* moved call to feature-flags from application route to the service to match patterns

* add managed test coverage on overview component test and remove premium feature so cta message appplies to both managed and non-managed clusters

* missed service name and unskip admin test

* clean up

* fix tests

* flags test fix

* Rename isManaged and managedNamespaceRoot (#26697)

* renames

* lowercase HVD to match

* missed some

* test failure

* [Secrets Sync] enable access to Sync clients page for HVD clusters (#26713)

* feat: split client counts navbar into separate component

* acceptance/clients/counts/overview-test: remove tests now covered by int tests

* clients counts route: rename isSecretsSyncActivated to showSecretsSync

* sync clients page: show unactivated state unless sync client history or feature is activated

* client counts navbar: show sync tab only if client history or is /able to be/ activated

* clients overview page: only show sync charts if activated

* fix: rename isManaged to isHvd

* acceptance/counts/overview-test: add HVD tests

* acceptance/counts/overview-test: clean up unused cruft

* aceptance/clients/counts/overview-test: ensure we dont get false negatives

* chore: move Clients::Error to Clients::Counts::Error

* chore: calculate showSecretSync in page component instead of route

* chore: add copyright headers

* acceptance/clients/counts/overview-test: stub activated flags to fix test

* [Secrets sync] update sync test selectors (#26824)

* acceptance/clients/counts/overview-test: use imported test selectors

* general-selectors: add missing emptyStateSubtitle property

* acceptance/clients/counts/sync: nest tests in top level module for easier test runs

* Add permissions check to show/hide activate button (#26840)

* add permissions check to flags service and consume in overview template

* add back missing refresh

* fix test failures

* add test coverage

* clean up

* address flaky test

* grr

* address test failures

* add changelog

* try to fix test failure only on gh

* fix fetch to match previous implementation of feature-flags

* fix failing test

* update comment

---------

Co-authored-by: Noelle Daley <[email protected]>
Co-authored-by: [email protected] <[email protected]>
michael-diggin pushed a commit to michael-diggin/vault that referenced this pull request Jan 20, 2025
* Allow Managed clusters to see Secrets Sync Overview and Sidebar nav (hashicorp#26649)

* update badge text and allow hvd on secrets sync views

* update logic in Secrets Sync overview and cta for hvd.

* spacing

* rearrange based on pr feedback

* fix return on badgeText and cluster nav test

* fix landing cta tests

* update test to reflect new changes

* moved call to feature-flags from application route to the service to match patterns

* add managed test coverage on overview component test and remove premium feature so cta message appplies to both managed and non-managed clusters

* missed service name and unskip admin test

* clean up

* fix tests

* flags test fix

* Rename isManaged and managedNamespaceRoot (hashicorp#26697)

* renames

* lowercase HVD to match

* missed some

* test failure

* [Secrets Sync] enable access to Sync clients page for HVD clusters (hashicorp#26713)

* feat: split client counts navbar into separate component

* acceptance/clients/counts/overview-test: remove tests now covered by int tests

* clients counts route: rename isSecretsSyncActivated to showSecretsSync

* sync clients page: show unactivated state unless sync client history or feature is activated

* client counts navbar: show sync tab only if client history or is /able to be/ activated

* clients overview page: only show sync charts if activated

* fix: rename isManaged to isHvd

* acceptance/counts/overview-test: add HVD tests

* acceptance/counts/overview-test: clean up unused cruft

* aceptance/clients/counts/overview-test: ensure we dont get false negatives

* chore: move Clients::Error to Clients::Counts::Error

* chore: calculate showSecretSync in page component instead of route

* chore: add copyright headers

* acceptance/clients/counts/overview-test: stub activated flags to fix test

* [Secrets sync] update sync test selectors (hashicorp#26824)

* acceptance/clients/counts/overview-test: use imported test selectors

* general-selectors: add missing emptyStateSubtitle property

* acceptance/clients/counts/sync: nest tests in top level module for easier test runs

* Add permissions check to show/hide activate button (hashicorp#26840)

* add permissions check to flags service and consume in overview template

* add back missing refresh

* fix test failures

* add test coverage

* clean up

* address flaky test

* grr

* address test failures

* add changelog

* try to fix test failure only on gh

* fix fetch to match previous implementation of feature-flags

* fix failing test

* update comment

---------

Co-authored-by: Noelle Daley <[email protected]>
Co-authored-by: [email protected] <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants