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

Sync data between Create Operand YAML and Form #3894

Merged
merged 1 commit into from Jan 29, 2020

Conversation

TheRealJon
Copy link
Member

@TheRealJon TheRealJon commented Jan 8, 2020

Sync data between yaml and form editors in the create operand workflow. Also fix visual issue where field group names overlap left blue border. It appears that the implementation of the blue border on patternfly accordions changed at some point and our css to override those styles was no longer working as expected.

Also update olm descriptor integration tests to delete the test operand between testing list/details views and creation form. There was previously no cleanup between these tests, which was causing a failure when attempting to create a new operand during the latter steps.

video-convert

@openshift-ci-robot openshift-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 8, 2020
@openshift-ci-robot openshift-ci-robot added component/core Related to console core functionality component/olm Related to OLM labels Jan 8, 2020
@TheRealJon
Copy link
Member Author

/retest

@openshift-ci-robot openshift-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 23, 2020
@TheRealJon TheRealJon changed the title [WIP] Sync data between Create Operand YAML and Form Sync data between Create Operand YAML and Form Jan 23, 2020
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 23, 2020
@TheRealJon
Copy link
Member Author

@benjaminapetersen @spadgett This is ready for review.

Copy link
Member

@spadgett spadgett left a comment

Choose a reason for hiding this comment

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

/approve
/lgtm

Nice work on this. It would be good to switch to optional chaining while changing the code, but since this was in existing code, I don't want to hold up the PR.

],
.map((field) => {
const capabilities = field.capabilities || [];
const openAPIProperties = _.get(openAPI, 'properties.spec.properties');
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
const openAPIProperties = _.get(openAPI, 'properties.spec.properties');
const openAPIProperties = openAPI?.properties?.spec?.properties;


const [formValues, setFormValues] = React.useState<FormValues>({
'metadata.name': 'example',
'metadata.labels': [],
'metadata.name': _.get(sample, 'metadata.name', 'example'),
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
'metadata.name': _.get(sample, 'metadata.name', 'example'),
'metadata.name': sample?.metadata?.name || 'example',

'metadata.name': 'example',
'metadata.labels': [],
'metadata.name': _.get(sample, 'metadata.name', 'example'),
'metadata.labels': SelectorInput.arrayify(_.get(sample, 'metadata.labels')) || [],
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
'metadata.labels': SelectorInput.arrayify(_.get(sample, 'metadata.labels')) || [],
'metadata.labels': SelectorInput.arrayify(sample?.metadata?.labels) || [],

},
spec: _.reduce(
specValues,
(spec, value, path) => _.set(spec, path, value),
_.get(props.sample, 'spec', {}),
_.get(sample, 'spec', {}),
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
_.get(sample, 'spec', {}),
sample?.spec || {},

name: formValues['metadata.name'],
labels: SelectorInput.objectify(
formValues['metadata.labels'],
) as ObjectMetadata['labels'],
annotations: _.get(props.sample, 'metadata.annotations', {}),
annotations: _.get(sample, 'metadata.annotations', {}),
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
annotations: _.get(sample, 'metadata.annotations', {}),
annotations: sample?.metadata?.annotations || {},

icon={_.get(props.clusterServiceVersion, 'spec.icon[0]')}
provider={_.get(props.clusterServiceVersion, 'spec.provider')}
displayName={providedAPI.displayName}
icon={_.get(clusterServiceVersion, 'spec.icon[0]')}
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
icon={_.get(clusterServiceVersion, 'spec.icon[0]')}
icon={clusterServiceVersion?.spec?.icon?.[0]}

provider={_.get(props.clusterServiceVersion, 'spec.provider')}
displayName={providedAPI.displayName}
icon={_.get(clusterServiceVersion, 'spec.icon[0]')}
provider={_.get(clusterServiceVersion, 'spec.provider')}
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
provider={_.get(clusterServiceVersion, 'spec.provider')}
provider={clusterServiceVersion?.spec?.provider}

operandModel,
}) => {
const { data: csv } = clusterServiceVersion;
const csvAnnotations = _.get(csv, 'metadata.annotations', {});
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
const csvAnnotations = _.get(csv, 'metadata.annotations', {});
const csvAnnotations = csv?.metadata?.annotations || {};


const defaultSample = React.useMemo<K8sResourceKind>(
() =>
JSON.parse(_.get(csvAnnotations, annotationKey, '[]')).find(
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
JSON.parse(_.get(csvAnnotations, annotationKey, '[]')).find(
JSON.parse(csvAnnotations?.[annotationKey] || '[]').find(

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 23, 2020
@TheRealJon
Copy link
Member Author

Nice work on this. It would be good to switch to optional chaining while changing the code, but since this was in existing code, I don't want to hold up the PR.

@spadgett I did consider converting to optional chaining in a lot of those places. Decided against it to keep my changes to a minimum. Clearly worked out in my favor with the size of this PR 😆

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

6 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@spadgett
Copy link
Member

/lgtm cancel

Runtime error in crud scenario

[SEVERE] https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js 117:71742 TypeError: l is not a function
    at t.<anonymous> (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/12-chunk-2b438f585f40935147f6.min.js:1:16172)
    at Ro (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:118:45996)
    at Ho (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:118:45733)
    at https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:118:95064
    at e.unstable_runWithPriority (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:126:3878)
    at so (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:118:41488)
    at Bc (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:118:90936)
    at Tc (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:118:79608)
    at https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:118:41759
    at e.unstable_runWithPriority (https://console-openshift-console.apps.ci-op-hl469dws-75d12.origin-ci-int-gce.dev.openshift.com/static/vendors~main-chunk-f13f313b764870d9c578.min.js:126:3878)

@openshift-ci-robot openshift-ci-robot removed lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Jan 24, 2020
@spadgett
Copy link
Member

/hold cancel

@openshift-ci-robot openshift-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 27, 2020
@TheRealJon
Copy link
Member Author

@spadgett It looks like the olm test was the problem. Looking at https://github.com/openshift/console/blob/006516745042a2d99f65f70ca9eded19a0600f9a/frontend/packages/operator-lifecycle-manager/integration-tests/scenarios/descriptors.scenario.ts#L348-L350p

A new operand is created at the beginning of that test scenario but is not cleaned up until after all of the test cases run. We check the list and details pages, then move on to the operand creation form, where we try to create a new operand using the form. This step was failing because it is trying to create a duplicate operand. Not sure why or how we weren't failing on this before now.

@@ -314,98 +335,114 @@ export const CreateOperandForm: React.FC<CreateOperandFormProps> = (props) => {
};

const [formValues, setFormValues] = React.useState<FormValues>({
'metadata.name': 'example',
'metadata.labels': [],
'metadata.name': _.get(sample, 'metadata.name', 'example'),
Copy link
Member Author

Choose a reason for hiding this comment

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

This line is what was causing the integration test failure. Previously, metadata.name was not synced from the YAML view and just defaulted to 'example', so when the integration tests created a new operand using the form, it didn't conflict with the existing one. Now that data is synced, the metadata.name field from the YAML view is carried over to the form view and conflicts with the existing resource.

Copy link
Member Author

Choose a reason for hiding this comment

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

@benjaminapetersen @spadgett I guess an easier solution to this failure would be to add a step to change the operand name before we create it via the form. But... since deleting and recreating it seems to work just fine (and adds a little bit more coverage), we might as well just leave it. Any objections or thoughts?

@benjaminapetersen
Copy link
Contributor

/retest

@benjaminapetersen
Copy link
Contributor

/hold

nevermind, CI is broken.

@openshift-ci-robot openshift-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 28, 2020
@spadgett
Copy link
Member

/lgtm
/hold cancel

@openshift-ci-robot openshift-ci-robot added lgtm Indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Jan 28, 2020
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: benjaminapetersen, spadgett, TheRealJon

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

@TheRealJon
Copy link
Member Author

/retest

5 similar comments
@TheRealJon
Copy link
Member Author

/retest

@TheRealJon
Copy link
Member Author

/retest

@TheRealJon
Copy link
Member Author

/retest

@TheRealJon
Copy link
Member Author

/retest

@TheRealJon
Copy link
Member Author

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@TheRealJon
Copy link
Member Author

/retest

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

2 similar comments
@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-bot
Copy link
Contributor

/retest

Please review the full test history for this PR and help us cut down flakes.

@openshift-merge-robot openshift-merge-robot merged commit 72b67ed into openshift:master Jan 29, 2020
@spadgett spadgett added this to the v4.4 milestone Feb 4, 2020
@TheRealJon TheRealJon deleted the 1965-console branch January 28, 2022 14:26
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/olm Related to OLM lgtm Indicates that a PR is ready to be merged. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants