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

Autoscaler Tweaks & Fixes #196

Merged
merged 2 commits into from
Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Observable } from 'rxjs';
import { filter, map, publishReplay, refCount, startWith } from 'rxjs/operators';

import { EntityServiceFactory } from '../../../../core/src/core/entity-service-factory.service';
import { APIResource, EntityInfo } from '../../../../store/src/types/api.types';
import { GetAppAutoscalerInfoAction } from '../../store/app-autoscaler.actions';
import { AutoscalerInfo } from '../../store/app-autoscaler.types';

export const fetchAutoscalerInfo = (
endpointGuid: string,
esf: EntityServiceFactory): Observable<EntityInfo<APIResource<AutoscalerInfo>>> => {
const action = new GetAppAutoscalerInfoAction(endpointGuid);
const entityService = esf.create<APIResource<AutoscalerInfo>>(action.entityKey, action.entity, endpointGuid, action);
return entityService.entityObs$.pipe(
filter(entityInfo =>
!!entityInfo &&
!!entityInfo.entityRequestInfo &&
!entityInfo.entityRequestInfo.fetching
),
publishReplay(1),
refCount()
);
};

export const isAutoscalerEnabled = (endpointGuid: string, esf: EntityServiceFactory): Observable<boolean> => {
return fetchAutoscalerInfo(endpointGuid, esf).pipe(
map(entityInfo => !entityInfo.entityRequestInfo.error),
startWith(false)
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,28 @@ export class AutoscalerConstants {
}

export const PolicyAlert = {
alertInvalidPolicyMinimumRange: 'The Minimum Instance Count must be a integer less than the Maximum Instance Count.',
alertInvalidPolicyMaximumRange: 'The Maximum Instance Count must be a integer greater than the Minimum Instance Count.',
alertInvalidPolicyMinimumRange: 'The Minimum Instance Count must be an integer less than the Maximum Instance Count.',
alertInvalidPolicyMaximumRange: 'The Maximum Instance Count must be an integer greater than the Minimum Instance Count.',
alertInvalidPolicyInitialMaximumRange:
'The Initial Minimum Instance Count must be a integer in the range of Minimum Instance Count to Maximum Instance Count.',
'The Initial Minimum Instance Count must be an integer between Minimum Instance Count and Maximum Instance Count.',
alertInvalidPolicyTriggerUpperThresholdRange: 'The Upper Threshold value must be an integer greater than the Lower Threshold value.',
alertInvalidPolicyTriggerLowerThresholdRange: 'The Lower Threshold value must be an integer in the range of 1 to (Upper Threshold-1).',
alertInvalidPolicyTriggerLowerThresholdRange: 'The Lower Threshold value must be an integer between 1 and (Upper Threshold-1).',
alertInvalidPolicyTriggerThreshold100: 'The Lower/Upper Threshold value of memoryutil must be an integer below or equal to 100.',
alertInvalidPolicyTriggerStepPercentageRange: 'The Instance Step Up/Down percentage must be a integer greater than 1.',
alertInvalidPolicyTriggerStepRange: 'The Instance Step Up/Down value must be a integer in the range of 1 to (Maximum Instance-1).',
alertInvalidPolicyTriggerStepPercentageRange: 'The Instance Step Up/Down percentage must be an integer greater than 1.',
alertInvalidPolicyTriggerStepRange: 'The Instance Step Up/Down value must be an integer between 1 and (Maximum Instance-1).',
alertInvalidPolicyTriggerBreachDurationRange:
`The breach duration value must be an integer in the range of ${AutoscalerConstants.PolicyDefaultSetting.breach_duration_secs_min} to
`The breach duration value must be an integer between ${AutoscalerConstants.PolicyDefaultSetting.breach_duration_secs_min} and
${AutoscalerConstants.PolicyDefaultSetting.breach_duration_secs_max} seconds.`,
alertInvalidPolicyTriggerCooldownRange:
`The cooldown period value must be an integer in the range of ${AutoscalerConstants.PolicyDefaultSetting.cool_down_secs_min} to
`The cooldown period value must be an integer between ${AutoscalerConstants.PolicyDefaultSetting.cool_down_secs_min} and
${AutoscalerConstants.PolicyDefaultSetting.breach_duration_secs_max} seconds.`,
alertInvalidPolicyScheduleDateBeforeNow: 'Start/End date should be after or equal to current date.',
alertInvalidPolicyScheduleDateBeforeNow: 'Start/End date should be after or equal to the current date.',
alertInvalidPolicyScheduleEndDateBeforeStartDate: 'Start date must be earlier than the end date.',
alertInvalidPolicyScheduleEndTimeBeforeStartTime: 'Start time must be earlier than the end time.',
alertInvalidPolicyScheduleRepeatOn: 'Please select at least one "Repeat On" day.',
alertInvalidPolicyScheduleEndDateTimeBeforeStartDateTime: 'Start date and time must be earlier than the end date and time.',
alertInvalidPolicyScheduleStartDateTimeBeforeNow: 'Start date and time must be after or equal to current date time.',
alertInvalidPolicyScheduleEndDateTimeBeforeNow: 'End date and time must be after or equal the current date and time.',
alertInvalidPolicyScheduleStartDateTimeBeforeNow: 'Start date and time must be after or equal to the current date time.',
alertInvalidPolicyScheduleEndDateTimeBeforeNow: 'End date and time must be after or equal to the current date and time.',
alertInvalidPolicyScheduleRecurringConflict: 'Recurring schedule configuration conflict occurs.',
alertInvalidPolicyScheduleSpecificConflict: 'Specific date configuration conflict occurs.',
alertInvalidPolicyTriggerScheduleEmpty: 'At least one Scaling Rule or Schedule should be defined.',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,52 +1,29 @@
<app-page-sub-nav>
<ng-container *ngIf="appAutoscalerPolicy$ | async as policy; else noPolicy">
<button mat-button name="edit" (click)="updatePolicyPage()" class="nav-button-with-text">
<span class="nav-button-with-text__span">
<mat-icon class="nav-button-with-text__icon">edit</mat-icon> Edit Policy
</span>
</button>
<button mat-button name="delete" (click)="disableAutoscaler()" class="nav-button-with-text">
<span class="nav-button-with-text__span">
<mat-icon class="nav-button-with-text__icon">delete</mat-icon> Delete Policy
</span>
</button>
</ng-container>
<ng-template #noPolicy>
<button mat-button name="add" (click)="updatePolicyPage(true)" class="nav-button-with-text">
<span class="nav-button-with-text__span">
<mat-icon class="nav-button-with-text__icon">add</mat-icon> Create Policy
</span>
</button>
</ng-template>
</app-page-sub-nav>
<div class="autoscaler-tab">
<app-tile-grid class="app-autoscaler-tile-grid-100">
<app-tile-group *ngIf="!(appAutoscalerPolicy$ | async)">
<app-tile>
<mat-card>
<mat-card-header>
<mat-card-title>Status</mat-card-title>
</mat-card-header>
<mat-card-content>
<div class="app-metadata">
<div class="app-metadata__two-cols">
<mat-slide-toggle checked="false" (click)="updatePolicyPage()">Disabled</mat-slide-toggle>
</div>
</div>
</mat-card-content>
</mat-card>
</app-tile>
<app-tile>
<app-card-app-instances></app-card-app-instances>
</app-tile>
</app-tile-group>
<app-tile-group *ngIf="appAutoscalerPolicy$ | async as policy">

<app-tile>
<mat-card>
<mat-card-header>
<mat-card-title>Status</mat-card-title>
</mat-card-header>
<mat-card-content>
<div class="app-metadata">
<div class="app-metadata__two-cols">
<mat-slide-toggle *ngIf="policy.enabled && detachConfirmOk == 0" checked="true"
(click)="disableAutoscaler()">Enabled</mat-slide-toggle>
<mat-slide-toggle *ngIf="policy.enabled && detachConfirmOk == 1" checked="true"
(click)="disableAutoscaler()">Enabled</mat-slide-toggle>
<mat-slide-toggle *ngIf="policy.enabled && detachConfirmOk == 2" checked="false"
(click)="updatePolicyPage()">Disabled</mat-slide-toggle>
<mat-slide-toggle *ngIf="!policy.enabled" checked="false" (click)="updatePolicyPage()">Disabled
</mat-slide-toggle>
</div>
</div>
</mat-card-content>
</mat-card>
</app-tile>
<app-tile *ngIf="!policy.enabled">
<app-card-app-instances></app-card-app-instances>
</app-tile>
<app-tile *ngIf="policy.enabled">
<app-card-autoscaler-default [onUpdate]="updatePolicyPage"></app-card-autoscaler-default>
<app-card-autoscaler-default></app-card-autoscaler-default>
</app-tile>
<app-tile *ngIf="policy.enabled" class="autoscaler-tab__latest-metrics">
<app-card-app-usage *ngIf="policy.scaling_rules.length == 0"></app-card-app-usage>
Expand All @@ -59,7 +36,6 @@
<div class="app-metadata__two-cols" *ngFor="let metricName of appAutoscalerAppMetricNames$ | async">
<app-metadata-item *ngIf="appAutoscalerAppMetrics[metricName] | async as metricData"
label={{metricName}}>
<!-- {{ metricData[0].entity.latest.length > 0 && metricData[0].entity.latest[0].value ? metricData[0].entity.latest[0].value + " " + metricData[0].entity.unit : "NaN"}} -->
<ngx-charts-gauge [view]="[80, 80]" [margin]="[5, 5, 0, 5]"
[customColors]="[metricData[0].entity.latest.colorTarget[0]]"
[results]="[metricData[0].entity.latest.target[0]]" [animations]="true" [textValue]=""
Expand Down Expand Up @@ -113,11 +89,6 @@
</div>
</div>
</mat-card-content>
<mat-card-actions class="autoscaler-tab__actions">
<button (click)="updatePolicyPage()" mat-icon-button>
<mat-icon>edit</mat-icon>
</button>
</mat-card-actions>
</mat-card>
</app-tile>
<app-tile>
Expand Down Expand Up @@ -204,17 +175,15 @@
No recurring schedule.</div>
</div>
</mat-card-content>
<mat-card-actions class="autoscaler-tab__actions">
<button (click)="updatePolicyPage()" mat-icon-button>
<mat-icon>edit</mat-icon>
</button>
</mat-card-actions>
</mat-card>
</app-tile>
</app-tile-group>
</div>
<app-tile-group class="autoscaler-tile-events" *ngIf="appAutoscalerScalingHistory$ | async as scalingHistory">
<app-tile>
<app-tile-group class="autoscaler-tile-events" *ngIf="showAutoscalerHistory$ | async">
<span *ngIf="!(appAutoscalerPolicy$ | async)" class="autoscaler-tile-events__no-policy">
{{noPolicyMessageFirstLine}}. {{noPolicyMessageSecondLine.text}}
</span>
<app-tile *ngIf="appAutoscalerScalingHistory$ | async as scalingHistory">
<mat-card>
<mat-card-header class="autoscaler-tile-events__header">
<mat-card-title>Latest Events </mat-card-title>
Expand Down Expand Up @@ -259,5 +228,8 @@
</mat-card>
</app-tile>
</app-tile-group>
<app-no-content-message *ngIf="showNoPolicyMessage$ | async" [icon]="'meter'" [iconFont]="'stratos-icons'"
[firstLine]="noPolicyMessageFirstLine" [secondLine]="noPolicyMessageSecondLine">
</app-no-content-message>
</app-tile-grid>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,17 @@
}

&__latest-metrics {
flex: 2;
min-height: 200px;
}
}


.app-metadata {
display: flex;
flex-direction: row;
&__two-cols {
flex: 1;
padding-right: 40px;
app-metadata-item:first-child {
margin-top: 0;
}
Expand All @@ -52,6 +54,15 @@ table {
}

.autoscaler-tile-events {
flex-direction: column;

&__no-policy {
align-items: center;
display: flex;
margin-bottom: 12px;
padding: 14px;
}

&__header {
display: flex;
flex: 1;
Expand All @@ -69,3 +80,16 @@ table {
}
}
}
.nav-button-with-text {
margin: 0 10px 0 0;
padding: 0 5px;

&__span {
align-items: center;
display: flex;
}

&__icon {
margin-right: 5px;
}
}
Loading