Skip to content

Commit

Permalink
Add Tenant Health Details (#780)
Browse files Browse the repository at this point in the history
* Add Tenant Health Details

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Colors

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
  • Loading branch information
dvaldivia committed Jun 2, 2021
1 parent 8ca6401 commit f183604
Show file tree
Hide file tree
Showing 10 changed files with 318 additions and 7 deletions.
25 changes: 25 additions & 0 deletions models/tenant.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions models/tenant_list.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions models/tenant_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 42 additions & 2 deletions portal-ui/src/screens/Console/Tenants/ListTenants/ListTenants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.

import React, { useEffect, useState, Fragment } from "react";
import React, { Fragment, useEffect, useState } from "react";
import { connect } from "react-redux";
import Grid from "@material-ui/core/Grid";
import TextField from "@material-ui/core/TextField";
Expand Down Expand Up @@ -93,6 +93,18 @@ const styles = (theme: Theme) =>
display: "none",
},
},
redState: {
color: theme.palette.error.main,
},
yellowState: {
color: theme.palette.warning.main,
},
greenState: {
color: theme.palette.success.main,
},
greyState: {
color: "grey",
},
});

const ListTenants = ({
Expand Down Expand Up @@ -203,6 +215,16 @@ const ListTenants = ({
setCurrentPanel(1);
};

const healthStatusToClass = (health_status: string) => {
return health_status == "red"
? classes.redState
: health_status == "yellow"
? classes.yellowState
: health_status == "green"
? classes.greenState
: classes.greyState;
};

return (
<Fragment>
{deleteOpen && (
Expand Down Expand Up @@ -271,7 +293,25 @@ const ListTenants = ({
<TableWrapper
itemActions={tableActions}
columns={[
{ label: "Name", elementKey: "name" },
{
label: "Name",
elementKey: "name",
renderFullObject: true,
renderFunction: (t) => {
return (
<React.Fragment>
<span
className={healthStatusToClass(
t.health_status
)}
>
</span>{" "}
{t.name}
</React.Fragment>
);
},
},
{ label: "Namespace", elementKey: "namespace" },
{ label: "Capacity", elementKey: "capacity" },
{ label: "# of Pools", elementKey: "pool_count" },
Expand Down
10 changes: 10 additions & 0 deletions portal-ui/src/screens/Console/Tenants/ListTenants/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@ export interface IEndpoints {
console: string;
}

export interface ITenantStatus {
write_quorum: string;
drives_online: string;
drives_offline: string;
drives_healing: string;
health_status: string;
}

export interface ITenant {
total_size: number;
name: string;
Expand All @@ -77,6 +85,8 @@ export interface ITenant {
encryptionEnabled: boolean;
idpAdEnabled: boolean;
idpOicEnabled: boolean;
health_status: string;
status?: ITenantStatus;
// computed
capacity: string;
subnet_license: LicenseInfo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,22 @@ const styles = (theme: Theme) =>
textDecoration: "none",
color: "black",
},
redState: {
color: theme.palette.error.main,
},
yellowState: {
color: theme.palette.warning.main,
},
greenState: {
color: theme.palette.success.main,
},
greyState: {
color: "grey",
},
healthCol: {
fontWeight: "bold",
paddingRight: "10px",
},
...modalBasic,
...actionsTray,
...buttonsStyles,
Expand Down Expand Up @@ -345,6 +361,16 @@ const TenantDetails = ({
loadInfo();
};

const healthStatusToClass = (health_status: string) => {
return health_status == "red"
? classes.redState
: health_status == "yellow"
? classes.yellowState
: health_status == "green"
? classes.greenState
: classes.greyState;
};

return (
<React.Fragment>
{addPoolOpen && tenant !== null && (
Expand Down Expand Up @@ -524,6 +550,44 @@ const TenantDetails = ({
error={usageError}
loading={loadingUsage}
/>
<h4>
{tenant && tenant.status && (
<span
className={healthStatusToClass(
tenant.status.health_status
)}
>
⬤&nbsp;
</span>
)}
Health
</h4>
<table>
<tr>
<td className={classes.healthCol}>Drives Online</td>
<td>
{tenant?.status?.drives_online
? tenant?.status?.drives_online
: 0}
</td>
</tr>
<tr>
<td className={classes.healthCol}>Drives Offline</td>
<td>
{tenant?.status?.drives_offline
? tenant?.status?.drives_offline
: 0}
</td>
</tr>
<tr>
<td className={classes.healthCol}>Write Quorum</td>
<td>
{tenant?.status?.write_quorum
? tenant?.status?.write_quorum
: 0}
</td>
</tr>
</table>
</Grid>
</Grid>
</Paper>
Expand Down
16 changes: 11 additions & 5 deletions portal-ui/src/theme/newtheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ const newTheme = createMuiTheme({
dark: "#01262E",
contrastText: "#000",
},
error: {
light: "#e03a48",
main: "#dc1f2e",
contrastText: "#ffffff",
},
grey: {
100: "#F7F7F7",
200: "#D8DDDE",
Expand All @@ -33,6 +28,17 @@ const newTheme = createMuiTheme({
background: {
default: "#F4F4F4",
},
success: {
main: "#32c787",
},
warning: {
main: "#ffb300",
},
error: {
light: "#e03a48",
main: "#dc1f2e",
contrastText: "#ffffff",
},
},
typography: {
fontFamily: ["Lato", "sans-serif"].join(","),
Expand Down
10 changes: 10 additions & 0 deletions restapi/admin_tenants.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,15 @@ func getTenantInfoResponse(session *models.Principal, params admin_api.TenantInf
}
}

// attach status information
info.Status = &models.TenantStatus{
HealthStatus: string(minTenant.Status.HealthStatus),
DrivesHealing: minTenant.Status.DrivesHealing,
DrivesOffline: minTenant.Status.DrivesOffline,
DrivesOnline: minTenant.Status.DrivesOnline,
WriteQuorum: minTenant.Status.WriteQuorum,
}

// get tenant service
minTenant.EnsureDefaults()
//minio service
Expand Down Expand Up @@ -533,6 +542,7 @@ func listTenants(ctx context.Context, operatorClient OperatorClientI, namespace
CurrentState: tenant.Status.CurrentState,
Namespace: tenant.ObjectMeta.Namespace,
TotalSize: totalSize,
HealthStatus: string(tenant.Status.HealthStatus),
})
}

Expand Down

0 comments on commit f183604

Please sign in to comment.