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

remove hard coded model versions from kubevirt #9349

Conversation

glekner
Copy link
Contributor

@glekner glekner commented Jun 27, 2021

JIRA: https://issues.redhat.com/browse/CNV-12565

  • Removed the requirement of version in the YAML Template extension
  • Added modelForGroupKind method to find a model through API Discovery by group and kind only

@openshift-ci openshift-ci bot requested review from kyoto and spadgett June 27, 2021 11:09
@openshift-ci openshift-ci bot added component/core Related to console core functionality component/kubevirt Related to kubevirt-plugin component/sdk Related to console-plugin-sdk labels Jun 27, 2021
@glekner
Copy link
Contributor Author

glekner commented Jun 27, 2021

please review @christianvogt @vojtechszocs

@glekner
Copy link
Contributor Author

glekner commented Jun 27, 2021

/retest

@glekner glekner force-pushed the kubevirt-remove-hardcode-versions branch 2 times, most recently from 5503d58 to 70da810 Compare June 28, 2021 14:50
@glekner
Copy link
Contributor Author

glekner commented Jun 28, 2021

/retest

import { Extension, ExtensionDeclaration, CodeRef } from '../types';

/** YAML templates for editing resources via the yaml editor. */
export type YAMLTemplate = ExtensionDeclaration<
'console.yaml-template',
{
/** Model associated with the template. */
model: ExtensionK8sModel;
model: ExtensionK8sGroupKindModel;
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems odd to me that a yaml template isn't tied a version.

cc @spadgett

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not use the dynamic version which is available in the cluster?

Copy link
Member

Choose a reason for hiding this comment

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

why not use the dynamic version which is available in the cluster?

They're not API compatible. Different API versions need different YAML templates due to API differences.

The API version should be part of the model, though, right?

"/k8s/ns/:ns/kubevirt.io~v1~VirtualMachine/:name",
"/k8s/ns/:ns/kubevirt.io~v1alpha3~VirtualMachine/:name"
],
"path": ["/k8s/ns/:ns/virtualmachines/:name"],
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 for backwards compatibility?
All links in the app should be using the qualified reference

Copy link
Contributor Author

Choose a reason for hiding this comment

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

its only for backwards, there is no link that is using this url in the app.
some tests however need this url

Comment on lines 387 to 407
"kind": "VirtualMachine",
"version": "v1alpha3"
"kind": "VirtualMachine"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to contribute separate templates per version.
When we adopt typescript definitions of the console extensions, you can reuse the same function to generate the the yaml.

Comment on lines 89 to 90
export const modelForGroupKind = (group: string, kind: string): K8sKind => {
const models: ImmutableMap<string, K8sKind> = store.getState().k8s.getIn(['RESOURCES', 'models']);
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to avoid using the global redux store.

cc @vojtechszocs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

well Vojtech already approved this change so it got in inside #9355
would like to hear if there's another solution that is viable for both React and non-React context

Copy link
Contributor

Choose a reason for hiding this comment

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

If we need data from application's Redux store outside a React component, it should be OK to use store.getState().

I think @christianvogt is referring to the import store declaration which adds dependency on public/redux.ts module, we can refactor the code to avoid that static import if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the import store has been inside this file for over 4 years :)

Copy link
Contributor

Choose a reason for hiding this comment

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

No my comment was about the new use of store.getState().
I don't want to see more use cases that use the global store because it's bad practice.
Yes the import has been around a while now because removing these instances is difficult.

Copy link
Contributor Author

@glekner glekner Jul 12, 2021

Choose a reason for hiding this comment

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

If we need data from application's Redux store outside a React component, it should be OK to use store.getState()

@christianvogt I see no other way here when dealing with contexts that are out of React.
Can you explain what are your concerns here? other than the fact it doesn't look nice

@glekner glekner force-pushed the kubevirt-remove-hardcode-versions branch from 70da810 to bb0e506 Compare June 29, 2021 10:35
@openshift-ci openshift-ci bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2021
@glekner glekner force-pushed the kubevirt-remove-hardcode-versions branch from bb0e506 to a54479f Compare July 11, 2021 09:46
@openshift-ci openshift-ci bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jul 11, 2021
@glekner glekner force-pushed the kubevirt-remove-hardcode-versions branch from a54479f to b959042 Compare July 11, 2021 09:48
@glekner glekner force-pushed the kubevirt-remove-hardcode-versions branch from b959042 to 8a1180d Compare July 13, 2021 11:24
@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 13, 2021
@glekner
Copy link
Contributor Author

glekner commented Jul 13, 2021

@christianvogt @spadgett reverted yaml templates changes

@christianvogt
Copy link
Contributor

/lgtm

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

openshift-ci bot commented Jul 13, 2021

[APPROVALNOTIFIER] This PR is APPROVED

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

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-merge-robot openshift-merge-robot merged commit 8819398 into openshift:master Jul 14, 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/core Related to console core functionality component/kubevirt Related to kubevirt-plugin component/sdk Related to console-plugin-sdk lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants