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

NAS-130739 / 24.10-RC.1 / Remove references to Pods in apps #10516

Merged
merged 1 commit into from
Aug 21, 2024
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
4 changes: 2 additions & 2 deletions src/app/interfaces/shell-details-dialog.interface.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { PodSelectDialogType } from 'app/enums/pod-select-dialog.enum';
import { ShellDetailsDialogComponent } from 'app/pages/apps/components/shell-details-dialog/shell-details-dialog.component';
import { ShellDetailsType } from 'app/pages/apps/enum/shell-details-type.enum';

export interface ShellDetailsDialogData {
type: PodSelectDialogType;
type: ShellDetailsType;
title: string;
appName: string;
containerImageKey: string;
Expand Down
8 changes: 4 additions & 4 deletions src/app/pages/apps/apps-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import { AppsScopeWrapperComponent } from 'app/pages/apps/components/apps-scope-
import { AvailableAppsComponent } from 'app/pages/apps/components/available-apps/available-apps.component';
import { CategoryViewComponent } from 'app/pages/apps/components/available-apps/category-view/category-view.component';
import { DockerImagesListComponent } from 'app/pages/apps/components/docker-images/docker-images-list/docker-images-list.component';
import { ContainerLogsComponent } from 'app/pages/apps/components/installed-apps/container-logs/container-logs.component';
import { ContainerShellComponent } from 'app/pages/apps/components/installed-apps/container-shell/container-shell.component';
import { InstalledAppsComponent } from 'app/pages/apps/components/installed-apps/installed-apps.component';
import { PodLogsComponent } from 'app/pages/apps/components/installed-apps/pod-logs/pod-logs.component';
import { appNameResolver } from 'app/pages/apps/resolvers/app-name.resolver';
import { AppDetailViewComponent } from './components/app-detail-view/app-detail-view.component';
import { AppRouterOutletComponent } from './components/app-router-outlet/app-router-outlet.component';
Expand Down Expand Up @@ -57,12 +57,12 @@ const routes: Routes = [
{
path: 'shell/:containerId/:command',
component: ContainerShellComponent,
data: { title: T('Pod Shell') },
data: { title: T('Container Shell') },
},
{
path: 'logs/:containerId',
component: PodLogsComponent,
data: { title: T('Pod Logs') },
component: ContainerLogsComponent,
data: { title: T('Container Logs') },
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/apps/apps.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ import { AppSettingsButtonComponent } from 'app/pages/apps/components/installed-
import { AppUpdateCellComponent } from 'app/pages/apps/components/installed-apps/app-update-cell/app-update-cell.component';
import { AppWorkloadsCardComponent } from 'app/pages/apps/components/installed-apps/app-workloads-card/app-workloads-card.component';
import { VolumeMountsDialogComponent } from 'app/pages/apps/components/installed-apps/app-workloads-card/volume-mounts-dialog/volume-mounts-dialog.component';
import { ContainerLogsComponent } from 'app/pages/apps/components/installed-apps/container-logs/container-logs.component';
import { ContainerShellComponent } from 'app/pages/apps/components/installed-apps/container-shell/container-shell.component';
import { PodLogsComponent } from 'app/pages/apps/components/installed-apps/pod-logs/pod-logs.component';
import { LogsDetailsDialogComponent } from 'app/pages/apps/components/logs-details-dialog/logs-details-dialog.component';
import { SelectPoolDialogComponent } from 'app/pages/apps/components/select-pool-dialog/select-pool-dialog.component';
import { ShellDetailsDialogComponent } from 'app/pages/apps/components/shell-details-dialog/shell-details-dialog.component';
Expand Down Expand Up @@ -105,7 +105,7 @@ import { InstalledAppsComponent } from './components/installed-apps/installed-ap
AppsScopeWrapperComponent,
AppAvailableInfoCardComponent,
ContainerShellComponent,
PodLogsComponent,
ContainerLogsComponent,
LogsDetailsDialogComponent,
ShellDetailsDialogComponent,
AppUpgradeDialogComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@
enum: [
{
value: 'RollingUpdate',
description: 'Create new pods and then kill old ones',
description: 'Create new containers and then kill old ones',
},
{
value: 'Recreate',
description: 'Kill existing pods before creating new ones',
description: 'Kill existing containers before creating new ones',
},
],
show_if: [
Expand Down Expand Up @@ -413,19 +413,19 @@
'Gateway Port to use for IPFS (local)': '9880',
'Provide access to node network namespace for the workload': false,
'Swarm Port to use for IPFS (Public)': '9401',
'Update Strategy': 'Create new pods and then kill old ones',
'Update Strategy': 'Create new containers and then kill old ones',
});
});

// TODO:
it.skip('creating when form is submitted', async () => {

Check warning on line 421 in src/app/pages/apps/components/app-wizard/app-wizard.component.spec.ts

View workflow job for this annotation

GitHub Actions / Validate code style

Disabled test
const form = await loader.getHarness(IxFormHarness);
await form.fillForm({
'Application Name': 'appname',
'API Port to use for IPFS (local)': '9599',
'Gateway Port to use for IPFS (local)': '9822',
'Provide access to node network namespace for the workload': true,
'Update Strategy': 'Kill existing pods before creating new ones',
'Update Strategy': 'Kill existing containers before creating new ones',
});

const values = await form.getValues();
Expand All @@ -436,7 +436,7 @@
'API Port to use for IPFS (local)': '9599',
'Gateway Port to use for IPFS (local)': '9822',
'Swarm Port to use for IPFS (Public)': '9401',
'Update Strategy': 'Kill existing pods before creating new ones',
'Update Strategy': 'Kill existing containers before creating new ones',
});

const saveButton = await loader.getHarness(MatButtonHarness.with({ text: 'Install' }));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ import { MockComponent } from 'ng-mocks';
import { of } from 'rxjs';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { CatalogAppState } from 'app/enums/catalog-app-state.enum';
import { PodSelectDialogType } from 'app/enums/pod-select-dialog.enum';
import { App, AppContainerState } from 'app/interfaces/app.interface';
import { MapValuePipe } from 'app/modules/pipes/map-value/map-value.pipe';
import { AppWorkloadsCardComponent } from 'app/pages/apps/components/installed-apps/app-workloads-card/app-workloads-card.component';
import {
VolumeMountsDialogComponent,
} from 'app/pages/apps/components/installed-apps/app-workloads-card/volume-mounts-dialog/volume-mounts-dialog.component';
import { ShellDetailsDialogComponent } from 'app/pages/apps/components/shell-details-dialog/shell-details-dialog.component';
import { ShellDetailsType } from 'app/pages/apps/enum/shell-details-type.enum';

describe('AppContainersCardComponent', () => {
let spectator: Spectator<AppWorkloadsCardComponent>;
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('AppContainersCardComponent', () => {
data: {
appName: app.name,
title: 'Choose Shell Details',
type: PodSelectDialogType.Shell,
type: ShellDetailsType.Shell,
customSubmit: expect.any(Function),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Router } from '@angular/router';
import { UntilDestroy } from '@ngneat/until-destroy';
import { TranslateService } from '@ngx-translate/core';
import { CatalogAppState } from 'app/enums/catalog-app-state.enum';
import { PodSelectDialogType } from 'app/enums/pod-select-dialog.enum';
import { Role } from 'app/enums/role.enum';
import {
App, AppContainerDetails, AppContainerState, appContainerStateLabels,
Expand All @@ -16,6 +15,7 @@ import {
VolumeMountsDialogComponent,
} from 'app/pages/apps/components/installed-apps/app-workloads-card/volume-mounts-dialog/volume-mounts-dialog.component';
import { ShellDetailsDialogComponent } from 'app/pages/apps/components/shell-details-dialog/shell-details-dialog.component';
import { ShellDetailsType } from 'app/pages/apps/enum/shell-details-type.enum';

@UntilDestroy()
@Component({
Expand Down Expand Up @@ -70,7 +70,7 @@ export class AppWorkloadsCardComponent {
data: {
appName: this.app().name,
title: this.translate.instant('Choose Shell Details'),
type: PodSelectDialogType.Shell,
type: ShellDetailsType.Shell,
customSubmit: (values: ShellDetailsDialogFormValue) => this.shellDialogSubmit(values, containerId),
},
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
}
</ix-page-header>

<div class="pod-logs-wrapper">
<div class="logs-wrapper">
<div class="meta-data">
<label>{{ 'Application Name' | translate }}:</label>
<span class="name">{{ appName }}</span>
Expand All @@ -27,17 +27,17 @@
</div>
<div
#logContainer
class="pod-logs"
[ngStyle]="{ 'font-size': fontSize + 'px' }"
class="logs"
[style.font-size]="fontSize + 'px'"
>
@if (isLoadingPodLogs) {
@if (isLoading) {
<mat-spinner class="spinner" [diameter]="40"></mat-spinner>
} @else if (!podLogs.length) {
} @else if (!logs.length) {
<div class="log-row">
<span class="no-logs">{{ 'No logs yet' | translate }}</span>
</div>
} @else {
@for (podLog of podLogs; track podLog) {
@for (podLog of logs; track podLog) {
<div class="log-row">
<span class="timestamp">{{ podLog.timestamp }}</span>
<span class="log-data">{{ podLog.data }}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
:host ::ng-deep {
.pod-logs-wrapper {
.logs-wrapper {
color: white;
height: calc(100% - 121px);
margin-left: 8px;
margin-right: 8px;
width: calc(100% - 16px);
}

.pod-logs {
.logs {
background: black;
font-family: 'Inconsolata';
height: calc(100% - 70px);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ import { of } from 'rxjs';
import { mockAuth } from 'app/core/testing/utils/mock-auth.utils';
import { ToolbarSliderComponent } from 'app/modules/forms/toolbar-slider/toolbar-slider.component';
import { PageHeaderModule } from 'app/modules/page-header/page-header.module';
import { PodLogsComponent } from 'app/pages/apps/components/installed-apps/pod-logs/pod-logs.component';
import { ContainerLogsComponent } from 'app/pages/apps/components/installed-apps/container-logs/container-logs.component';
import { LogsDetailsDialogComponent } from 'app/pages/apps/components/logs-details-dialog/logs-details-dialog.component';
import { WebSocketService } from 'app/services/ws.service';

describe('PodLogsComponent', () => {
let spectator: Spectator<PodLogsComponent>;
describe('ContainerLogsComponent', () => {
let spectator: Spectator<ContainerLogsComponent>;

const createComponent = createComponentFactory({
component: PodLogsComponent,
component: ContainerLogsComponent,
imports: [
MockModule(PageHeaderModule),
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { ErrorHandlerService } from 'app/services/error-handler.service';
import { ShellService } from 'app/services/shell.service';
import { WebSocketService } from 'app/services/ws.service';

interface PodLogEvent {
interface ContainerLogEvent {
data: string;
timestamp: string;
msg?: string;
Expand All @@ -25,24 +25,24 @@ interface PodLogEvent {

@UntilDestroy()
@Component({
selector: 'ix-pod-logs',
templateUrl: './pod-logs.component.html',
styleUrls: ['./pod-logs.component.scss'],
selector: 'ix-container-logs',
templateUrl: './container-logs.component.html',
styleUrls: ['./container-logs.component.scss'],
providers: [ShellService],
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class PodLogsComponent implements OnInit {
export class ContainerLogsComponent implements OnInit {
@ViewChild('logContainer', { static: true }) logContainer: ElementRef<HTMLElement>;

fontSize = 14;
appName: string;
containerId: string;
podLogSubName = '';
isLoadingPodLogs = false;
subscriptionMethod = '';
isLoading = false;
defaultTailLines = 500;

private podLogsChangedListener: Subscription;
podLogs: PodLogEvent[] = [];
private logsChangedListener: Subscription;
logs: ContainerLogEvent[] = [];

constructor(
private ws: WebSocketService,
Expand All @@ -68,37 +68,37 @@ export class PodLogsComponent implements OnInit {

// subscribe pod log for selected app, pod and container.
reconnect(): void {
if (this.podLogsChangedListener && !this.podLogsChangedListener.closed) {
this.podLogsChangedListener.unsubscribe();
if (this.logsChangedListener && !this.logsChangedListener.closed) {
this.logsChangedListener.unsubscribe();
}

this.podLogsChangedListener = this.matDialog.open(LogsDetailsDialogComponent, { width: '400px' }).afterClosed().pipe(
this.logsChangedListener = this.matDialog.open(LogsDetailsDialogComponent, { width: '400px' }).afterClosed().pipe(
tap((details: LogsDetailsDialogComponent['form']['value']) => {
this.podLogSubName = `app.container_log_follow: ${JSON.stringify({
this.subscriptionMethod = `app.container_log_follow: ${JSON.stringify({
app_name: this.appName,
container_id: this.containerId,
tail_lines: details.tail_lines || this.defaultTailLines,
})}`;

this.podLogs = [];
this.isLoadingPodLogs = true;
this.logs = [];
this.isLoading = true;
}),
switchMap(() => this.ws.subscribeToLogs(this.podLogSubName)),
switchMap(() => this.ws.subscribeToLogs(this.subscriptionMethod)),
map((apiEvent) => apiEvent.fields),
untilDestroyed(this),
).subscribe({
next: (podLog: PodLogEvent) => {
this.isLoadingPodLogs = false;
next: (log: ContainerLogEvent) => {
this.isLoading = false;

if (podLog && podLog.msg !== 'nosub') {
this.podLogs.push(podLog);
if (log && log.msg !== 'nosub') {
this.logs.push(log);
this.scrollToBottom();
}

this.cdr.markForCheck();
},
error: (error: WebSocketError) => {
this.isLoadingPodLogs = false;
this.isLoading = false;
if (error.reason) {
this.dialogService.error(this.errorHandler.parseError(error));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import {
combineLatest, Observable, Subject, Subscriber,
} from 'rxjs';
import { PodSelectDialogType } from 'app/enums/pod-select-dialog.enum';
import { ShellDetailsDialogFormValue } from 'app/interfaces/shell-details-dialog.interface';
import { TerminalConfiguration, TerminalConnectionData } from 'app/interfaces/terminal.interface';
import { DialogService } from 'app/modules/dialog/dialog.service';
import { ShellDetailsDialogComponent } from 'app/pages/apps/components/shell-details-dialog/shell-details-dialog.component';
import { ShellDetailsType } from 'app/pages/apps/enum/shell-details-type.enum';

@UntilDestroy()
@Component({
Expand Down Expand Up @@ -59,8 +59,8 @@ export class ContainerShellComponent implements TerminalConfiguration {
maxWidth: '850px',
data: {
appName: this.appName,
type: PodSelectDialogType.Shell,
title: 'Choose pod',
type: ShellDetailsType.Shell,
title: 'Choose container',
customSubmit: (dialogFormValue: ShellDetailsDialogFormValue) => {
this.onChooseShell(dialogFormValue, this.containerId);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
import { createComponentFactory, mockProvider, Spectator } from '@ngneat/spectator/jest';
import { MockWebSocketService } from 'app/core/testing/classes/mock-websocket.service';
import { mockCall, mockWebSocket } from 'app/core/testing/utils/mock-websocket.utils';
import { PodSelectDialogType } from 'app/enums/pod-select-dialog.enum';
import { IxFormsModule } from 'app/modules/forms/ix-forms/ix-forms.module';
import { IxFormHarness } from 'app/modules/forms/ix-forms/testing/ix-form.harness';
import { AppLoaderModule } from 'app/modules/loader/app-loader.module';
import { ShellDetailsDialogComponent } from 'app/pages/apps/components/shell-details-dialog/shell-details-dialog.component';
import { ShellDetailsType } from 'app/pages/apps/enum/shell-details-type.enum';

// TODO:
describe.skip('PodSelectDialogComponent', () => {

Check warning on line 16 in src/app/pages/apps/components/shell-details-dialog/shell-details-dialog.component.spec.ts

View workflow job for this annotation

GitHub Actions / Validate code style

Disabled test suite
let spectator: Spectator<ShellDetailsDialogComponent>;
let loader: HarnessLoader;
let form: IxFormHarness;
Expand Down Expand Up @@ -45,7 +45,7 @@
provide: MAT_DIALOG_DATA,
useValue: {
appName: 'app_name',
type: PodSelectDialogType.Shell,
type: ShellDetailsType.Shell,
containerImageKey: 'test.shell/pod1:7.0.11',
customSubmit: mockCustomSubmit,
},
Expand Down Expand Up @@ -93,7 +93,7 @@
useValue: {
appName: 'app_name',
containerImageKey: 'test.logs/pod1:7.0.11',
type: PodSelectDialogType.Logs,
type: ShellDetailsType.Logs,
customSubmit: mockCustomSubmit,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
} from '@angular/forms';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { UntilDestroy } from '@ngneat/until-destroy';
import { PodSelectDialogType } from 'app/enums/pod-select-dialog.enum';
import { ShellDetailsDialogData } from 'app/interfaces/shell-details-dialog.interface';
import { ShellDetailsType } from 'app/pages/apps/enum/shell-details-type.enum';
import { ApplicationsService } from 'app/pages/apps/services/applications.service';

@UntilDestroy()
Expand All @@ -20,8 +20,8 @@ import { ApplicationsService } from 'app/pages/apps/services/applications.servic
export class ShellDetailsDialogComponent {
private tailLines = 500;
selectedAppName: string;
dialogType: PodSelectDialogType;
podSelectDialogType = PodSelectDialogType;
dialogType: ShellDetailsType;
podSelectDialogType = ShellDetailsType;
podList: string[] = [];
podDetails: Record<string, string[]> = {};

Expand All @@ -42,12 +42,12 @@ export class ShellDetailsDialogComponent {
this.dialogType = data.type;
this.title = data.title;
switch (this.dialogType) {
case PodSelectDialogType.Shell:
case ShellDetailsType.Shell:
this.form = this.formBuilder.group({
command: ['/bin/sh', Validators.required],
}) as ShellDetailsDialogComponent['form'];
break;
case PodSelectDialogType.Logs:
case ShellDetailsType.Logs:
this.form = this.formBuilder.group({
tail_lines: [this.tailLines, Validators.required],
}) as ShellDetailsDialogComponent['form'];
Expand Down
Loading
Loading