feat(jobs): show Nexus registry reachability next to the Docker daemon

This commit is contained in:
2026-07-24 14:05:37 +02:00
parent 9d24c0a9bb
commit f0caacd696
11 changed files with 326 additions and 42 deletions
@@ -135,6 +135,12 @@ class DockerHealth(BaseModel):
detail: str
class RegistryHealth(BaseModel):
reachable: bool
detail: str
host: str
class AvailableImages(BaseModel):
images: list[str]
detail: str = ""
@@ -11,6 +11,7 @@ from .model import (
AvailableImages,
BackgroundJobTask,
DockerHealth,
RegistryHealth,
JobDefinitionCreateRequest,
JobDefinitionUpdateRequest,
JobRun,
@@ -147,3 +148,14 @@ async def docker_health(
access_token: AccessTokenMetadata = auth_service.CurrentUserAccessTokenPayloadDep,
) -> DockerHealth:
return service.docker_health(access_token)
@router.get(
"/registry-health",
operation_id="getBackgroundJobsRegistryHealth",
response_model=RegistryHealth,
)
async def registry_health(
access_token: AccessTokenMetadata = auth_service.CurrentUserAccessTokenPayloadDep,
) -> RegistryHealth:
return service.registry_health(access_token)
@@ -45,6 +45,23 @@ def docker_reachable() -> tuple[bool, str]:
return False, str(error)
def registry_reachable() -> tuple[bool, str]:
username = settings.background_jobs_registry_username
password = settings.background_jobs_registry_password
auth = (username, password) if username and password else None
host = registry_host()
try:
with httpx.Client(timeout=8.0, auth=auth) as client:
response = client.get(f"https://{host}/v2/")
if response.status_code == 200:
return True, "ok"
if response.status_code == 401:
return False, "authentication failed (401)"
return False, f"unexpected status {response.status_code}"
except Exception as error: # noqa: BLE001
return False, str(error)
def compute_next_run(schedule: str) -> datetime:
return croniter(schedule, utcnow()).get_next(datetime)
@@ -17,6 +17,7 @@ from .model import (
AvailableImages,
BackgroundJobTask,
DockerHealth,
RegistryHealth,
JobDefinition,
JobDefinitionCreateRequest,
JobDefinitionUpdateRequest,
@@ -390,3 +391,11 @@ def docker_health(access_token: AccessTokenMetadata) -> DockerHealth:
_require_super_admin(access_token)
reachable, detail = runner.docker_reachable()
return DockerHealth(reachable=reachable, detail=detail)
def registry_health(access_token: AccessTokenMetadata) -> RegistryHealth:
_require_super_admin(access_token)
reachable, detail = runner.registry_reachable()
return RegistryHealth(
reachable=reachable, detail=detail, host=runner.registry_host()
)
@@ -192,6 +192,7 @@ model/publicationIdsByAuthorPosition.ts
model/publicationsByAuthorResponse.ts
model/rankingResponse.ts
model/rebuildResponse.ts
model/registryHealth.ts
model/score.ts
model/sortDirection.ts
model/tokenType.ts
@@ -38,6 +38,8 @@ import { JobDefinitionUpdateRequest } from '../model/jobDefinitionUpdateRequest'
import { JobRun } from '../model/jobRun';
// @ts-ignore
import { JobRunLogs } from '../model/jobRunLogs';
// @ts-ignore
import { RegistryHealth } from '../model/registryHealth';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS } from '../variables';
@@ -856,6 +858,110 @@ export class BackgroundJobsService extends BaseService {
);
}
/**
* Registry Health
* @endpoint get /api/background-jobs/registry-health
* @param secureFgpAcc
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
* @param reportProgress flag to report request and response progress.
*/
public getBackgroundJobsRegistryHealth(
secureFgpAcc?: string,
observe?: 'body',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<RegistryHealth>;
public getBackgroundJobsRegistryHealth(
secureFgpAcc?: string,
observe?: 'response',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<HttpResponse<RegistryHealth>>;
public getBackgroundJobsRegistryHealth(
secureFgpAcc?: string,
observe?: 'events',
reportProgress?: boolean,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<HttpEvent<RegistryHealth>>;
public getBackgroundJobsRegistryHealth(
secureFgpAcc?: string,
observe: any = 'body',
reportProgress: boolean = false,
options?: {
httpHeaderAccept?: 'application/json';
context?: HttpContext;
transferCache?: boolean;
},
): Observable<any> {
let localVarHeaders = this.defaultHeaders;
// authentication (HTTPBearer) required
localVarHeaders = this.configuration.addCredentialToHeaders(
'HTTPBearer',
'Authorization',
localVarHeaders,
'Bearer ',
);
const localVarHttpHeaderAcceptSelected: string | undefined =
options?.httpHeaderAccept ??
this.configuration.selectHeaderAccept(['application/json']);
if (localVarHttpHeaderAcceptSelected !== undefined) {
localVarHeaders = localVarHeaders.set(
'Accept',
localVarHttpHeaderAcceptSelected,
);
}
const localVarHttpContext: HttpContext =
options?.context ?? new HttpContext();
const localVarTransferCache: boolean = options?.transferCache ?? true;
let responseType_: 'text' | 'json' | 'blob' = 'json';
if (localVarHttpHeaderAcceptSelected) {
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
responseType_ = 'text';
} else if (
this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)
) {
responseType_ = 'json';
} else {
responseType_ = 'blob';
}
}
let localVarPath = `/api/background-jobs/registry-health`;
const { basePath, withCredentials } = this.configuration;
return this.httpClient.request<RegistryHealth>(
'get',
`${basePath}${localVarPath}`,
{
context: localVarHttpContext,
responseType: <any>responseType_,
...(withCredentials ? { withCredentials } : {}),
headers: localVarHeaders,
observe: observe,
...(localVarTransferCache !== undefined
? { transferCache: localVarTransferCache }
: {}),
reportProgress: reportProgress,
},
);
}
/**
* Run Task
* @endpoint post /api/background-jobs/tasks/{task_id}/run
+1
View File
@@ -162,6 +162,7 @@ export * from './publicationIdsByAuthorPosition';
export * from './publicationsByAuthorResponse';
export * from './rankingResponse';
export * from './rebuildResponse';
export * from './registryHealth';
export * from './score';
export * from './sortDirection';
export * from './tokenType';
@@ -0,0 +1,15 @@
/**
* Innovation Search Engine API
*
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface RegistryHealth {
reachable: boolean;
detail: string;
host: string;
}
+78 -29
View File
@@ -18,37 +18,86 @@
</button>
</header>
<mat-card appearance="outlined" class="docker-health-card">
<mat-card-content class="docker-health-content">
<div class="docker-health-info">
<span
class="docker-state-dot"
[class.docker-state-dot--ok]="dockerHealth()?.reachable"
[class.docker-state-dot--error]="
dockerHealth() && !dockerHealth()?.reachable
">
</span>
<div>
<strong>Docker-Daemon</strong>
<div class="docker-health-detail">
{{ dockerHealth()?.reachable ? 'Erreichbar' : 'Nicht erreichbar' }}
@if (dockerHealth()?.detail) {
<span> · {{ dockerHealth()?.detail }}</span>
}
<div class="health-cards">
<mat-card appearance="outlined" class="health-card">
<mat-card-content class="health-content">
<div class="health-info">
<span
class="state-dot"
[class.state-dot--ok]="dockerHealth()?.reachable"
[class.state-dot--error]="
dockerHealth() && !dockerHealth()?.reachable
">
</span>
<div class="health-text">
<strong>Docker-Daemon</strong>
<div class="health-detail">
{{
dockerHealth()?.reachable ? 'Erreichbar' : 'Nicht erreichbar'
}}
@if (dockerHealth()?.detail) {
<span> · {{ dockerHealth()?.detail }}</span>
}
</div>
</div>
</div>
</div>
<button
mat-icon-button
type="button"
aria-label="Docker-Status aktualisieren"
matTooltip="Docker-Status aktualisieren"
[disabled]="dockerHealthLoading()"
(click)="refreshDockerHealth()">
<mat-icon>refresh</mat-icon>
</button>
</mat-card-content>
</mat-card>
<button
mat-icon-button
type="button"
aria-label="Docker-Status aktualisieren"
matTooltip="Docker-Status aktualisieren"
[disabled]="dockerHealthLoading()"
(click)="refreshDockerHealth()">
<mat-icon>refresh</mat-icon>
</button>
</mat-card-content>
</mat-card>
<mat-card appearance="outlined" class="health-card">
<mat-card-content class="health-content">
<div class="health-info">
<span
class="state-dot"
[class.state-dot--ok]="registryHealth()?.reachable"
[class.state-dot--error]="
registryHealth() && !registryHealth()?.reachable
">
</span>
<div class="health-text">
<div class="health-title">
<strong>Nexus-Registry</strong>
@if (registryHealth()?.host) {
<code class="health-host">{{ registryHealth()?.host }}</code>
}
</div>
<div class="health-detail">
@if (registryHealthLoading() && !registryHealth()) {
<span>Wird geprüft …</span>
} @else {
{{
registryHealth()?.reachable
? 'Erreichbar'
: 'Nicht erreichbar'
}}
@if (registryHealth()?.detail) {
<span> · {{ registryHealth()?.detail }}</span>
}
}
</div>
</div>
</div>
<button
mat-icon-button
type="button"
aria-label="Nexus-Status aktualisieren"
matTooltip="Nexus-Status aktualisieren"
[disabled]="registryHealthLoading()"
(click)="refreshRegistryHealth()">
<mat-icon>refresh</mat-icon>
</button>
</mat-card-content>
</mat-card>
</div>
<mat-card appearance="outlined">
<mat-card-content>
+40 -13
View File
@@ -37,20 +37,35 @@ mat-paginator {
background-color: var(--sg-background);
}
.docker-health-content {
.health-cards {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
}
.docker-health-info {
display: flex;
align-items: flex-start;
gap: 12px;
}
.docker-state-dot {
.health-card {
flex: 1 1 0;
min-width: 0;
}
.health-content {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
}
.health-info {
display: flex;
align-items: flex-start;
gap: 12px;
min-width: 0;
}
.health-text {
min-width: 0;
}
.state-dot {
margin-top: 6px;
width: 10px;
height: 10px;
@@ -67,11 +82,24 @@ mat-paginator {
}
}
.docker-health-detail {
.health-detail {
font-size: 12px;
color: #64748b;
}
.health-title {
display: flex;
align-items: baseline;
gap: 8px;
flex-wrap: wrap;
}
.health-host {
font-size: 11px;
color: #64748b;
word-break: break-all;
}
:host ::ng-deep .mat-mdc-row {
height: 96px;
}
@@ -283,8 +311,7 @@ mat-paginator {
flex-direction: column;
}
.docker-health-content {
.health-cards {
flex-direction: column;
align-items: flex-start;
}
}
@@ -30,6 +30,7 @@ import {
BackgroundJobsService,
BackgroundJobTask,
DockerHealth,
RegistryHealth,
} from '../../api';
import {
DataTableComponent,
@@ -89,6 +90,8 @@ export class JobsComponent implements OnInit {
protected readonly tasks = signal<BackgroundJobTask[]>([]);
protected readonly dockerHealth = signal<DockerHealth | null>(null);
protected readonly dockerHealthLoading = signal(false);
protected readonly registryHealth = signal<RegistryHealth | null>(null);
protected readonly registryHealthLoading = signal(false);
protected readonly deletingTaskIds = signal<ReadonlySet<number>>(new Set());
protected readonly nowMs = signal(Date.now());
@@ -123,6 +126,7 @@ export class JobsComponent implements OnInit {
ngOnInit(): void {
this.tasks.set(this.tasksInput());
this.dockerHealth.set(this.dockerHealthInput());
this.refreshRegistryHealth();
merge(this.pollNow, this.taskRefreshTrigger)
.pipe(
@@ -249,6 +253,39 @@ export class JobsComponent implements OnInit {
});
}
protected refreshRegistryHealth(): void {
this.registryHealthLoading.set(true);
this.backgroundJobsService
.getBackgroundJobsRegistryHealth()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (health) => {
this.registryHealth.set(health);
this.registryHealthLoading.set(false);
},
error: () => {
this.registryHealthLoading.set(false);
this.showError('Nexus-Status konnte nicht abgerufen werden.');
},
});
}
private notifyIfRegistryDown(): void {
this.backgroundJobsService
.getBackgroundJobsRegistryHealth()
.pipe(takeUntilDestroyed(this.destroyRef))
.subscribe({
next: (health) => {
this.registryHealth.set(health);
if (!health.reachable) {
this.showError(
`Nexus-Registry nicht erreichbar: ${health.detail}. Die Image-Auswahl bleibt leer.`,
);
}
},
});
}
protected runNow(task: BackgroundJobTask): void {
if (['running', 'stopping'].includes(task.status)) return;
@@ -334,6 +371,8 @@ export class JobsComponent implements OnInit {
}
protected openCreateDialog(): void {
this.notifyIfRegistryDown();
const dialogRef = this.dialog.open<
TaskCreateDialogComponent,
void,
@@ -359,6 +398,8 @@ export class JobsComponent implements OnInit {
protected openEditDialog(task: BackgroundJobTask): void {
if (['running', 'stopping'].includes(task.status)) return;
this.notifyIfRegistryDown();
const dialogRef = this.dialog.open<
TaskEditDialogComponent,
TaskEditDialogData,