-
Notifications
You must be signed in to change notification settings - Fork 92
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
Fix infinite loop when fetching USS resources with stat() #3321
Fix infinite loop when fetching USS resources with stat() #3321
Conversation
Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com>
Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com>
Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #3321 +/- ##
=======================================
Coverage 92.99% 92.99%
=======================================
Files 116 116
Lines 12063 12069 +6
Branches 2776 2777 +1
=======================================
+ Hits 11218 11224 +6
Misses 843 843
Partials 2 2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this Benjamin, the fix is much appreciated. I tested this with a basic sample extension and the fix looks good to me. Please disregard the failing ze-build (22.x, ubuntu-22.04)
check as its unrelated.
It seems that the vscode.workspace.fs
wrappers perform some extra checks before creating the directory - my guess is that they probably stat
the folder to make sure it doesn't exist before trying to create it. When calling createDirectory
directly within the providers, this step doesn't occur, so the infinite loop isn't encountered.
Admittedly, the stat
function has caused more grief than expected with the file system provider implementations, especially when it comes to network requests. I also did not expect VS Code to call it as much as it does, and this particular case seems to be a side effect of preserving the fetch
query on the original URI 😵💫
@traeok Thanks for the review. Is it possible to include this fix in the v3.0.3 release? |
@zFernand0 @t1m0thyj @adam-wolfe what do y'all think too? I believe we are including a similar fix for another tree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @benjamin-t-santos!
@JillieBeanSim This fix looks like a simple one that would be good to include 👍 |
thanks I will get it ported |
* remove query when looking up parent Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * remove leftover comment Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * Update CHANGELOG.md Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> --------- Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com>
Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com>
* DatasetFSprovider fetchDataset() - fix behavior with non-existent datasets and members (#3255) * Fix PDS members in fetchDataset Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * Update DatasetFSProvider.unit.test.ts Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * Update CHANGELOG.md Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * Merge branch 'main' into datasetfsprovider-remote-lookup-fix Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * move changelog update Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * improve logic Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * add ? after checking dsorg Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * do not fetch attributes for members Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> --------- Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * fix: use `vscode.workspace.fs` for `delete` and `rename` (#3261) * fix: use vscode.workspace.fs to rename URIs Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: update ZE changelog Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * update mocks, remaining use of delete/rename Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * Fix: To resolve error message upon switching the authentication methods (#3275) * To handle missing args in basicAuthClearSecureArray Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * To handle missing args in tokenAuthClearSecureArray Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * To add unit test case for missing arg's in basicAuthClearSecureArray Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * To add unit test case for missing arg's in tokenAuthClearSecureArray Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * To run pre-publish command Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * To update changelog Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * To modify tokenAuthClearSecureArray() function Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * To add additional test cases for tokenAuthClearSecureArray() Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> --------- Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> * fix: "Show Config" button in error dialog does not work during initialization (#3274) * fix: check if profileInfo is nullish during v1 migration Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: update ZE changelog Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * tests: integration test for broken config Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * add unit test for nullish profileinfo Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix transient failures in UpdateCredentials scenario Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * remove extra join import in wdio conf Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * make integration test more reliable Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * move getprofileinfo call into try/catch during profiles init Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * test: open notification center to check for dialog Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * add license header to test; add another null check Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * add typedoc to ProfilesUtils.getProfileInfo Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * setupDefaultCredentialManager: log err msgs, update typedoc Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * test: promptUserWithNoConfigs, nullish profileInfo case Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor typedoc for setupDefaultCredentialManager Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(ds): Call remoteLookupForResource when entry doesn't exist locally (#3268) Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Billie Simmons <BillieJean.Simmons@ibm.com> Co-authored-by: Billie Simmons <BillieJean.Simmons@ibm.com> * fix: Only show "No configs detected" prompt if ZE opened (#3281) * fix: show 'No config detected' prompt once when ZE opened Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: update ZE changelog Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * resolve failing tests Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor: move event into static fn, add coverage Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * update changelog Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * patch coverage for ProfilesUtils.promptUserWithNoConfigs Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * move variable definition Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Billie Simmons <BillieJean.Simmons@ibm.com> Co-authored-by: Billie Simmons <BillieJean.Simmons@ibm.com> Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * fix(v3): Pass `responseTimeout` in z/OSMF MVS and USS API calls (#3292) * fix: pass responseTimeout to API functions Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor: remove fallback for spreading newOptions Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor: use optional chaining; work on resolving tests Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor: pass profile props to tests, fix types Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * tests: resolve failing cases in ZE Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: update changelog entry for ZE API Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor: remove fallback for spreading undefined options Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix: add missing functions to MvsApi test list Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * run package Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * chore: remediation commit Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Third-Party DCO Remediation Commit for benjamin-t-santos <115251181+benjamin-t-santos@users.noreply.github.com> On behalf of benjamin-t-santos <115251181+benjamin-t-santos@users.noreply.github.com>, I, Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 8957a64 Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Third-Party DCO Remediation Commit for SanthoshiBoyina1 <142206957+SanthoshiBoyina1@users.noreply.github.com> On behalf of SanthoshiBoyina1 <142206957+SanthoshiBoyina1@users.noreply.github.com>, I, Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com>, hereby add my Signed-off-by to this commit: 86a82f6 Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> * DatasetFSProvider.readFile() makes at most one API call (#3279) * fix(ds): Call remoteLookupForResource when entry doesn't exist locally Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * readFile() uses one MVS API call Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * update unit tests, fix logic of calls Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * fix lint error Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * Update CHANGELOG.md Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> Signed-off-by: benjamin-t-santos <115251181+benjamin-t-santos@users.noreply.github.com> Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * Change default credentials manager check and not-found dialog (#3297) * updates to webpack and package.json for dev mode Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * Remove endless startup loop when default CM cannot be loaded Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Initial set of test updates Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Merge branch 'main' into change-credentials-manager-check Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Convenience launch to only run currently open test Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Fixed ProfileUtils tests Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Clean up package files Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Updated changelog Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Reworded info message Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Update CHANGELOG.md Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> * Added detail to info message Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> * Updated resource files Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> --------- Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Co-authored-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * fix(3.0.3): Prompt in editor for 401 error, fix profile propagation (#3318) * fix: profile change propagation, prompt on auth error Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * tests: profile propagation, tree node cases Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: changelogs Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * test(jobs): add patch coverage Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * tests: AuthUtils.promptForAuthError Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * tests: UssFSProvider.fetchFileAtUri Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix: reset wasAccessed flag if ImperativeError caught Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * tests: resolve failing USS tests Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix failing jobs test Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * fix(ftp): Generate member name if missing in `putContents` (#3313) * fix(ftp): Generate member name if missing in putContents Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: add entry to FTP changelog Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * refactor: remove unused isAbsolutePath import Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * chore: undo updates to l10n since no strings were changed Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> * tests(ftp): PDS upload case, clean up PS upload test Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> --------- Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> Co-authored-by: Billie Simmons <BillieJean.Simmons@ibm.com> Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> * run prepublish Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * Fix infinite loop when fetching USS resources with stat() (#3321) * remove query when looking up parent Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * remove leftover comment Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> * Update CHANGELOG.md Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> --------- Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * run prepublish Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> * Fix port of #3321 for 3.0.3 release Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com> --------- Signed-off-by: Benjamin Santos <benjamin.santos@ibm.com> Signed-off-by: Trae Yelovich <trae.yelovich@broadcom.com> Signed-off-by: Santhoshi Boyina <Santhoshi.Boyina1@ibm.com> Signed-off-by: Billie Simmons <BillieJean.Simmons@ibm.com> Signed-off-by: Billie Simmons <49491949+JillieBeanSim@users.noreply.github.com> Signed-off-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Signed-off-by: benjamin-t-santos <115251181+benjamin-t-santos@users.noreply.github.com> Signed-off-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> Signed-off-by: Timothy Johnson <timothy.johnson@broadcom.com> Co-authored-by: benjamin-t-santos <115251181+benjamin-t-santos@users.noreply.github.com> Co-authored-by: Trae Yelovich <trae.yelovich@broadcom.com> Co-authored-by: SanthoshiBoyina1 <142206957+SanthoshiBoyina1@users.noreply.github.com> Co-authored-by: Fernando Rijo Cedeno <37381190+zFernand0@users.noreply.github.com> Co-authored-by: Peter Haumer <4391934+phaumer@users.noreply.github.com> Co-authored-by: Timothy Johnson <timothy.johnson@broadcom.com>
Proposed changes
Extenders can fetch a USS resource on demand using
vscode.workspace.fs.stat()
with thefetch=true
query. When done with a USS file that has not expanded in the USS tree view, Zowe Explorer gets stuck in an infinite loop of callingstat()
over and over again. Here's how it happens:vscode.workspace.fs.stat()
is called for a USS resource with the fetch query set to true. Example:vscode.workspace.fs.stat(zowe-uss:/zosmf/user/test.txt)
UssFSProvider.remoteLookupForResource()
is called to fetch the file from the host.UssFSProvider.fetchEntries()
.fetchEntries()
checks if the parent directory of the requested file is in the file system. If it's not,await vscode.workspace.fs.createDirectory(parentUri)
is called on line 191 to create it.stat()
is called again for theparentUri
with afetch=true
query as a result of callingvscode.workspace.fs.createDirectory()
. (I believe this is due to the VS Code file system base implementation. It surprised me but looking at the call stack that is what I see)UssFSProvider.remoteLookupForResource()
is called to fetch the directory from the host. This eventually callsUssFSProvider.fetchEntries()
listFiles()
is called infetchEntries()
, if the resource requested is a directory that does not already exist in the file system, we callvscode.workspace.fs.createDirectory()
with the directory's URI. This is the same exact URI that is used when callingcreateDirectory()
in step 3.Basically, Zowe Explorer keeps calling
vscode.workspace.fs.createDirectory()
for the parent of the requested file over and over again without ever resolving. This does not happen when using tree views because of how directories are expanded from the top-down. In this case, I as an extender am requesting a file from a parent directory that has not been created.There are improvements we can make to improve the
UssFSProvider
for extenders, but with the goal of trying to get a fix for this issue into the v3.0.3 release, I tried to keep my changes minimal. I added code that sets the query of theparentUri
to an empty string when callingvscode.workspace.fs.createDirectory()
infetchEntries()
. This prevents it from entering the infinite loop by not trying to fetch the requested resource's parent.This change will not impact the tree view, as those views do not make use of the fetch query. This change will only fix functionality for extenders.
Release Notes
Milestone:
Changelog:
Types of changes
Checklist
General
yarn workspace vscode-extension-for-zowe vscode:prepublish
pnpm --filter vscode-extension-for-zowe vscode:prepublish
Code coverage
Deployment
Further comments