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

fix(KFLUXUI-253): tekton results should filter unknown status record out #55

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
15 changes: 10 additions & 5 deletions src/utils/__tests__/tekton-results.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,23 @@ const mockRecordsList = {
},
{
data: {
// {"key":"test2"}
value: 'eyJrZXkiOiJ0ZXN0MiJ9',
// {"status":{"conditions":[{"status":"Unknown"},{"status":"Failed"}]}}
value:
'eyJzdGF0dXMiOnsiY29uZGl0aW9ucyI6W3sic3RhdHVzIjoiVW5rbm93biJ9LHsic3RhdHVzIjoiRmFpbGVkIn1dfX0K',
},
},
],
} as RecordsList;

const mockResponseCheck = [[{ key: 'test1' }, { key: 'test2' }], mockRecordsList] as [
const mockResponseCheck = [
[{ key: 'test1' }, { status: { conditions: [{ status: 'Unknown' }, { status: 'Failed' }] } }],
mockRecordsList,
] as [unknown[], RecordsList];

const mockPipelineRunReponseCheck = [[{ key: 'test1' }], mockRecordsList] as [
unknown[],
RecordsList,
];

const mockLogsRecordsList = {
nextPageToken: null,
records: [
Expand Down Expand Up @@ -551,7 +556,7 @@ describe('tekton-results', () => {
describe('getPipelineRuns', () => {
it('should return record list and decoded value', async () => {
commonFetchJSONMock.mockReturnValue(mockRecordsList);
expect(await getPipelineRuns('test-ws', 'test-ns')).toEqual(mockResponseCheck);
expect(await getPipelineRuns('test-ws', 'test-ns')).toEqual(mockPipelineRunReponseCheck);
});

it('should query tekton results with options', async () => {
Expand Down
14 changes: 11 additions & 3 deletions src/utils/tekton-results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,15 +286,15 @@ export const getFilteredRecord = async <R extends K8sResourceCommon>(
return value;
};

const getFilteredPipelineRuns = (
const getFilteredPipelineRuns = async (
workspace: string,
namespace: string,
filter: string,
options?: TektonResultsOptions,
nextPageToken?: string,
cacheKey?: string,
) =>
getFilteredRecord<PipelineRunKindV1Beta1>(
): Promise<[PipelineRunKindV1Beta1[], RecordsList]> => {
const [originalPipelineRuns, list] = await getFilteredRecord<PipelineRunKindV1Beta1>(
workspace,
namespace,
[DataType.PipelineRun, DataType.PipelineRun_v1beta1],
Expand All @@ -303,6 +303,14 @@ const getFilteredPipelineRuns = (
nextPageToken,
cacheKey,
);
// When pipelines are running, the etcd would keep their results.
// deleting pipelines frome ectd would make unknown tekton results.
// Just to get meaningful test runs, we need to filter 'unknown' out.
const filteredPipelineRuns = originalPipelineRuns.filter((pipelinerun) => {
return pipelinerun.status?.conditions?.every((c) => c.status !== 'Unknown') ?? true;
});
return [filteredPipelineRuns, list];
};
Comment on lines +306 to +313
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible that an unknown status will appear for the pipeline runs that were not deleted? In that case, It's not a good idea to filter out the Unknown status pipeline runs.


const getFilteredTaskRuns = (
workspace: string,
Expand Down
Loading