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 dynamic sdk support for topology extensions #9055

Merged
merged 1 commit into from
Jun 21, 2021

Conversation

glekner
Copy link
Contributor

@glekner glekner commented May 26, 2021

No description provided.

@openshift-ci openshift-ci bot added component/sdk Related to console-plugin-sdk component/topology Related to topology labels May 26, 2021
@glekner
Copy link
Contributor Author

glekner commented May 27, 2021

/retest

@glekner glekner force-pushed the dp-sdk-topology branch 2 times, most recently from 9ea76ea to 29a39e2 Compare May 31, 2021 08:59
Comment on lines 143 to 147
const componentFactoryExtensions = useExtensions<TopologyComponentFactory>(
isTopologyComponentFactory,
);
const [dynamicComponentFactoryExtensions, isFactoryComponentsResolved] = useResolvedExtensions<
DynamicTopologyComponentFactory
>(isDynamicTopologyComponentFactory);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move away from useExtensions for the old extension and make use of useResolvedExtensions?
Then combine the results two variables: one for the resolved state and one for an array of factories.

This way it'll be two code paths for setup but consumption will be simple.

.catch(() => {});
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [componentFactoriesPromises, isFactoryComponentsResolved]);

React.useEffect(() => {
if (componentFactoriesPromises.length && !componentFactories.length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you've separated the static and dynamic extensions into different variables, this check is no longer valid as it only applies to one.

See other comment about using useResolvedExtensions for both static and dynamic plugins.

Comment on lines 25 to 29
const modelFactories = useExtensions<TopologyDataModelFactory>(isTopologyDataModelFactory);
const [dynamicModelFactories, isModelResolved] = useResolvedExtensions<
DynamicTopologyDataModelFactory
>(isDynamicTopologyDataModelFactory);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can both paths use useResolvedExtensions so that we don't have one path doing manual resolution.

Comment on lines 47 to 56
const modelFactories = useExtensions<TopologyDataModelFactory>(isTopologyDataModelFactory);
const [dynamicModelFactories] = useResolvedExtensions<DynamicTopologyDataModelFactory>(
isDynamicTopologyDataModelFactory,
);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we update the static extension to make use of CodeRef then simplified the resolution with useResolvedExtensions

We probably don't want to render the firehose component until all extensions have been resolved.

@openshift-ci openshift-ci bot added component/helm Related to helm-plugin component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/pipelines Related to pipelines-plugin labels Jun 1, 2021
@glekner
Copy link
Contributor Author

glekner commented Jun 1, 2021

@christianvogt modified extensions, now consuming all with useResolvedExtensions

Copy link
Contributor

@christianvogt christianvogt left a comment

Choose a reason for hiding this comment

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

Operator backed services aren't showing up correctly. Use the dev catalog
Before:
image

After:
image

There's also flashing of the old value when switching from one namespace to another.

@@ -35,3 +36,14 @@ export const applyHelmDisplayOptions = (model: Model, filters: DisplayFilters):
};

export const applyDisplayOptions = () => applyHelmDisplayOptions;

export const getHelmWatchedResources = (namespace: string): WatchK8sResources<any> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was this moved to a filters module?

@@ -19,3 +22,16 @@ export const getCreateConnector = (createHints: string[], source: Node, target:
}
return null;
};

export const getRhoasWatchedResources = (
Copy link
Contributor

Choose a reason for hiding this comment

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

Moving to createConnector doesn't seem like a logical home.

@@ -35,3 +39,25 @@ export const applyOperatorDisplayOptions = (model: Model, filters: DisplayFilter
};

export const applyDisplayOptions = () => applyOperatorDisplayOptions;

export const getOperatorWatchedResources = (namespace: string): WatchK8sResources<any> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about location.

@christianvogt
Copy link
Contributor

Display filters are missing:

Before:
image

After:
image

@christianvogt
Copy link
Contributor

Knative service, helm chart and channel:

Before:
image

After (channel doesn't show up):
image

@christianvogt
Copy link
Contributor

@glekner the latest changes fixed the missing visuals.

One outstanding issue remains. Flashing of the old value when switching from one namespace to another.
In the following gif, the visual of the operator backed service disappears when we change namespaces (expected), then then reappears (unexpected) before the proper topology for the new namespace is displayed.

topology-flash

@glekner
Copy link
Contributor Author

glekner commented Jun 6, 2021

hey again,
the flashing is fixed by reverting ModelFactory to use useExtensions.
since you can’t pass a function without a CodeRef for the dynamic extensions, instead we are passing the resources that need to be watched, and we build a function for them in the consuming of the extensions. please review @christianvogt

@glekner
Copy link
Contributor Author

glekner commented Jun 6, 2021

/test e2e-gcp-console


@glekner
Copy link
Contributor Author

glekner commented Jun 7, 2021

/retest

@rohitkrai03
Copy link
Contributor

/cc @rohitkrai03

@openshift-ci openshift-ci bot requested a review from rohitkrai03 June 9, 2021 11:10
@glekner
Copy link
Contributor Author

glekner commented Jun 9, 2021

/retest

@@ -88,7 +88,7 @@ export const isTopologyCreateConnector = (e: Extension): e is TopologyCreateConn
export const isTopologyDataModelFactory = (e: Extension): e is TopologyDataModelFactory =>
e.type === 'console.topology/data/factory';

export const isTopologyDisplayFilters = (e: Extension): e is TopologyDisplayFilters =>
export const isTopologyDisplayFilter = (e: Extension): e is TopologyDisplayFilters =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to match the static extension

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I guess it was a typo in the static extensions. But we can keep it like this for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest changing the old static one instead of the new. That being said we will end up revisiting these extensiioons.

@@ -56,7 +69,9 @@ const ApplicationDropdown: React.FC<ApplicationDropdownProps> = ({ namespace, ..
...watchedBaseResources[key],
prop: key,
}));
}, [modelFactories, namespace]);

return [];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this needed? Its unreachable.

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, removed

@@ -39,7 +39,7 @@ export type TopologyDataModelFactory = ExtensionDeclaration<
/** Priority for the factory */
priority: number;
/** Resources to be fetched from useK8sWatchResources hook. */
resources?: CodeRef<(namespace: string) => WatchK8sResources<any>>;
resources?: WatchK8sResources<any>;
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 not need namespaced resources anymore?

Copy link
Contributor Author

@glekner glekner Jun 9, 2021

Choose a reason for hiding this comment

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

since you cant set a function without a CodeRef, i'm building the namespaced resources here
https://github.com/openshift/console/pull/9055/files#diff-281f5462e39247e7a7894ee5ad688563cf18b46d97e7707da0b660b79c236f41R17

Copy link
Contributor

Choose a reason for hiding this comment

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

So why not make it a coderef?

Copy link
Contributor

Choose a reason for hiding this comment

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

I talked to @glekner about this too. I don't see an issue with this change unless the extension wants to hard code a namespace. In which case we can make sure to not set the namespace if one is already provided.

I don't think we have such a use case at this time that will be negatively affected by this.

Note that we still need to review the topology extensions for their exposed API and at that time may change things.

@glekner glekner force-pushed the dp-sdk-topology branch 2 times, most recently from 827c8f3 to 70a6fb9 Compare June 11, 2021 21:09
@glekner
Copy link
Contributor Author

glekner commented Jun 13, 2021

/retest

@glekner
Copy link
Contributor Author

glekner commented Jun 14, 2021

/test e2e-gcp-console

@glekner glekner force-pushed the dp-sdk-topology branch 2 times, most recently from 5fafe6b to 6f5f9f9 Compare June 16, 2021 10:12
@glekner
Copy link
Contributor Author

glekner commented Jun 16, 2021

/test frontend

@glekner
Copy link
Contributor Author

glekner commented Jun 16, 2021

/test e2e-gcp-console

@glekner
Copy link
Contributor Author

glekner commented Jun 16, 2021

/retest

@glekner
Copy link
Contributor Author

glekner commented Jun 17, 2021

/test kubevirt-plugin

1 similar comment
@glekner
Copy link
Contributor Author

glekner commented Jun 17, 2021

/test kubevirt-plugin

@glekner
Copy link
Contributor Author

glekner commented Jun 18, 2021

/retest

@@ -88,7 +88,7 @@ export const isTopologyCreateConnector = (e: Extension): e is TopologyCreateConn
export const isTopologyDataModelFactory = (e: Extension): e is TopologyDataModelFactory =>
e.type === 'console.topology/data/factory';

export const isTopologyDisplayFilters = (e: Extension): e is TopologyDisplayFilters =>
export const isTopologyDisplayFilter = (e: Extension): e is TopologyDisplayFilters =>
Copy link
Contributor

Choose a reason for hiding this comment

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

I suggest changing the old static one instead of the new. That being said we will end up revisiting these extensiioons.

Object.assign(
{},
...Object.entries(properties.resources).map(([k, v]) => ({
[k]: { ...v, namespace: ns },
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 probably accept the namespace provided before overriding? Not sure we have a use case for this yet but if an extension wanted to pull resources from a specific namespace we'd have to do:

Suggested change
[k]: { ...v, namespace: ns },
[k]: { namespace: ns, ...v },

@rohitkrai03
Copy link
Contributor

/assign @rohitkrai03

Copy link
Contributor

@rohitkrai03 rohitkrai03 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

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

openshift-ci bot commented Jun 21, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: glekner, rohitkrai03

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 added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jun 21, 2021
@openshift-merge-robot openshift-merge-robot merged commit b3606c9 into openshift:master Jun 21, 2021
@spadgett spadgett added this to the v4.9 milestone Jul 14, 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/helm Related to helm-plugin component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/pipelines Related to pipelines-plugin component/sdk Related to console-plugin-sdk component/topology Related to topology lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants