Skip to content

Conversation

@invincibleJai
Copy link
Member

@invincibleJai invincibleJai commented Oct 30, 2020

Fixes:
https://issues.redhat.com/browse/ODC-5082

Analysis / Root cause:
User preferences were saved in localStorage so not persisted across browsers

Implemented this hook for

  • Topology layout Data
  • Topology view state (graph/list)
  • Cloudshell terminal

Depends on : https://github.com/openshift/console/pull/7301/files

Solution Description:
Implemented useUserSettings for three features

Browser conformance:

  • Chrome
  • Firefox
  • Safari
  • Edge

@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. component/core Related to console core functionality labels Oct 30, 2020
@openshift-ci-robot openshift-ci-robot added component/dev-console Related to dev-console component/shared Related to console-shared labels Oct 30, 2020
@christoph-jerolimov
Copy link
Member

/assign
/assign christianvogt

@invincibleJai invincibleJai force-pushed the odc-4753 branch 4 times, most recently from 239cb2c to 20d04df Compare November 3, 2020 08:33
@invincibleJai invincibleJai changed the title [WIP] added userSettingHook to update configmap added userSettingHook to update configmap Nov 3, 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 Nov 3, 2020
@invincibleJai
Copy link
Member Author

/retest

@invincibleJai invincibleJai force-pushed the odc-4753 branch 2 times, most recently from ddbb9c6 to 15c1cc6 Compare November 4, 2020 02:46
@christianvogt
Copy link
Contributor

/hold

We cannot merge this until the backend support is ready. I suggest splitting this PR into one just for the utility function and tests and another for the subsequent updates to the existing code to move from localStorage to user settings.

@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 Nov 4, 2020
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have to look into this further but looks like this is a change in behavior because setCloudShellNamespace only updated what was stored in localStorage. Now setNamespace also updates the state.

Unless absolutely sure, I suggest keeping the state namespace separate from the user settings.

Copy link
Member Author

@invincibleJai invincibleJai Nov 11, 2020

Choose a reason for hiding this comment

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

i tried verifying it and we had setCloudShellNamespace to set in localStorage and getCloudShellNamespace to get from LocalStorage so with setNamespace it'll update the ns in ConfigMap, don't we need that.

@sahil143 can you as well verify once, if you get time?

Copy link
Contributor

Choose a reason for hiding this comment

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

I tested it locally cloud shell seems to work as expected.

Copy link
Contributor

Choose a reason for hiding this comment

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

Verified as well that setting this, while it does trigger an effect, will not cause any issues.

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2020
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 6, 2020
@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 26, 2020
Copy link
Contributor

@sahil143 sahil143 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 Nov 26, 2020
@christoph-jerolimov
Copy link
Member

Tested it again together with api change, works fine.

@invincibleJai needs rebase after #7199

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 27, 2020
@christoph-jerolimov
Copy link
Member

Still works fine 😄

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 27, 2020
@christoph-jerolimov
Copy link
Member

/title Use User settings hook for topology layout data, topology view state (graph/list) and cloudshell terminal

@openshift-ci-robot openshift-ci-robot changed the title added userSettingHook to update configmap Use User settings hook for topology layout data, topology view state (graph/list) and cloudshell terminal Nov 27, 2020
@christianvogt
Copy link
Contributor

Looks like replace doesn't work if the entry isn't present.
I'm seeing the following error trying to patch the configmap:

request url:

PATCH
/api/kubernetes/api/v1/namespaces/console-user-settings/configmaps/user-settings-d15fe175-17a2-463a-bfbc-d6f7da23e31c

request payload:

[{op: "replace", path: "/data/console.terminal.namespace", value: "cd-dev2"}]

422 error response:

{
  "kind": "Status",
  "apiVersion": "v1",
  "metadata": {
    
  },
  "status": "Failure",
  "message": "the server rejected our request due to an error in our request",
  "reason": "Invalid",
  "details": {
    
  },
  "code": 422
}

@christoph-jerolimov
Copy link
Member

christoph-jerolimov commented Nov 28, 2020

422 error response:

@christianvogt @invincibleJai The reason is that the ConfigMap contains no data. I fixed this in my PR #7327 by using a different patch format (merge-patch+json instead of patch+json). See:

https://github.com/openshift/console/blob/b06c1a73b9c46c84cbb57b8b931b4bdcb57cab43/frontend/packages/console-shared/src/utils/user-settings.ts#L18-L49

We can merge that as part of my PR or Jai can also integrate this into this PR.

As workaround you need to add some fake data: aaa: bbb to your ConfigMap.

@invincibleJai
Copy link
Member Author

invincibleJai commented Nov 30, 2020

422 error response:

@christianvogt @invincibleJai The reason is that the ConfigMap contains no data. I fixed this in my PR #7327 by using a different patch format (merge-patch+json instead of patch+json). See:

https://github.com/openshift/console/blob/b06c1a73b9c46c84cbb57b8b931b4bdcb57cab43/frontend/packages/console-shared/src/utils/user-settings.ts#L18-L49

We can merge that as part of my PR or Jai can also integrate this into this PR.

As workaround you need to add some fake data: aaa: bbb to your ConfigMap.

Thanks @jerolimov @christianvogt the problem is as you described if data is not there in Configmap and tries operation replace with patch request. what we can do is in op make a check if key doesn't exists instead of always doing replace perform add and we should good.

I updated the code to perform replace only if key exists in Configmap

https://github.com/openshift/console/pull/7051/files#diff-be39cbd2abb0f20ca51f378837f9c219a3920437816474dd2954942b85569fe2R51-R58

Let me know if you see issue.

@openshift-ci-robot openshift-ci-robot removed the lgtm Indicates that a PR is ready to be merged. label Nov 30, 2020
@christoph-jerolimov
Copy link
Member

christoph-jerolimov commented Dec 1, 2020

/hold cancel
/lgtm

@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 Dec 1, 2020
@christoph-jerolimov
Copy link
Member

/assign @christianvogt

@christianvogt
Copy link
Contributor

/approve

@openshift-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: christianvogt, invincibleJai, jeff-phillips-18, jerolimov, sahil143

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 1, 2020
@openshift-merge-robot
Copy link
Contributor

@invincibleJai: The following tests failed, say /retest to rerun all failed tests:

Test name Commit Details Rerun command
ci/prow/kubevirt-plugin 7e4b457760dbb319cb1c23f056b05faba7936f98 link /test kubevirt-plugin
ci/prow/e2e-gcp-console cf554d0 link /test e2e-gcp-console

Full PR test history. Your PR dashboard.

Details

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.

@christoph-jerolimov
Copy link
Member

/retest

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/ceph Related to ceph-storage-plugin component/core Related to console core functionality component/dev-console Related to dev-console component/knative Related to knative-plugin component/kubevirt Related to kubevirt-plugin component/lso Related to local-storage-operator-plugin component/metal3 Related to metal3-plugin component/olm Related to OLM component/sdk Related to console-plugin-sdk component/shared Related to console-shared lgtm Indicates that a PR is ready to be merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants