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

Bug 1797766: Resource Requirements" specDescriptor fields - CPU and Memory injects empty string YAML editor #5525

Conversation

cyril-ui-developer
Copy link
Contributor

@cyril-ui-developer cyril-ui-developer commented May 21, 2020

/assign @TheRealJon
/cc @spadgett

@openshift-ci-robot openshift-ci-robot added the bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. label May 21, 2020
@openshift-ci-robot
Copy link
Contributor

@cyril-ui-developer: This pull request references Bugzilla bug 1797766, which is valid. The bug has been moved to the POST state. The bug has been updated to refer to the pull request using the external bug tracker.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.5.0) matches configured target release for branch (4.5.0)
  • bug is in the state ASSIGNED, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1797766: Resource Requirements" specDescriptor fields - CPU and Memory injects empty string YAML editor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@openshift-ci-robot openshift-ci-robot added bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/olm Related to OLM labels May 21, 2020
const [memory, setMemory] = React.useState<string>(
_.get(obj.spec, `${path}.${type}.memory`, ''),
);
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`));
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 a candidate for the typescript syntax instead? obj.spec?.path?.type?.cpu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this a candidate for the typescript syntax instead? obj.spec?.path?.type?.cpu

@benjaminapetersen path and type are string values to construct a valid path to the obj. Tried optional chaining in past here and got lint error. Trying it now seems to be happy. Investigating what was the issue in the past. Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an issue with using optional chaining here. I think it is because the path, and type are just string value, although I'm investigating it. When I console.log the value for optional chaining, I got undefined:

_.get(obj.spec, ${path}.${type}.cpu) 33
obj.spec?.path?.type?.cpu undefined

@spadgett
Copy link
Member

@TheRealJon PTAL
@cyril-ui-developer Sorry, needs rebase :/

@cyril-ui-developer cyril-ui-developer force-pushed the resource-reqts-spec-desc-fields-cpu-memory-injects-empty-str-yaml branch from 21eb4a3 to fbe8b54 Compare August 20, 2020 13:11
@cyril-ui-developer
Copy link
Contributor Author

@spadgett Rebased. Thanks

@cyril-ui-developer cyril-ui-developer force-pushed the resource-reqts-spec-desc-fields-cpu-memory-injects-empty-str-yaml branch from fbe8b54 to 7280d92 Compare September 2, 2020 13:50
@cyril-ui-developer cyril-ui-developer force-pushed the resource-reqts-spec-desc-fields-cpu-memory-injects-empty-str-yaml branch from 7280d92 to 9415612 Compare September 11, 2020 13:05
@cyril-ui-developer
Copy link
Contributor Author

@spadgett Just rebase this PR -#5525 again. Please take a look when you have a chance. Thanks

@openshift-ci-robot
Copy link
Contributor

@cyril-ui-developer: This pull request references Bugzilla bug 1797766, which is valid.

3 validation(s) were run on this bug
  • bug is open, matching expected state (open)
  • bug target release (4.7.0) matches configured target release for branch (4.7.0)
  • bug is in the state POST, which is one of the valid states (NEW, ASSIGNED, ON_DEV, POST, POST)

In response to this:

Bug 1797766: Resource Requirements" specDescriptor fields - CPU and Memory injects empty string YAML editor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Copy link
Member

@TheRealJon TheRealJon left a comment

Choose a reason for hiding this comment

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

This is untested, but I would think something like this would work:

const submit = (e) => {
  e.preventDefault();
  const newObj =
    cpu || memory || storage
      ? _.set(_.cloneDeep(obj), `spec.${path}.${type}`, {
          ...(cpu && { cpu }),
          ...(memory && { memory }),
          ...(storage && { 'ephemeral-storage': storage }),
        })
      : obj;
  return props.handlePromise(k8sUpdate(model, newObj), props.close);
};

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Jan 29, 2021

@cyril-ui-developer: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/kubevirt-plugin 9415612 link /test kubevirt-plugin
ci/prow/ceph-storage-plugin 9415612 link /test ceph-storage-plugin

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

@cyril-ui-developer cyril-ui-developer force-pushed the resource-reqts-spec-desc-fields-cpu-memory-injects-empty-str-yaml branch from 9415612 to e336f49 Compare February 2, 2021 12:32
Copy link
Contributor Author

@cyril-ui-developer cyril-ui-developer left a comment

Choose a reason for hiding this comment

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

This is untested, but I would think something like this would work:

const submit = (e) => {
  e.preventDefault();
  const newObj =
    cpu || memory || storage
      ? _.set(_.cloneDeep(obj), `spec.${path}.${type}`, {
          ...(cpu && { cpu }),
          ...(memory && { memory }),
          ...(storage && { 'ephemeral-storage': storage }),
        })
      : obj;
  return props.handlePromise(k8sUpdate(model, newObj), props.close);
};

@TheRealJon Looks cleaner! Works with small tweak.
PTAL. Thanks

const [memory, setMemory] = React.useState<string>(
_.get(obj.spec, `${path}.${type}.memory`, ''),
);
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this a candidate for the typescript syntax instead? obj.spec?.path?.type?.cpu

@benjaminapetersen path and type are string values to construct a valid path to the obj. Tried optional chaining in past here and got lint error. Trying it now seems to be happy. Investigating what was the issue in the past. Thanks

const [memory, setMemory] = React.useState<string>(
_.get(obj.spec, `${path}.${type}.memory`, ''),
);
const [cpu, setCPU] = React.useState<string>(_.get(obj.spec, `${path}.${type}.cpu`));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is an issue with using optional chaining here. I think it is because the path, and type are just string value, although I'm investigating it. When I console.log the value for optional chaining, I got undefined:

_.get(obj.spec, ${path}.${type}.cpu) 33
obj.spec?.path?.type?.cpu undefined

@TheRealJon TheRealJon self-requested a review February 3, 2021 18:45
Copy link
Member

@TheRealJon TheRealJon 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-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 3, 2021
@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cyril-ui-developer, 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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 3, 2021
@openshift-merge-robot openshift-merge-robot merged commit 4d6253e into openshift:master Feb 3, 2021
@openshift-ci-robot
Copy link
Contributor

@cyril-ui-developer: All pull requests linked via external trackers have merged:

Bugzilla bug 1797766 has been moved to the MODIFIED state.

In response to this:

Bug 1797766: Resource Requirements" specDescriptor fields - CPU and Memory injects empty string YAML editor

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@spadgett spadgett added this to the v4.7 milestone Feb 5, 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. bugzilla/severity-low Referenced Bugzilla bug's severity is low for the branch this PR is targeting. bugzilla/valid-bug Indicates that a referenced Bugzilla bug is valid for the branch this PR is targeting. component/olm Related to OLM 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

6 participants