Commit 73a404d8 authored by Michal Nowikowski's avatar Michal Nowikowski

[#324] addressed review issues, fixed merging

parent fb970e73
......@@ -6,6 +6,7 @@ import (
"net"
"reflect"
"strconv"
"strings"
"time"
"github.com/pkg/errors"
......@@ -542,7 +543,7 @@ func (agents *connectedAgentsData) updateErrorStatsAndRaiseEvents(agent *Agent,
"kea": caURL,
}).Warnf("communication failed: %+v", fdReq.KeaRequests)
dmn := daemonsMap["ca"]
agents.EventCenter.AddErrorEvent("communication with {daemon} failed", caErrorStr, &dmn)
agents.EventCenter.AddErrorEvent("communication with {daemon} failed", strings.TrimSpace(caErrorStr), &dmn)
}
} else {
keaCommStats.CurrentErrorsCA = 0
......
......@@ -329,20 +329,13 @@ func GetAppState(ctx context.Context, agents agentcomm.ConnectedAgents, dbApp *d
daemonsErrors := map[string]string{}
allDaemons, dhcpDaemons, err := getStateFromCA(ctx2, agents, dbApp, daemonsMap, daemonsErrors)
if err != nil {
log.Warnf("problem with getting state from kea CA: %s", err)
errStr, ok := daemonsErrors["ca"]
if !ok {
errStr = fmt.Sprintf("%s", err)
}
eventCenter.AddErrorEvent("cannot get state from Kea CA from {app} on {machine}", errStr, dbApp.Machine, dbApp)
log.Warnf("problem with getting state from Kea CA: %s", err)
}
// if no problems then now get state from the rest of Kea daemons
err = getStateFromDaemons(ctx2, agents, dbApp, daemonsMap, allDaemons, dhcpDaemons, daemonsErrors)
if err != nil {
log.Warnf("problem with getting state from kea daemons: %s", err)
errStr := fmt.Sprintf("%s", err)
eventCenter.AddErrorEvent("cannot get state from Kea CA from {app} on {machine}", errStr, dbApp.Machine, dbApp)
log.Warnf("problem with getting state from Kea daemons: %s", err)
}
newActive, overrideDaemons, newDaemons, events := findChangesAndRaiseEvents(dbApp, daemonsMap, daemonsErrors)
......@@ -374,12 +367,12 @@ func findChangesAndRaiseEvents(dbApp *dbmodel.App, daemonsMap map[string]*dbmode
if !ok {
errStr = ""
}
ev := eventcenter.CreateEvent(dbmodel.EvError, "{daemon} is down", errStr, dbApp.Machine, dbApp, oldDmn)
ev := eventcenter.CreateEvent(dbmodel.EvError, "{daemon} is unreachable", errStr, dbApp.Machine, dbApp, oldDmn)
events = append(events, ev)
}
}
if dbApp.Active {
ev := eventcenter.CreateEvent(dbmodel.EvError, "{app} is down", dbApp.Machine, dbApp)
ev := eventcenter.CreateEvent(dbmodel.EvError, "{app} is unreachable", dbApp.Machine, dbApp)
events = append(events, ev)
}
return false, false, nil, events
......@@ -405,9 +398,9 @@ func findChangesAndRaiseEvents(dbApp *dbmodel.App, daemonsMap map[string]*dbmode
lvl := dbmodel.EvWarning
text := "{daemon} is "
if dmn.Active && !oldDmn.Active {
text += "up"
text += "reachable now"
} else if !dmn.Active && oldDmn.Active {
text += "down"
text += "unreachable"
lvl = dbmodel.EvError
}
errStr, ok := daemonsErrors[oldDmn.Name]
......
......@@ -8,6 +8,7 @@ import (
"github.com/stretchr/testify/require"
agentcommtest "isc.org/stork/server/agentcomm/test"
dbmodel "isc.org/stork/server/database/model"
dbtest "isc.org/stork/server/database/test"
"isc.org/stork/server/gen/restapi/operations/services"
......@@ -55,7 +56,7 @@ func TestGetLogTail(t *testing.T) {
require.NotZero(t, a.Daemons[0].LogTargets[0].ID)
settings := RestAPISettings{}
fa := storktest.NewFakeAgents(nil, nil)
fa := agentcommtest.NewFakeAgents(nil, nil)
fec := &storktest.FakeEventCenter{}
rapi, err := NewRestAPI(&settings, dbSettings, db, fa, fec)
require.NoError(t, err)
......@@ -128,7 +129,7 @@ func TestLogTailBadParams(t *testing.T) {
}
settings := RestAPISettings{}
fa := storktest.NewFakeAgents(nil, nil)
fa := agentcommtest.NewFakeAgents(nil, nil)
fec := &storktest.FakeEventCenter{}
rapi, err := NewRestAPI(&settings, dbSettings, db, fa, fec)
require.NoError(t, err)
......
<table class="events-table">
<ng-container *ngFor="let ev of events.items; index as i">
<tr [class.odd-row]="i % 2 === 0">
<td *ngIf="ev.level === undefined || ev.level === 0" style="font-size: 1.5em; color: #9db2d3;">
<td *ngIf="ev.level === undefined || ev.level === 0" style="font-size: 1.5em; color: #9db2d3; width: 1em;">
<i class="pi pi-info-circle"></i>
</td>
<td *ngIf="ev.level === 1" style="font-size: 1.5em; color: orange;">
<td *ngIf="ev.level === 1" style="font-size: 1.5em; color: orange; width: 1em;">
<i class="pi pi-exclamation-triangle"></i>
</td>
<td *ngIf="ev.level === 2" style="font-size: 1.5em; color: red;">
<td *ngIf="ev.level === 2" style="font-size: 1.5em; color: red; width: 1em;">
<i class="pi pi-exclamation-circle"></i>
</td>
<td style="width: 6em;">{{ ev.createdAt | localtime }}</td>
......
......@@ -78,10 +78,11 @@
</div>
<div class="p-grid" style="padding: 12px;">
<!-- box with error message if there is communication issue or other problem with daemon -->
<div *ngIf="daemon.statusErred" class="p-col-4">
<p-message severity="error" text="{{ daemonStatusErrorText(daemon) }}"></p-message>
</div>
<div *ngIf="daemon.statusErred" class="p-col-8"></div>
<div *ngIf="daemon.statusErred" class="p-col-8"><!-- fill horizontally all 12 cols --></div>
<!-- warning about not-active and not-monitored -->
<div *ngIf="!daemon.active" class="p-col-4">
......@@ -102,87 +103,85 @@
>
</p-message>
</div>
<!-- fill horizontally all 12 cols -->
<div *ngIf="!daemon.active" class="p-col-8"></div>
<div *ngIf="!daemon.active" class="p-col-8"><!-- fill horizontally all 12 cols --></div>
<!-- Overview -->
<div class="p-col-4" [ngClass]="{ disabled: !daemon.active }">
<h3 style="margin-top: 2px;">Overview</h3>
<table style="width: 100%;">
<tr>
<td style="width: 10rem;">Version</td>
<td>{{ daemon.version }}</td>
</tr>
<tr>
<td style="width: 10rem; vertical-align: top;">Version Ext</td>
<td [innerHTML]="daemon.extendedVersion"></td>
</tr>
<tr>
<td style="with: 10rem; vertical-align: top;">Hooks</td>
<td>
<div *ngFor="let hook of daemon.hooks">
{{ hook }}
</div>
<div *ngIf="daemon.hooks.length === 0" style="color: #aaa;">
no hooks
</div>
</td>
</tr>
<tr>
<td style="width: 10rem; vertical-align: top;">Uptime</td>
<td>{{ showDuration(daemon.uptime) }}</td>
</tr>
<tr>
<td style="width: 10rem; vertical-align: top;">Last Reloaded At</td>
<td>{{ daemon.reloadedAt | localtime }}</td>
</tr>
</table>
</div>
<div *ngIf="daemon.active" class="p-col-7">
<h4 style="margin-top: 2px;">Loggers</h4>
<p-table [value]="daemon.logTargets">
<ng-template pTemplate="header">
<div class="p-col-7">
<!-- Overview -->
<div style="margin-bottom: 14px;" [ngClass]="{ disabled: !daemon.active }">
<h3 style="margin-top: 2px;">Overview</h3>
<table style="width: 100%;">
<tr>
<td style="width: 10rem;">Version</td>
<td>{{ daemon.version }}</td>
</tr>
<tr>
<th style="width: 10rem;">Logger</th>
<th style="width: 7rem;">Severity</th>
<th style="width: 30rem;">Output Location</th>
<td style="width: 10rem; vertical-align: top;">Version Ext</td>
<td [innerHTML]="daemon.extendedVersion"></td>
</tr>
</ng-template>
<ng-template pTemplate="body" let-logTarget>
<tr>
<td>{{ logTarget.name }}</td>
<td align="center">{{ logTarget.severity }}</td>
<td style="with: 10rem; vertical-align: top;">Hooks</td>
<td>
<i *ngIf="!logTargetViewable(logTarget.output)">{{ logTarget.output }}</i>
<a
*ngIf="logTargetViewable(logTarget.output)"
routerLink="/logs/{{ logTarget.id }}"
><i>{{ logTarget.output }}</i></a
>
<div *ngFor="let hook of daemon.hooks">
{{ hook }}
</div>
<div *ngIf="daemon.hooks.length === 0" style="color: #aaa;">
no hooks
</div>
</td>
</tr>
</ng-template>
<ng-template pTemplate="emptymessage" let-columns>
<tr>
<td [attr.colspan]="3">
No loggers found
</td>
<td style="width: 10rem; vertical-align: top;">Uptime</td>
<td>{{ showDuration(daemon.uptime) }}</td>
</tr>
</ng-template>
</p-table>
</div>
<tr>
<td style="width: 10rem; vertical-align: top;">Last Reloaded At</td>
<td>{{ daemon.reloadedAt | localtime }}</td>
</tr>
</table>
</div>
<!-- High Availability -->
<div
*ngIf="daemon.name === 'dhcp4' || daemon.name === 'dhcp6'"
class="p-col-12"
[ngClass]="{ disabled: !daemon.active }"
>
<app-ha-status [appId]="appTab.app.id" [daemonName]="daemon.name"></app-ha-status>
<!-- High Availability -->
<div
*ngIf="daemon.name === 'dhcp4' || daemon.name === 'dhcp6'"
style="margin-bottom: 18px;"
[ngClass]="{ disabled: !daemon.active }"
>
<app-ha-status [appId]="appTab.app.id" [daemonName]="daemon.name"></app-ha-status>
</div>
<!-- Loggers -->
<div class="" [ngClass]="{ disabled: !daemon.active }">
<h3 style="margin-top: 2px;">Loggers</h3>
<p-table [value]="daemon.logTargets">
<ng-template pTemplate="header">
<tr>
<th style="width: 10rem;">Logger</th>
<th style="width: 5rem;">Severity</th>
<th>Output Location</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-logTarget>
<tr>
<td>{{ logTarget.name }}</td>
<td align="center">{{ logTarget.severity }}</td>
<td>
<i>{{ logTarget.output }}</i>
</td>
</tr>
</ng-template>
<ng-template pTemplate="emptymessage" let-columns>
<tr>
<td [attr.colspan]="3">
No loggers found
</td>
</tr>
</ng-template>
</p-table>
</div>
</div>
<!-- Events -->
<div class="p-col-4">
<div class="p-col-5">
<h3 style="margin-top: 2px;">Events</h3>
<app-events-panel #eventsTable [filter]="{ daemon: daemon.id }"></app-events-panel>
</div>
......
......@@ -192,7 +192,6 @@ export class KeaAppTabComponent implements OnInit {
}
changeMonitored(daemon) {
console.info(daemon)
const dmn = { monitored: !daemon.monitored }
this.servicesApi.updateDaemon(daemon.id, dmn).subscribe(
(data) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment