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

zowe-explorer-api ProfilesCache holding onto stale service profile from extenders when it is deleted from team config #2395

Closed
FrankSu1996 opened this issue Jul 25, 2023 · 8 comments · Fixed by #2795
Assignees
Labels
bug Something isn't working priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex.

Comments

@FrankSu1996
Copy link

FrankSu1996 commented Jul 25, 2023

We are currently contributing our own zowe service profiles (type zOpenDebug) using zowe-explorer-api. Our code has it's own watchers set up on the team config files. However, when all profiles of type zOpenDebug are removed from the team config file, the ZE-api ProfilesCache will still contain the removed profile. Note that aside from this case, the ProfilesCache seems to work as expected when multiple zOpenDebug profiles are added/deleted. It's only when they are ALL removed, that this bug occurs.

Steps to reproduce the behavior:

  1. Create a new zowe profile type using zowe-explorer-api.
  2. Create a zowe team config file if one isn't already present.
  3. Delete All instances of the new profile type from the team config file.
  4. call ProfileCache.refresh(). Despite profiles being removed from team config file, ProfilesCache will still return a reference to a profile.

Expected behavior

The ProfileCache should return an empty list for the new zowe profile type if they are all removed from the team config

Desktop (please complete the following information):

@FrankSu1996 FrankSu1996 added the bug Something isn't working label Jul 25, 2023
@github-actions
Copy link

Thank you for creating a bug report.
We will investigate the bug and evaluate its impact on the product.
If you haven't already, please ensure you have provided steps to reproduce the bug and as much context as possible.

@zFernand0 zFernand0 added priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex. labels Aug 1, 2023
@t1m0thyj t1m0thyj moved this from New Issues to Medium Priority in Zowe Explorer for VS Code Dec 26, 2023
@JillieBeanSim
Copy link
Contributor

Hey @FrankSu1996 would you mind letting us know the version of the Zowe Explorer API you experience the issue and when deleting the profile manually from the team config file is that also being removed from the defaults if labeled as default in the config file? Thanks

@FrankSu1996
Copy link
Author

currently using @zowe/zowe-explorer-api v2.12.0. It doesn't matter whether or not I remove the default line in the config file. The bug occurs regardless.

@traeok
Copy link
Member

traeok commented Mar 20, 2024

Hi @FrankSu1996,

I ran some tests with the FTP extension to reproduce this issue. For context, I am using the latest version of Zowe Explorer, Zowe Explorer API, and the FTP extension (v2.15.1). I believe this is a side effect of using the ProfilesCache.refresh function before accessing data from the cache.

To test, I registered a test command in the FTP extension to print profiles, which grabs the ProfilesCache instance from the extender API and logs it to the console:

image

I noticed that if I skip the usage of ProfilesCache.refresh, I can access the profiles as expected, and changes to the team config are handled as expected in the instance:

Click to toggle screenshot

The first printed output contains 2 zFTP profiles, while the second output does not.
The only change was the removal of those 2 zFTP profiles from the team config, which is reflected in the second output:

image

However, when I use ProfilesCache.refresh from the FTP extension before printing the cache, the allProfiles array is empty, even if I provide the API register. I believe this is because Zowe Explorer already refreshes its ProfilesCache instance when the team config is changed - because the instance is already shared to extensions through the ZoweExplorerExtender API, the extra refresh call is not required, and calling it causes the profiles to be removed from the cache.

Can you confirm that removing the call to ProfilesCache.refresh resolves your issue with the latest ZE API?
Granted, while it's strange that the extra refresh may cause this behavior, I believe that the team expects Zowe Explorer to handle the refreshing ourselves, and extenders that access the ProfilesCache through ZoweExplorerExtender should not have to do an additional refresh to get the changes.

@FrankSu1996
Copy link
Author

[
with_refresh.zip
](url)
no_refresh.zip

Taking out ProfilesCache.refresh() does not solve the issue. I attached a couple of screen recordings, one where I comment out the call to refresh(). In both cases, I'm logging out both ProfilesCache.allProfiles and ProfilesCache.getProfiles("zOpenDebug"). The results are pretty interesting.

Without Refresh:
ProfilesCache.allProfiles properly removes the zOpenDebug profile, but ProfilesCache.getProfiles("zOpenDebug") still returns it.

With Refresh:
Both ProfilesCache.getProfiles("zOpenDebug") and ProfilesCache.allProfiles contains the zOpenDebug profile. In addition, allProfiles seems to have duplicated every profile.

@traeok
Copy link
Member

traeok commented Mar 20, 2024

Taking out ProfilesCache.refresh() does not solve the issue. I attached a couple of screen recordings, one where I comment out the call to refresh(). In both cases, I'm logging out both ProfilesCache.allProfiles and ProfilesCache.getProfiles("zOpenDebug"). The results are pretty interesting.

Without Refresh: ProfilesCache.allProfiles properly removes the zOpenDebug profile, but ProfilesCache.getProfiles("zOpenDebug") still returns it.

With Refresh: Both ProfilesCache.getProfiles("zOpenDebug") and ProfilesCache.allProfiles contains the zOpenDebug profile. In addition, allProfiles seems to have duplicated every profile.

Thanks for the detailed follow-up. I looked back at my previous examples and noticed that profilesByType is not accurate for my tests either - sorry for the oversight. getProfiles uses a different data structure than allProfiles, and while allProfiles is updated correctly, it looks like the other structure does not reflect recent updates to the team config. I'll look into resolving this and will release a fix as soon as possible.

@traeok traeok self-assigned this Mar 20, 2024
@traeok traeok moved this from Medium Priority to In Progress in Zowe Explorer for VS Code Mar 20, 2024
@FrankSu1996
Copy link
Author

Thanks for the update, appreciate you looking into this. For us, it's important for us that ProfilesCache keeps the ability for clients to be able to refresh.

@traeok
Copy link
Member

traeok commented Apr 2, 2024

Closed as completed in #2795

@traeok traeok closed this as completed Apr 2, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Closed in Zowe Explorer for VS Code Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority-medium Not functioning - next quarter if capacity permits severity-medium Bug where workaround exists or that doesn't prevent the usage of Zowe. Just makes it more complex.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants