lens icon indicating copy to clipboard operation
lens copied to clipboard

Elimination of global shared state

Open jansav opened this issue 2 years ago • 5 comments

This issue is a way to track progress with elimination of global shared state in OpenLens.

Things to consider

  • Extension API contracts should not be broken
  • Incremental refactoring (i.e. system needs to remain usable)
  • Unit tests should be added while doing this

Red flag trigger words

On encounter of any of these phrases in codebase, one is likely to be dealing with global shared state.

  • .createInstance() and .getInstance()
  • static
  • export anything-with-state
  • jest.mock
  • constructor that inits or loads something

Singleton -base-class usages

Registries

Most of the registries can be replaced with reactive solutions relatively easily. Think if this is feasible at the same time.

  • [x] #4649
  • [ ] #4819
  • [x] #4912
  • [x] #4913
  • [x] #4647
  • [ ] #4875
  • [x] #4914
  • [x] #4632
  • [x] #4729
  • [x] #4814
  • [x] MenuRegistry - #4527
  • [x] #4727
  • [x] TopBarRegistry - #4613
  • [x] WelcomeBannerRegistry - #4615
  • [x] WelcomeMenuRegistry - #4615
  • [x] #4816
  • [ ] BaseRegistry (if still needed, mark as deprecated)

Stores

  • [ ] #4878
  • [x] #4654
  • [ ] #4879
  • [ ] #4880
  • [ ] #4881
  • [ ] #4882
  • [ ] #4883
  • [ ] #4884

Other stuff

  • [ ] #4712
  • [ ] #4713
  • [x] #4885
  • [x] #4655
  • [x] #4862
  • [ ] #5023
  • [x] #4656
  • [x] #4886
  • [ ] #5026
  • [x] #4657
  • [x] #4658
  • [x] #5673
  • [x] #4887

Exporting already instantiated class

Global search with RegExp: export const .* = new

  • [ ] #4890
  • [x] #4633
  • [x] #4659
  • [ ] #4888
  • [ ] #4714
  • [ ] #4715
  • [ ] #4716
  • [x] #4660
  • [x] ClusterRoleBindingsStore
  • [x] ClusterRolesStore
  • [x] componentStatusApi
  • [x] ConfigMapsStore
  • [x] CRDStore
  • [x] #4639
  • [x] CrobJobStore
  • [x] DaemonSetStore
  • [x] DeploymentStore
  • [x] #4648
  • [x] #4637
  • [x] #4636
  • [x] EndpointStore
  • [x] EventStore
  • [x] #4661
  • [x] #4662
  • [x] ExtensionLoader - #4527
  • [ ] HelmChartStore
  • [x] #5677
  • [ ] HelmService
  • [x] HPAStore
  • [x] IngressStore
  • [x] #4640
  • [x] JobStore
  • [x] KubernetesClusterCategory
  • [x] #4667
  • [x] LimitRangesStore
  • [x] #4641
  • [x] #4642
  • [x] #4663
  • [x] NetworkPolicyStore
  • [x] NodesStore
  • [x] #4889
  • [ ] packageMirrors
  • [x] PageFiltersStore
  • [x] PersistentVolumesStore
  • [x] PodDisruptionBudgetsStore
  • [x] PodSecurityPoliciesStore
  • [x] #4664
  • [x] #4643
  • [x] ReplicaSetStore
  • [x] ResourceQuotasStore
  • [x] RoleBindingsStore
  • [x] RolesStore
  • [x] #4644
  • [x] SecretsStore
  • [x] ServiceAccountsStore
  • [x] ServiceStore
  • [x] StatefulSetStore
  • [x] StorageClassStore
  • [x] #4645
  • [x] #4646
  • [x] VolumeClaimStore
  • [x] workloadStores

Other stuff

  • [x] #4665

jansav avatar Dec 15 '21 06:12 jansav

Exporting already instantiated class

While I really want to do this part. I don't quite see how we can without a major version bump to the extension API.

Nokel81 avatar Dec 15 '21 17:12 Nokel81

Exporting already instantiated class

While I really want to do this part. I don't quite see how we can without a major version bump to the extension API.

Lets see. I think we have some ideas, but haven’t tested them about yet.

jansav avatar Dec 15 '21 20:12 jansav

Note: Added Red flag trigger words to description

Red flag trigger words

On encounter of any of these phrases in codebase, one is likely to be dealing with global shared state.

  • .createInstance() and .getInstance()
  • static
  • export anything-with-state

Iku-turso avatar Dec 17 '21 07:12 Iku-turso

Hear hear: elimination of shared global state is the current Team Technical Focus (TTF).

Iku-turso avatar Dec 17 '21 10:12 Iku-turso

Should the checkmarks really be checked for PRs that are closed and not merged?

Nokel81 avatar Jan 05 '22 20:01 Nokel81

Closing as the bulk work is now done. Just need to remove as many uses of the legacyGlobal family of functions as possible now.

🎉

Nokel81 avatar Dec 20 '22 16:12 Nokel81