forked from grafana/grafana
-
Notifications
You must be signed in to change notification settings - Fork 8
PMM-14325 HA info inventory #862
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
Open
matejkubinec
wants to merge
4
commits into
v3
Choose a base branch
from
PMM-14325-ha-info-inventory
base: v3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
838ae42
PMM-14325 Add information about HA in inventory
matejkubinec 4fbea90
PMM-14325 Disable notifications and add cancel token
matejkubinec df3bbcd
PMM-14325 Add support for boolean field
matejkubinec def1b43
Merge branch 'v3' into PMM-14325-ha-info-inventory
matejkubinec File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { Node } from 'app/percona/inventory/Inventory.types'; | ||
| import { NodeRole, NodeStatus } from 'app/percona/shared/services/highAvailability/HighAvailability.types'; | ||
|
|
||
| export interface InventoryNode extends Node { | ||
| haRole?: NodeRole; | ||
| haStatus?: NodeStatus; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,29 @@ | ||
| import { HighAvailabilityNode, NodeRole } from 'app/percona/shared/services/highAvailability/HighAvailability.types'; | ||
| import { Node } from 'app/percona/inventory/Inventory.types'; | ||
| import { InventoryNode } from './Nodes.types'; | ||
|
|
||
| export const getServiceLink = (serviceId: string) => { | ||
| return `/inventory/services?search-text-input=${serviceId}&search-select=serviceId`; | ||
| }; | ||
|
|
||
| export const mapNodesToInventoryNodes = (nodes: Node[], haNodes: HighAvailabilityNode[]): InventoryNode[] => | ||
| nodes.map((node) => { | ||
| const haNode = haNodes.find((haNode) => haNode.node_name === node.nodeName); | ||
|
|
||
| return { | ||
| ...node, | ||
| haRole: haNode?.role, | ||
| haStatus: haNode?.status, | ||
| }; | ||
| }); | ||
|
|
||
| export const getHaRoleBadgeText = (role: NodeRole) => { | ||
| switch (role) { | ||
| case NodeRole.leader: | ||
| return 'Leader'; | ||
| case NodeRole.follower: | ||
| return 'Follower'; | ||
| default: | ||
| return 'Unspecified'; | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
public/app/percona/shared/core/reducers/highAvailability/highAvailability.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,57 @@ | ||||||||
| import { CancelToken } from 'axios'; | ||||||||
| import { createAsyncThunk, createSlice } from '@reduxjs/toolkit'; | ||||||||
|
|
||||||||
| import { HighAvailabilityState } from './highAvailability.types'; | ||||||||
|
|
||||||||
| import { HighAvailabilityService } from 'app/percona/shared/services/highAvailability/HighAvailability.service'; | ||||||||
| import { | ||||||||
| HighAvailabilityNodesResponse, | ||||||||
| HighAvailabilityStatusResponse, | ||||||||
| } from 'app/percona/shared/services/highAvailability/HighAvailability.types'; | ||||||||
|
|
||||||||
| const initialState: HighAvailabilityState = { | ||||||||
| isLoading: false, | ||||||||
| isEnabled: false, | ||||||||
| nodes: [], | ||||||||
| }; | ||||||||
|
|
||||||||
| const highAvailabilitySlice = createSlice({ | ||||||||
| name: 'highAvailability', | ||||||||
| initialState, | ||||||||
| reducers: {}, | ||||||||
| extraReducers: (builder) => { | ||||||||
| builder.addCase(fetchHighAvailabilityStatus.pending, (state) => ({ | ||||||||
| ...state, | ||||||||
| isLoading: true, | ||||||||
| })); | ||||||||
| builder.addCase(fetchHighAvailabilityStatus.rejected, (state) => ({ | ||||||||
| ...state, | ||||||||
| isEnabled: false, | ||||||||
| isLoading: false, | ||||||||
| })); | ||||||||
| builder.addCase(fetchHighAvailabilityStatus.fulfilled, (state, action) => ({ | ||||||||
| ...state, | ||||||||
| isEnabled: action.payload.status === 'Enabled', | ||||||||
| })); | ||||||||
| builder.addCase(fetchHighAvailabilityNodes.fulfilled, (state, action) => ({ | ||||||||
| ...state, | ||||||||
| nodes: action.payload.nodes, | ||||||||
|
||||||||
| nodes: action.payload.nodes, | |
| nodes: action.payload.nodes, | |
| isLoading: false, |
7 changes: 7 additions & 0 deletions
7
public/app/percona/shared/core/reducers/highAvailability/highAvailability.types.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| import { HighAvailabilityNode } from 'app/percona/shared/services/highAvailability/HighAvailability.types'; | ||
|
|
||
| export interface HighAvailabilityState { | ||
| isLoading: boolean; | ||
| isEnabled: boolean; | ||
| nodes: HighAvailabilityNode[]; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
public/app/percona/shared/services/highAvailability/HighAvailability.service.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { CancelToken } from 'axios'; | ||
|
|
||
| import { api } from 'app/percona/shared/helpers/api'; | ||
|
|
||
| import { HighAvailabilityNodesResponse, HighAvailabilityStatusResponse } from './HighAvailability.types'; | ||
|
|
||
| const BASE_URL = '/v1/ha'; | ||
|
|
||
| export const HighAvailabilityService = { | ||
| getStatus: async (token?: CancelToken) => { | ||
| return api.get<HighAvailabilityStatusResponse, void>(`${BASE_URL}/status`, true, { cancelToken: token }); | ||
| }, | ||
| getNodes: async (token?: CancelToken): Promise<HighAvailabilityNodesResponse> => { | ||
| return api.get<HighAvailabilityNodesResponse, void>(`${BASE_URL}/nodes`, true, { cancelToken: token }); | ||
| }, | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The header 'Node Filter' is not user-facing since this column is hidden, but it's unclear what filtering is being applied. Consider renaming to something more descriptive like 'PMM Server Node Filter' to better indicate its purpose.