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

Add workspaces to Pipeline Details Page #8238

Merged

Conversation

abhinandan13jan
Copy link
Contributor

@abhinandan13jan abhinandan13jan commented Feb 24, 2021

Addresses

In continuation to #8216
https://issues.redhat.com/browse/ODC-4444

Screenshot

Screenshot from 2021-02-22 19-58-42
Screenshot from 2021-02-22 19-59-06
Screenshot from 2021-02-22 19-58-51
Screenshot from 2021-02-22 19-58-22
Screenshot from 2021-02-22 19-58-34

PR Test

Add following YAMLs and check the details pages

apiVersion: v1
kind: Secret
metadata:
  name: secret-password
type: Opaque
data:
  password: aHVudGVyMg==
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: shared-task-storage
spec:
  resources:
    requests:
      storage: 16Mi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: fetch-secure-data
spec:
  workspaces:
  - name: super-secret-password
  - name: secure-store
  - name: filedrop
  steps:
  - name: fetch-and-write
    image: ubuntu
    script: |
      if [ "hunter2" = "$(cat $(workspaces.super-secret-password.path)/password)" ]; then
        cp $(workspaces.secure-store.path)/recipe.txt $(workspaces.filedrop.path)
      else
        echo "wrong password!"
        exit 1
      fi
---
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
  name: print-data
spec:
  workspaces:
  - name: storage
    readOnly: true
  params:
  - name: filename
  steps:
  - name: print-secrets
    image: ubuntu
    script: cat $(workspaces.storage.path)/$(params.filename)
---
apiVersion: tekton.dev/v1beta1
kind: Pipeline
metadata:
  name: fetch-and-print-recipe
spec:
  workspaces:
  - name: password-vault
  - name: recipe-store
  - name: shared-data
  tasks:
  - name: fetch-the-recipe
    taskRef:
      name: fetch-secure-data
    workspaces:
    - name: super-secret-password
      workspace: password-vault
    - name: secure-store
      workspace: recipe-store
    - name: filedrop
      workspace: shared-data
  - name: print-the-recipe
    taskRef:
      name: print-data
    # Note: this is currently required to ensure order of write / read on PVC is correct.
    runAfter:
      - fetch-the-recipe
    params:
    - name: filename
      value: recipe.txt
    workspaces:
    - name: storage
      workspace: shared-data
---
apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
  generateName: recipe-time-
spec:
  pipelineRef:
    name: fetch-and-print-recipe
  workspaces:
  - name: password-vault
    secret:
      secretName: secret-password
  - name: recipe-store
    configMap:
      name: sensitive-recipe-storage
      items:
      - key: brownies
        path: recipe.txt
  - name: shared-data
    persistentVolumeClaim:
      claimName: shared-task-storage

Tests

Added unit tests

Browser conformance

Chrome 88

@openshift-ci-robot openshift-ci-robot added the component/pipelines Related to pipelines-plugin label Feb 24, 2021
@openshift-ci-robot openshift-ci-robot added the kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated label Feb 24, 2021
@abhinandan13jan abhinandan13jan deleted the pipeline-workspaces branch February 24, 2021 14:30
@abhinandan13jan abhinandan13jan restored the pipeline-workspaces branch February 24, 2021 14:59
@abhinandan13jan
Copy link
Contributor Author

/retest

@abhinandan13jan abhinandan13jan deleted the pipeline-workspaces branch February 24, 2021 15:04
@abhinandan13jan abhinandan13jan restored the pipeline-workspaces branch February 24, 2021 15:06
@abhinandan13jan
Copy link
Contributor Author

@bgliwa01 @karthikjeeyar Unable to restore the commit in previous PR, please look into this one instead. regretting the inconvenience.

@abhinandan13jan
Copy link
Contributor Author

@karthik I've taken care og the volumeClaimTemplate thing.

Comment on lines 60 to 71
<VolumeClaimTemplateLink
labels={labels}
workspaceName={workspace.name}
namespace={namespace}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Unique key is missing here, causing the error in console.

Suggested change
<VolumeClaimTemplateLink
labels={labels}
workspaceName={workspace.name}
namespace={namespace}
/>
<VolumeClaimTemplateLink
key={workspace.name}
labels={labels}
workspaceName={workspace.name}
namespace={namespace}
/>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added key

@@ -45,6 +46,7 @@ const PipelineDetails: React.FC<PipelineDetailsProps> = ({
links={taskLinks}
title={t('pipelines-plugin~Tasks')}
/>
<WorkspaceDefinitionList workspaces={pipeline?.spec.workspaces} />
Copy link
Contributor

Choose a reason for hiding this comment

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

spec is not optional but workspaces is

Suggested change
<WorkspaceDefinitionList workspaces={pipeline?.spec.workspaces} />
<WorkspaceDefinitionList workspaces={pipeline.spec?.workspaces} />

@@ -57,6 +58,10 @@ const PipelineRunCustomDetails: React.FC<PipelineRunCustomDetailsProps> = ({ pip
links={renderResources}
namespace={pipelineRun.metadata.namespace}
/>
<WorkspaceResourceLinkList
workspaces={pipelineRun?.spec.workspaces}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
workspaces={pipelineRun?.spec.workspaces}
workspaces={pipelineRun.spec?.workspaces}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

import { TaskModel } from '../../models';
import { TaskKind } from '../../types';
import WorkspaceDefinitionList from '../shared/workspaces/WorkspaceDefinitionList';
import './TaskDetails.scss';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: new line before scss imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@@ -290,3 +290,76 @@ export const mockRunDurationTest = [
pipelineTestData[PipelineExampleNames.WORKSPACE_PIPELINE].pipelineRuns[DataState.SUCCESS],
pipelineTestData[PipelineExampleNames.CLUSTER_PIPELINE].pipelineRuns[DataState.SUCCESS],
];

export const pipelineWithWorkspace: PipelineKind[] = [
Copy link
Contributor

Choose a reason for hiding this comment

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

It will be good if we reuse the existing pipeline test data from pipelines-plugin/src/test-data/pipeline-data.ts. This file exclusively contains different pipeline test data including one for WORKSPACE_PIPELINE. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

using existing PL

<ResourceSummary resource={task} />
</div>
<div className="col-sm-6 odc-task-details__status">
<WorkspaceDefinitionList workspaces={task?.spec.workspaces} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<WorkspaceDefinitionList workspaces={task?.spec.workspaces} />
<WorkspaceDefinitionList workspaces={task.spec?.workspaces} />

<ResourceSummary resource={task} />
</div>
<div className="col-sm-6 odc-cluster-task-details__status">
<WorkspaceDefinitionList workspaces={task?.spec.workspaces} />
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<WorkspaceDefinitionList workspaces={task?.spec.workspaces} />
<WorkspaceDefinitionList workspaces={task.spec?.workspaces} />

@@ -38,6 +39,10 @@ const TaskRunDetailsStatus = ({ taskRun }) => {
</dd>
</dl>
)}
<WorkspaceResourceLinkList
workspaces={taskRun?.spec.workspaces}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
workspaces={taskRun?.spec.workspaces}
workspaces={taskRun.spec?.workspaces}

Copy link
Contributor

Choose a reason for hiding this comment

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

If the TaskRun is there, I'm pretty sure Spec has to be there too... I don't think conditional checks are needed. You just have to support no workspaces (empty array or undefined) in the component.

@abhinandan13jan abhinandan13jan force-pushed the pipeline-workspaces branch 2 times, most recently from 69b77b4 to 516a463 Compare February 25, 2021 12:57
@karthikjeeyar
Copy link
Contributor

karthikjeeyar commented Feb 25, 2021

@bgliwa01 For Empty Directory scenario, workspace-name is shown as the text in this PR, shall we add a separate bug to add the new design changes and let this PR go in. Is it fine with you?
image
cc: @andrewballantyne

namespace,
}) => {
const { t } = useTranslation();
return workspaces?.length > 0 ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Ideally for cleaner code, you should just return early instead of making a return into a large ternary statement.

Comment on lines 25 to 26
expect(WorkspaceDefinitionListWrapper.find('dd').exists()).toBe(false);
expect(WorkspaceDefinitionListWrapper.find('dt').exists()).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not look for the root element? dl

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated


it('Should render workspace list', () => {
const { pipeline } = pipelineTestData[PipelineExampleNames.WORKSPACE_PIPELINE];
WorkspaceDefinitionListWrapperProps = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
WorkspaceDefinitionListWrapperProps = {
workspaceDefinitionListWrapperProps = {

workspaces: PipelineWorkspace[];
}

const WorkspaceDefinitionList: React.FC<WorkspaceDefinitionListProps> = ({ workspaces }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need this component? Is this not just the same component as the WorkspaceResourceLinkList with less bells and whistles? I think they both will render a div list 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, the two components need different set of props to function. They also render lists based out of different types of objects.
There is also a need of certain additional mandatory props in ResourceLinkList which will not be required in DefinitionList

selector: { matchLabels: labels },
});

if (loaded && !loadError && pvcResource?.metadata) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: for readability, you typically want to return nulls early so that the proper render is always at the bottom. It obv doesn't impact the flow, but it helps to be consistent in a codebase this large.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the suggestion. Updated :)

Comment on lines 18 to 27
const [pvcResource, loaded, loadError] = useK8sWatchResource<K8sResourceKind>({
kind: PersistentVolumeClaimModel.kind,
isList: false,
selector: { matchLabels: labels },
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you also need to look at the owner field 🤔

Otherwise you're going to fetch the first PVC that matches a label and it's a coin flip if you get the one you want.

Suggested new path:

  • Fetch all PVCs that match the label
  • Look at the metadata.ownerReferences and trim down to the PLR / TR that matches
  • List only the remaining PVCs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated with this logic and also added tests

Comment on lines 37 to 38
expect(WorkspaceDefinitionListWrapper.find('dd').exists()).toBe(true);
expect(WorkspaceDefinitionListWrapper.find('dt').exists()).toBe(true);
Copy link
Contributor

@christianvogt christianvogt Feb 25, 2021

Choose a reason for hiding this comment

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

Testing static markup here makes the test very fragile to component changes. You can omit these tag present assertions.

To test the condition that the component renders null or something, you can perform an exists check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

export const getMatchedPVCs: GetMatchedPVCs = (pvcResources, ownerReference) => {
return pvcResources.filter((pvc) => {
const { ownerReferences } = pvc.metadata;
return ownerReferences.find((reference) => reference.name === ownerReference);
Copy link
Contributor

Choose a reason for hiding this comment

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

metadata.ownerReferences is an optional field, If you call this function with a PVC without ownerReferences chances are this will throw a error in console, so add an empty array as a fallback value and you could also add test for the same.

Copy link
Contributor

Choose a reason for hiding this comment

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

Does the owner reference not include a kind/type as well? 🤔

example PLR name for instance could match another resource very easily.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated. checking Kind as well, doing a null check and added tests

WorkspaceResourceLinkListProps,
} from '../WorkspaceResourceLinkList';
import { taskRunWithWorkspaces } from '../../../taskruns/__tests__/taskrun-test-data';
import { SecretModel, PersistentVolumeClaimModel, ConfigMapModel } from '@console/internal/models';
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: sort imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@karthikjeeyar
Copy link
Contributor

Verified locally, works fine. We need to match the Empty directory scenario once we have the design for it in a different story.
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2021
Copy link
Contributor

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

/lgtm cancel

I see a couple issues that will generate bugs if we leave them.

  1. You make labels required for the fetching of the volumeClaimTemplate PVCs... which is not valid since a user could create a PLR without labels and it breaks down immediately.
  2. The fetching on the PLRs today will cause duplicates in references as each workspace can render n-number of PVC links based on the number of volumeClaimTemplate workspaces there are. Ie, if I have two volumeClaimTemplates, you'll get 2 PVC links for each workspace:
    image

I started a conversation with Tekton on how we could use PLRs to properly fetch them, an oversight I did not see when reviewing the designs / story -- my apologizes. They think it's a bug upstream that we don't have these values on the PLR, so this may not be fixable today -- at least not directly.

I think our best option to avoid the duplicate links is to actually go through the TRs to get the values today. We may need to fix this later if the upstream code can support PLRs knowing their PVCs that get created from volumeClaimTemplates.

Suggested path to fix (WDYT): see history if you want to see my message -- we don't want this as there is a bug upstream

Comment on lines 447 to 452
type GetMatchedPVCs = (
pvcResources: PersistentVolumeClaimKind[],
ownerReference: string,
) => PersistentVolumeClaimKind[];

export const getMatchedPVCs: GetMatchedPVCs = (pvcResources, ownerReference) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Typically when you're tying a function it's for when you want to make multiple functions of the same signature (like an interface)... Not that it matters a ton, but ideally gravitate towards direct types as it's easier to read.

return pvcResources.filter((pvc) => {
const { ownerReferences = [] } = pvc.metadata;

return ownerReferences.find(
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
return ownerReferences.find(
return ownerReferences.some(

Filter takes a boolean result and you don't actually need the item.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

<WorkspaceResourceLinkList
workspaces={taskRun.spec.workspaces}
namespace={taskRun.metadata.namespace}
ownerReference={taskRun.metadata.name}
Copy link
Contributor

Choose a reason for hiding this comment

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

Aside from ownerReference not really speaking to the name of the prop... more like resourceName or ownerResourceName imo. But from this flow, TaskRun, you compare PipelineRun model to the owner reference.


if (!ownerReference) return null;

if (loaded && !loadError && pvcResources?.length > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is a nit, but you really should return early with nulls.

Ideally you code up your component like so:

() => {
  if ...
    return null
  if ...
    return null

  if ...
    return <small rendering> // ie. an Alert

  return <main rendering> // ie. the main purpose of the component
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Mar 2, 2021
Comment on lines 21 to 27
const [pvcResources, loaded, loadError] = useK8sWatchResource<PersistentVolumeClaimKind[]>({
kind: PersistentVolumeClaimModel.kind,
isList: true,
selector: { matchLabels: labels },
});
Copy link
Contributor

Choose a reason for hiding this comment

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

And you need to constrain this on namespace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added namespace

Comment on lines 22 to 25
workspaceDefinitionListWrapper = shallow(
<WorkspaceDefinitionList {...workspaceDefinitionListWrapperProps} />,
);
expect(workspaceDefinitionListWrapper.find('dl').exists()).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think based on Christian's response, we want this:

Suggested change
workspaceDefinitionListWrapper = shallow(
<WorkspaceDefinitionList {...workspaceDefinitionListWrapperProps} />,
);
expect(workspaceDefinitionListWrapper.find('dl').exists()).toBe(false);
workspaceDefinitionListWrapper = shallow(
<WorkspaceDefinitionList {...workspaceDefinitionListWrapperProps} />,
);
expect(workspaceDefinitionListWrapper.isEmptyRender()).toBe(true);

Ref: https://enzymejs.github.io/enzyme/docs/api/ShallowWrapper/isEmptyRender.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

<WorkspaceResourceLinkList {...workspaceResourceListWrapperProps} />,
);
expect(workspaceResourceListWrapper.find('dd').exists()).toBe(false);
expect(workspaceResourceListWrapper.find('dt').exists()).toBe(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll want to use .isEmptyRender here too... (and other places in this file)

@andrewballantyne
Copy link
Contributor

@abhinandan13jan As requested by @bgliwa01 on slack, please drop the (workspace-name) from all the relationships links.

Comment on lines 199 to 213
it('should return PVCs correctly matched with name and kind', () => {
const matchedPVCs = getMatchedPVCs(pvcWithPipelineOwnerRef, 'pipeline2', PipelineRunModel.kind);
expect(matchedPVCs.length).toBe(2);
expect(matchedPVCs[0].metadata.name).toBe(pvcWithPipelineOwnerRef[1].metadata.name);
expect(matchedPVCs[1].metadata.name).toBe(pvcWithPipelineOwnerRef[3].metadata.name);
});

it('should not match PVCs when ownerRef matches name but not kind', () => {
const matchedPVCs = getMatchedPVCs(pvcWithPipelineOwnerRef, 'pipeline2', PipelineRunModel.kind);
expect(matchedPVCs.length).toBe(2);
expect(matchedPVCs[0].metadata.name).toBe(pvcWithPipelineOwnerRef[1].metadata.name);
expect(matchedPVCs[1].metadata.name).toBe(pvcWithPipelineOwnerRef[3].metadata.name);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Same tests with different expectations? 😕

image

let workspaceResourceListWrapper: ShallowWrapper<WorkspaceResourceLinkListProps>;
let workspaceResourceListWrapperProps: WorkspaceResourceLinkListProps;

it('Should not render dd or dt heading if no workspaces are found', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good use case for not explaining the expected output, speak to the reason for the test.

it('should not render if there are no workspaces'

let workspaceDefinitionListWrapper: ShallowWrapper<WorkspaceDefinitionListProps>;
let workspaceDefinitionListWrapperProps: WorkspaceDefinitionListProps;

it('Should not render root dl if no workspaces are found', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

root dl?

<ResourceLink
name={pvcResource.metadata.name}
key={pvcResource.metadata.name}
namespace={namespace}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Technically this should be pvcResource.metadata.namespace -- the logic around this makes the two match but your namespace needs to be that of the pvcResource not of your PLR/TR

Comment on lines 74 to 95
return <div key={workspace.name}>{workspace.name}</div>;
})}
<VolumeClaimTemplatesLink
namespace={namespace}
ownerResourceName={ownerResourceName}
ownerResourceKind={ownerResourceKind}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

@abhinandan13jan Please test before you request a review... You are double rendering...

image

Or if you prefer, with my two volumeClaimTemplate example from before:
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My PLR YAML, completely missed it. I've updated and tested against these now. Thanks a ton for the check

Screenshot from 2021-03-04 02-48-29
Screenshot from 2021-03-04 02-49-04

@andrewballantyne
Copy link
Contributor

If you need access to my resources, I posted as part of the upstream request for them to add volumeClaimTemplate PVC names to the .status. See the upstream issue: tektoncd/pipeline#3800

Comment on lines 26 to 28
if (!ownerResourceName) return null;

if (!loaded || loadError || pvcResources?.length === 0) return null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (!ownerResourceName) return null;
if (!loaded || loadError || pvcResources?.length === 0) return null;
if (!ownerResourceName || !loaded || loadError || pvcResources?.length === 0) return null;


export interface TaskRunDetailsStatusProps {
taskRun: TaskRunKind;
}

const TaskRunDetailsStatus = ({ taskRun }) => {
const { t } = useTranslation();
const ownerReference = taskRun.metadata.ownerReferences?.[0] || taskRun.metadata.name;
Copy link
Contributor

Choose a reason for hiding this comment

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

taskRun.metadata.ownerReferences?.[0] This one is an object which is passed to ownerResourceName in WorkspaceResourceLinkList below. Shouldn't this be taskRun.metadata.ownerReferences?.[0].name ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thinking about this more, do we need this at all? TaskRun's ownerRef will be PipelineRun, but for ownerResourceKind is tied to taskrun.kind always, so it will never match 🤔 or am i missing something here?

ie:

   <WorkspaceResourceLinkList
        workspaces={taskRun.spec.workspaces}
        namespace={taskRun.metadata.namespace}
        ownerResourceName={ownerReference} // <PipelineRun-name> (if taskrun is NOT standalone)
        ownerResourceKind={taskRun.kind} // TaskRun
      />

Copy link
Contributor Author

@abhinandan13jan abhinandan13jan Mar 4, 2021

Choose a reason for hiding this comment

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

yes, u r correct. I misplaced the ownerReference. Updated now

      <WorkspaceResourceLinkList
        workspaces={taskRun.spec.workspaces}
        namespace={taskRun.metadata.namespace}
        ownerResourceName={ownerReference ? ownerReference.name : taskRun.metadata.name}
        ownerResourceKind={ownerReference ? ownerReference.kind : taskRun.kind}
      />

@karthikjeeyar
Copy link
Contributor

karthikjeeyar commented Mar 4, 2021

Workspace section is displayed without any list of workspaces for standalone Taskrun uses volumeClaimTemplate (failed due to errors). Used invalid taskRef name to reproduce this issue.

invalid_task_ref.yaml

kind: TaskRun                                                                                                                 
apiVersion: tekton.dev/v1beta1                                                                                                
metadata:                                                                                                                     
  name: test-run                                                                                                              
spec:                                                                                                                         
  taskRef:                                                                                                                    
    name: invalid-taskref-name                                                                                                               
  workspaces:                                                                                                                 
  - name: workspace                                                                                                           
    volumeClaimTemplate:                                                                                                      
      spec:                                                                                                                   
        accessModes:                                                                                                          
          - ReadWriteOnce                                                                                                     
        resources:                                                                                                            
          requests:                                                                                                           
            storage: 256M
            

image

@abhinandan13jan abhinandan13jan force-pushed the pipeline-workspaces branch 2 times, most recently from 7824f8d to 144625c Compare March 4, 2021 11:38
@karthikjeeyar
Copy link
Contributor

@abhinandan13jan You still need to fix the issue from my last comment. PTAL

Comment on lines 42 to 50
{matchedPVCs.map((pvcResource) => {
return (
<ResourceLink
name={pvcResource.metadata.name}
key={pvcResource.metadata.name}
namespace={pvcResource.metadata.namespace}
kind={PersistentVolumeClaimModel.kind}
/>
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of repeating this block twice, it would be nice if you could add it to a const and contidionally render it based on the showHeader.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@karthikjeeyar
Copy link
Contributor

Verified, everything else looks good apart from my last minor comment, I will add lgtm once that is fixed.

@debsmita1
Copy link
Contributor

@abhinandan13jan
Copy link
Contributor Author

I tried out this yaml https://github.com/tektoncd/pipeline/blob/master/examples/v1beta1/pipelineruns/workspace-from-volumeclaimtemplate.yaml

and I can see the same PVC listed twice
workspaces

@debsmita1 @karthikjeeyar @andrewballantyne This happens if we use pipelineRun as the ownerReference for taskRun, which I did because of a review comment. I've reverted that particular change and it works fine now.

@karthikjeeyar
Copy link
Contributor

Thanks for all the changes @abhinandan13jan
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 8, 2021
@debsmita1
Copy link
Contributor

works fine. Thanks !

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: abhinandan13jan, andrewballantyne, karthikjeeyar

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 9, 2021
@openshift-merge-robot openshift-merge-robot merged commit aaa4c6d into openshift:master Mar 9, 2021
@spadgett spadgett added this to the v4.8 milestone Mar 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. component/pipelines Related to pipelines-plugin kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants