Skip to content

Commit

Permalink
NIFI-13552 - Ensure errors from Provenance and Lineage queries are sh…
Browse files Browse the repository at this point in the history
…own. (#9088)

This closes #9088
  • Loading branch information
mcgilman authored Jul 17, 2024
1 parent 8e5cf99 commit ca227c7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { selectActiveLineageId, selectClusterNodeIdFromActiveLineage } from './l
import * as ErrorActions from '../../../../state/error/error.actions';
import { ErrorHelper } from '../../../../service/error-helper.service';
import { HttpErrorResponse } from '@angular/common/http';
import { isDefinedAndNotNull } from 'libs/shared/src';
import { isDefinedAndNotNull, NiFiCommon } from 'libs/shared/src';

@Injectable()
export class LineageEffects {
Expand All @@ -38,6 +38,7 @@ export class LineageEffects {
private store: Store<NiFiState>,
private provenanceService: ProvenanceService,
private errorHelper: ErrorHelper,
private nifiCommon: NiFiCommon,
private dialog: MatDialog
) {}

Expand Down Expand Up @@ -78,8 +79,11 @@ export class LineageEffects {
map((action) => action.response),
switchMap((response) => {
const query: Lineage = response.lineage;
if (query.finished) {
this.dialog.closeAll();
if (query.finished || !this.nifiCommon.isEmpty(query.results.errors)) {
response.lineage.results.errors?.forEach((error) => {
this.store.dispatch(ErrorActions.addBannerError({ error }));
});

return of(LineageActions.deleteLineageQuery());
} else {
return of(LineageActions.startPollingLineageQuery());
Expand Down Expand Up @@ -138,8 +142,16 @@ export class LineageEffects {
this.actions$.pipe(
ofType(LineageActions.pollLineageQuerySuccess),
map((action) => action.response),
filter((response) => response.lineage.finished),
switchMap(() => of(LineageActions.stopPollingLineageQuery()))
filter(
(response) => response.lineage.finished || !this.nifiCommon.isEmpty(response.lineage.results.errors)
),
switchMap((response) => {
response.lineage.results.errors?.forEach((error) => {
this.store.dispatch(ErrorActions.addBannerError({ error }));
});

return of(LineageActions.stopPollingLineageQuery());
})
)
);

Expand All @@ -158,6 +170,8 @@ export class LineageEffects {
this.store.select(selectClusterNodeIdFromActiveLineage)
]),
tap(([, id, clusterNodeId]) => {
this.dialog.closeAll();

if (id) {
this.provenanceService.deleteLineageQuery(id, clusterNodeId).subscribe();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import { CancelDialog } from '../../../../ui/common/cancel-dialog/cancel-dialog.
import * as ErrorActions from '../../../../state/error/error.actions';
import { ErrorHelper } from '../../../../service/error-helper.service';
import { HttpErrorResponse } from '@angular/common/http';
import { isDefinedAndNotNull } from 'libs/shared/src';
import { isDefinedAndNotNull, NiFiCommon } from 'libs/shared/src';
import { selectClusterSummary } from '../../../../state/cluster-summary/cluster-summary.selectors';
import { ClusterService } from '../../../../service/cluster.service';
import { LARGE_DIALOG, MEDIUM_DIALOG } from 'libs/shared/src';
Expand All @@ -54,6 +54,7 @@ export class ProvenanceEventListingEffects {
private provenanceService: ProvenanceService,
private errorHelper: ErrorHelper,
private clusterService: ClusterService,
private nifiCommon: NiFiCommon,
private dialog: MatDialog,
private router: Router
) {}
Expand Down Expand Up @@ -143,8 +144,11 @@ export class ProvenanceEventListingEffects {
map((action) => action.response),
switchMap((response) => {
const query: Provenance = response.provenance;
if (query.finished) {
this.dialog.closeAll();
if (query.finished || !this.nifiCommon.isEmpty(query.results.errors)) {
response.provenance.results.errors?.forEach((error) => {
this.store.dispatch(ErrorActions.addBannerError({ error }));
});

return of(ProvenanceEventListingActions.deleteProvenanceQuery());
} else {
return of(ProvenanceEventListingActions.startPollingProvenanceQuery());
Expand Down Expand Up @@ -203,8 +207,17 @@ export class ProvenanceEventListingEffects {
this.actions$.pipe(
ofType(ProvenanceEventListingActions.pollProvenanceQuerySuccess),
map((action) => action.response),
filter((response) => response.provenance.finished),
switchMap(() => of(ProvenanceEventListingActions.stopPollingProvenanceQuery()))
filter(
(response) =>
response.provenance.finished || !this.nifiCommon.isEmpty(response.provenance.results.errors)
),
switchMap((response) => {
response.provenance.results.errors?.forEach((error) => {
this.store.dispatch(ErrorActions.addBannerError({ error }));
});

return of(ProvenanceEventListingActions.stopPollingProvenanceQuery());
})
)
);

Expand Down

0 comments on commit ca227c7

Please sign in to comment.