Skip to content

Conversation

@pcbailey
Copy link
Contributor

This PR fixes the content and structure of the configurations created by using the network attachment definitions form. Example configurations created using the form are below. This PR also fixes an issue where the user was redirected to the wrong URL after successfully creating a network attachment definition via YAML.

Bridge:

apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  annotations:
    k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/br0
  creationTimestamp: '2019-10-31T12:16:06Z'
  generation: 1
  name: test-bridge
  namespace: rhodes-test
  resourceVersion: '769456'
  selfLink: >-
    /apis/k8s.cni.cncf.io/v1/namespaces/rhodes-test/network-attachment-definitions/test-bridge
  uid: 373e5ba7-fbd8-11e9-bfee-525400f2bdf7
spec:
  config: >-
    {"name":"test-bridge","type":"cnv-bridge","cniVersion":"0.3.1","plugins":[{"type":"cnv-bridge","bridge":"br0","vlan":"100","ipam":{}},{"type":"cnv-tuning"}]}

SR-IOV:

apiVersion: k8s.cni.cncf.io/v1
kind: NetworkAttachmentDefinition
metadata:
  annotations:
    k8s.v1.cni.cncf.io/resourceName: bridge.network.kubevirt.io/sriov_net
  creationTimestamp: '2019-10-31T12:16:36Z'
  generation: 1
  name: test-sriov
  namespace: rhodes-test
  resourceVersion: '769807'
  selfLink: >-
    /apis/k8s.cni.cncf.io/v1/namespaces/rhodes-test/network-attachment-definitions/test-sriov
  uid: 48a611f4-fbd8-11e9-bfee-525400f2bdf7
spec:
  config: '{"name":"test-sriov","type":"sriov","cniVersion":"0.3.1","ipam":{}}'``` 

@phoracek 

@openshift-ci-robot openshift-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Oct 31, 2019
@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 31, 2019
@pcbailey pcbailey force-pushed the fix-configs-and-yaml-creation-redirect branch from 55d79e4 to e2a9a43 Compare November 1, 2019 01:08
@pcbailey
Copy link
Contributor Author

pcbailey commented Nov 1, 2019

/retest

Copy link
Contributor

@mareklibra mareklibra left a comment

Choose a reason for hiding this comment

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

In addition to my comments above, please add typescript, i.e. NetworkAttachmentDefinitionFormBase, NetworkTypeOptions, createNetAttachDef and others.

try {
ipam = JSON.parse(_.get(typeParamsData, 'ipam.value', {}));
} catch (e) {
console.log(e); // eslint-disable-line no-console
Copy link
Contributor

Choose a reason for hiding this comment

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

The user should be informed about unexpected format of data, the console logging is just optional way to handle that state.

In any case, the log message should be at least info level and provide additional info about context for debugging.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Very good points. I'll address this in a follow-up.

const vlan = _.get(typeParamsData, 'vlanTagNum.value', '');
config.plugins = [
{
type: 'cnv-bridge',
Copy link
Contributor

Choose a reason for hiding this comment

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

repeating string, worth of a constant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. This will be addressed in a follow-up.

},
{ type: 'cnv-tuning' },
];
} else if (networkType === 'sriov') {
Copy link
Contributor

Choose a reason for hiding this comment

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

likewise here
Please check other similar occurrences.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. This will be addressed in a follow-up.

@phoracek
Copy link
Member

phoracek commented Nov 1, 2019

Can't comment on the code, but the output looks fine.

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: pcbailey, phoracek

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

The pull request process is described here

Details 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

@pcbailey
Copy link
Contributor Author

pcbailey commented Nov 1, 2019

This commit was included in #3183. Closing this PR.

@pcbailey pcbailey closed this Nov 1, 2019
@pcbailey pcbailey deleted the fix-configs-and-yaml-creation-redirect branch October 26, 2022 12:32
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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants