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

Extensions don't stay enabled #7784

Closed
jim-docker opened this issue May 25, 2023 · 11 comments · Fixed by #7801
Closed

Extensions don't stay enabled #7784

jim-docker opened this issue May 25, 2023 · 11 comments · Fixed by #7801
Assignees
Labels
area/extension Something to related to the extension api bug Something isn't working p0

Comments

@jim-docker
Copy link
Contributor

Describe the bug
If you enable an extension then restart Lens, the extension is disabled.

To Reproduce
Steps to reproduce the behavior:

  1. Enable an extension (tried @jakolehm/lens-extension-gke-sync and @nevalla/kube-resource-map)
  2. Verify it works
  3. Restart Lens
  4. Observe that the extension is disabled

Environment (please complete the following information):

  • Lens Version: 2023.5.251645-alpha
  • OS: Linux (AppImage), MacOS
@jim-docker jim-docker added bug Something isn't working area/extension Something to related to the extension api labels May 25, 2023
@Nokel81 Nokel81 modified the milestone: 6.6.0 May 26, 2023
@jim-docker jim-docker self-assigned this May 26, 2023
@jim-docker
Copy link
Contributor Author

If the lens-extensions.json file looks like this before starting Lens:

{
	"__internal__": {
		"migrations": {
			"version": "1.0.0"
		}
	},
	"extensions": [
		[
			"/home/jim/.config/OpenLensDev/node_modules/@andrea-falco/lens-multi-pod-logs/package.json",
			{
				"enabled": true,
				"name": "@andrea-falco/lens-multi-pod-logs"
			}
		]
	]
}

It looks like this right after Lens has started:

{
	"__internal__": {
		"migrations": {
			"version": "1.0.0"
		}
	},
	"extensions": [
		[
			"0",
			[
				"/home/jim/.config/OpenLensDev/node_modules/@andrea-falco/lens-multi-pod-logs/package.json",
				{
					"enabled": true,
					"name": "@andrea-falco/lens-multi-pod-logs"
				}
			]
		],
		[
			"/home/jim/.config/OpenLensDev/node_modules/@andrea-falco/lens-multi-pod-logs/package.json",
			{
				"enabled": false,
				"name": "@andrea-falco/lens-multi-pod-logs"
			}
		]
	]
}

This would explain why the extension is not enabled after restarting Lens. I have seen this before, do you remember what the problem is @Nokel81 ?

@Nokel81
Copy link
Collaborator

Nokel81 commented May 27, 2023

Looks likes a call to .entries() are being serialized instead or something.

Maybe making a unit test with that initial state and expecting that after the application starts up that the state is the same could help here.

@jim-docker
Copy link
Contributor Author

jim-docker commented May 29, 2023

@Nokel81 I think this is the culprit. Is this migration just to catch when extensions is not an object? If it is an array we probably should do nothing(?)

@Nokel81
Copy link
Collaborator

Nokel81 commented May 29, 2023

Yeah we probably should do nothing in that case.

IIRC the shape of the stored object changed in that PR.

Also, does the __migration__ key really not change the version before and after?

@jim-docker
Copy link
Contributor Author

Also, does the migration key really not change the version before and after?

It does change. That was copy-paste chicanery on my part, I edited my lens-extensions.json file to have just one extension in it, missed the version change.

@Nokel81
Copy link
Collaborator

Nokel81 commented May 29, 2023

Okay good

@Nokel81
Copy link
Collaborator

Nokel81 commented May 29, 2023

I believe that the intended behaviour was to convert between an object based storage and an entry based one since the backing type changed from observable.object() to observable.array().

@jim-docker
Copy link
Contributor Author

Ok. I'm going to double check this because I see the migration version changing for a dev run but it appears the alphas are not changing it(?) On my windows machine, latest alpha, after testing with it and previous alpha:

{
	"__internal__": {
		"migrations": {
			"version": "1.0.0"
		}
	},
	"extensions": [
		[
			"0",
			[
				"0",
				[
					"0",
					[
						"0",
						[
							"0",
							[
								"0",
								[
									"0",
									[
										"0",
										[
											"0",
											[
												"0",
												[
													"0",
													[
														"C:\\Users\\jiim\\AppData\\Roaming\\Lens\\node_modules\\cloud-provider-sync-extension\\package.json",
														{
															"enabled": false,
															"name": "cloud-provider-sync-extension"
														}
													]
												]
											]
										]
									]
								]
							]
						]
					]
				]
			]
		],
		[
			"1",
			[
				"1",
				[
					"1",
					[
						"1",
						[
							"1",
							[
								"1",
								[
									"1",
									[
										"1",
										[
											"1",
											[
												"1",
												[
													"1",
													[
														"C:\\Users\\jiim\\AppData\\Roaming\\Lens\\node_modules\\lens-certificate-info\\package.json",
														{
															"enabled": false,
															"name": "lens-certificate-info"
														}
													]
												]
											]
										]
									]
								]
							]
						]
					]
				]
			]
		],
.
.
.

@jim-docker
Copy link
Contributor Author

Maybe this is caused by me going from latest to alpha to latest...

@jim-docker
Copy link
Contributor Author

Hmmm

Screen.Recording.2023-05-29.at.5.37.42.PM.mov

@Nokel81
Copy link
Collaborator

Nokel81 commented May 29, 2023

Oh I see, that is the single store the now uses a new method of calculating the store version number, which is based on the declared migrations.

But migrations are only declared on main so I guess it defaults to the version of 1.0.0 on renderer. I think the proper fix would be to not read from the file system at all on renderer and instead retrieve the initial state from main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/extension Something to related to the extension api bug Something isn't working p0
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants