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

Tekton hub integration #9771

Merged
merged 4 commits into from Aug 14, 2021

Conversation

karthikjeeyar
Copy link
Contributor

@karthikjeeyar karthikjeeyar commented Aug 10, 2021

Fixes:

https://issues.redhat.com/browse/ODC-6134
https://issues.redhat.com/browse/ODC-6135

Analysis / Root cause:
Integrate tektonHub tasks in the pipeline builder, where users can find/install and update a tekton hub tasks in a namespace.

Solution Description:

  1. Pull the tasks from tekton hub api endpoint and add it to the pipeline task catalog
  2. Install / update a tekton hub task to the namespace.
  3. Show the installing decorator when the API call is in progress.
  4. Added access review checks for the tekton hub CTA button.
  5. Update the limited permission flow to have only the installed tasks listed in the modal.

Todo:

  • Update the Alert message with finalized content (will be provided by UX)

Screen shots / Gifs for design review:

Add already Installed Task flow:

Add_existing_task

Install task flow:
installing_task

Update task flow:
updating_task

Installing and Delete Add task Decorators:
image (14)

Unit test coverage report:

Test setup:

pipeline-quicksearch-utils
    isSelectedVersionInstalled
      ✓ should return false when the attributes is not present in catalogItem (1ms)
      ✓ should return false when the selected version is not installed
      ✓ should return true when the selected version is installed (1ms)
    isTaskVersionInstalled
      ✓ should return false when the attributes is not present in catalogItem
      ✓ should return false when the installed attribute is not present in catalogItem (1ms)
      ✓ should return true when the installed attribute is set in catalogItem
    isOneVersionInstalled
      ✓ should return false when the attributes is not present in catalogItem (1ms)
      ✓ should return false when the none of the version is installed in the cluster
      ✓ should return true when the one version is installed in the cluster
    isSelectedVersionUpgradable
      ✓ should return false when the attributes is not present in catalogItem (1ms)
      ✓ should return false when the passed version is not upgradable
      ✓ should return false when the selected version is already installed in the cluster
      ✓ should return true when the selected version is upgradable in catalogItem (1ms)
    getTaskCtaType
      ✓ should return the Install button type for the uninstalled task
      ✓ should return the Add button type for the installed version
      ✓ should return the Upgrade button type if selected version is upgradable (1ms)
    isInstalledNamespaceTask
      ✓ should return false if the tekton hub task is passed
      ✓ should return false if the namespace task is not installed through pipeline builder
      ✓ should return true if the namespace task is installed through pipeline builder (1ms)
    isExternalTask
      ✓ should return true for the tekton hub task
      ✓ should return false if clusterTask and namespaceTask is passed
    isTaskSearchable
      ✓ should return true for all the tekton hub tasks are searchable (1ms)
      ✓ should return true for all the cluster and namespace tasks not added through pipeline builder
      ✓ should return false for all the namespace tasks added through pipeline builder
    getSelectedVersionUrl
      ✓ should return null if the attirbutes is not present in the catalogItem (1ms)
      ✓ should return the download url when the item and version id is passed
    findInstalledTask
      ✓ should return undefined the catalogItem is not installed through pipeline builder
      ✓ should return the installed Task resource through pipeline builder (1ms)

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

cc: @serenamarie125 @bgliwa01 @andrewballantyne

@openshift-ci openshift-ci bot added the component/dev-console Related to dev-console label Aug 10, 2021
@openshift-ci openshift-ci bot added component/pipelines Related to pipelines-plugin component/sdk Related to console-plugin-sdk component/shared Related to console-shared kind/i18n Indicates issue or PR relates to internationalization or has content that needs to be translated labels Aug 10, 2021
@@ -0,0 +1 @@
export const TEKTON_HUB_API_ENDPOINT = 'https://api.hub.tekton.dev';
Copy link
Member

Choose a reason for hiding this comment

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

isn't this endpoint id there within operator, so that we can read and could be dynamic

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Backend support for reading the endpoints is not there yet, so for now we are going with tektonhub API

}
} else {
resolve(savedCallback.current({ metadata: { name: item.data.name } }));
createTask(selectedVersionUrl, namespace).catch(() =>
Copy link
Member

Choose a reason for hiding this comment

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

no action needed on then here only on catch?

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, In case of successful task creation, the resources will be created and pulled in automatically by K8swatchers.

@karthikjeeyar karthikjeeyar force-pushed the tekton-hub-integration branch 2 times, most recently from 1ac673f to 040c056 Compare August 10, 2021 11:52
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.

Also we talked about the storage of the loading tasks, please make those changes as discussed.

}

const QuickSearchDetails: React.FC<QuickSearchDetailsProps> = ({ selectedItem, closeModal }) => {
const DefaultContent = ({ selectedItem, closeModal }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should type this with the props, it's a stand-alone function.

(props: QuickSearchDetailsRendererProps) => React.ReactNode maybe can be it's own type and we just reuse it here?

Also, maybe we make this lower case. It's not a component, it's a defaultContentRenderer. Perhaps the rename and go with camelCase as it's a function.

Comment on lines 47 to 48
React.useEffect(() => {
savedCallback.current = callback;
}, [callback]);
Copy link
Contributor

Choose a reason for hiding this comment

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

Just move this next to the useRef... you're just holding onto it and not doing any computation, no reason to use an effect.

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.

Couple other things...

Somehow the Sidebar styles got mucked up. I think it was in your previous PR (or another PR that I'm unaware of that touched the Pipeline Builder):
image

Also not sure how it happened... I was clicking around in the modal and I got this:
image
I also got a ton of "Failed to fetch" errors from the useTekonHubTasksProvider.tsx file.

Your implementation also is not what we discussed. I'm not sure if that's because it didn't work or because you misunderstood. I don't want to hold up your PR beyond this sprint, if you can fix the UID issue above and other issues I mentioned, we can merge this as-is.

Seek another review for the LGTM when you get a chance, hopefully we can merge this before EOD tomorrow.

Comment on lines +17 to +18
const tags = annotations[TektonTaskAnnotation.tags]?.split(/\s*,\s*/) || [];
const categories = annotations[TektonTaskAnnotation.categories]?.split(/\s*,\s*/) || [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I didn't see this before... but I wonder if we don't want to use parseJSONAnnotation... not sure if that's the goal of what you're trying to do or not.

I'm unsure what format these annotations are in...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

annotations are strings, could be comma separated, so splitting the string into array.

@@ -42,6 +42,7 @@ export type PipelineResult = {
};

export type PipelineTask = {
metadata?: { installing?: boolean };
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 no longer needed, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops, missed this spot.

@karthikjeeyar
Copy link
Contributor Author

Fixed TaskSidebar alignment issue caused by this removing bootstrap close styles commit 70a267f

Not able to reproduce the uid of undefined error, It seems like some flake happened in catalogServiceProvider while loading extensions.

I also got a ton of "Failed to fetch" errors from the useTekonHubTasksProvider.tsx file.

There were a lot of failures for /api/check-updates call, the errors are no longer appearing after building the backeend and re-sourcing it.


React.useEffect(() => {
const { loadingTasks } = values.formData;
loadingTasks.map((task) => {
Copy link
Member

Choose a reason for hiding this comment

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

nit: will forEach be a better fit here

Comment on lines 15 to 20
export const isTaskVersionInstalled = (item: CatalogItem): boolean => {
if (item.attributes?.installed) {
return item.attributes.installed !== '';
}
return false;
};
Copy link
Member

Choose a reason for hiding this comment

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

nit: can we have it like this?

Suggested change
export const isTaskVersionInstalled = (item: CatalogItem): boolean => {
if (item.attributes?.installed) {
return item.attributes.installed !== '';
}
return false;
};
export const isTaskVersionInstalled = (item: CatalogItem): boolean => !!item.attributes?.installed;

export const isInstalledNamespaceTask = (item: CatalogItem) => {
return (
item.data.kind === TaskModel.kind &&
item.data?.metadata?.annotations[TektonTaskAnnotation.installedFrom] === TEKTONHUB
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
item.data?.metadata?.annotations[TektonTaskAnnotation.installedFrom] === TEKTONHUB
item.data.metadata?.annotations[TektonTaskAnnotation.installedFrom] === TEKTONHUB

if (!item?.attributes?.versions) {
return null;
}
return item?.attributes?.versions.find((v) => v.id.toString() === version)?.rawURL;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
return item?.attributes?.versions.find((v) => v.id.toString() === version)?.rawURL;
return item.attributes.versions.find((v) => v.id.toString() === version)?.rawURL;

i.name === item.name &&
item.data.kind !== ClusterTaskModel.kind &&
i.data.kind === TaskModel.kind &&
i.data?.metadata?.annotations[TektonTaskAnnotation.installedFrom] === TEKTONHUB,
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@invincibleJai
Copy link
Member

/approve
/label qe-approved

Verified the changes, works as expected cc @andrewballantyne

@openshift-ci openshift-ci bot added qe-approved Signifies that QE has signed off on this PR approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Aug 12, 2021
@karthikjeeyar
Copy link
Contributor Author

/retest

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

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 12, 2021
@karthikjeeyar
Copy link
Contributor Author

Adding on behalf of the docs & px team as the Epic already contains the acks.
/label px-approved
/label docs-approved

@openshift-ci openshift-ci bot added px-approved Signifies that Product Support has signed off on this PR docs-approved Signifies that Docs has signed off on this PR needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 12, 2021
@openshift-ci openshift-ci bot removed lgtm Indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 13, 2021
@karthikjeeyar
Copy link
Contributor Author

Rebased the PR to resolve conflicts.

@invincibleJai
Copy link
Member

/lgtm

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 14, 2021
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Aug 14, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne, invincibleJai, 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 openshift-ci bot merged commit 0a20908 into openshift:master Aug 14, 2021
@spadgett spadgett added this to the v4.9 milestone Aug 30, 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/dev-console Related to dev-console component/pipelines Related to pipelines-plugin component/sdk Related to console-plugin-sdk component/shared Related to console-shared docs-approved Signifies that Docs has signed off on this PR 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. px-approved Signifies that Product Support has signed off on this PR qe-approved Signifies that QE has signed off on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants