Skip to content
This repository has been archived by the owner on Jun 2, 2022. It is now read-only.

Explore volumes incrementally, sort API list response, make history entry more readable #330

Merged
merged 5 commits into from
Jun 14, 2019

Conversation

MikaelSmith
Copy link
Contributor

@MikaelSmith MikaelSmith commented Jun 14, 2019

Resolves #290.

plugin.CachedList returns a map, which removes any ordering on the list
results from an individual plugin. Remove ignored sorting from
volume.List and instead sort when constructing the API response.

FUSE appears to handle sorting entries for us when using `ls`.

Signed-off-by: Michael Smith <[email protected]>
@@ -60,6 +61,8 @@ var listHandler handler = func(w http.ResponseWriter, r *http.Request) *errorRes
apiEntry.Path = path + "/" + apiEntry.CName
result = append(result, apiEntry)
}
// Sort entries so they have a deterministic order.
sort.Slice(result, func(i, j int) bool { return result[i].Name < result[j].Name })
Copy link
Contributor

Choose a reason for hiding this comment

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

Sucks that we have to iterate again. Guessing there's no easy OrderedMap alternate?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it's too bad, O(n log n) either way. There are several options:

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, not worth it. Like you said, O(n log n) isn't that bad.

Parses the logfmt entries returned by the API and emits them in a more
readable format, e.g.
```
Jun 13 15:44:04.299 Exec [find / -mindepth 1 -maxdepth 5 -exec stat -c %s %X %Y %Z %f %n {} +] on blissful_gould
Jun 13 15:44:04.433 stdout: 4096 1559079604 1557434981 1559079604 41ed /lib
                    2597536 1552660099 1552660099 1559079604 81ed /lib/libcrypto.so.1.1
```
Tests were incorrectly relying on uninitialized fields in a map
returning nil. That wasn't the case. Use Contains to correctly test the
contents of a map.

Signed-off-by: Michael Smith <[email protected]>
@MikaelSmith MikaelSmith force-pushed the volume-improvements branch from dfcca03 to 476b88f Compare June 14, 2019 20:21
The volume package will now search to the specified depth, then if that
level is listed it will incrementally search the subtree requested. This
provides improved speed for individual requests while batching listing
for slower transports.

Signed-off-by: Michael Smith <[email protected]>
@MikaelSmith MikaelSmith added the do not merge Do not merge this pull request until the author removes this label. label Jun 14, 2019
@MikaelSmith MikaelSmith force-pushed the volume-improvements branch from 476b88f to d211318 Compare June 14, 2019 20:56
@MikaelSmith MikaelSmith removed the do not merge Do not merge this pull request until the author removes this label. label Jun 14, 2019
Refactor volume internals to remove the path argument from volume.List,
which always needed to be set to an empty string ("") when called
externally.

Signed-off-by: Michael Smith <[email protected]>
@MikaelSmith MikaelSmith force-pushed the volume-improvements branch from d211318 to 74e74f9 Compare June 14, 2019 20:57
@ekinanp ekinanp merged commit 6b18bad into puppetlabs-toy-chest:master Jun 14, 2019
@MikaelSmith MikaelSmith deleted the volume-improvements branch June 14, 2019 22:20
MikaelSmith added a commit to MikaelSmith/wash that referenced this pull request Jun 15, 2019
PR puppetlabs-toy-chest#330 introduced a regression where, when the cache expired, listing
a volume could repopulate the cache with different data and break
navigation. Fix so that VolumeList calls for a particular cache key
always uses the same path.

Signed-off-by: Michael Smith <[email protected]>
MikaelSmith added a commit to MikaelSmith/wash that referenced this pull request Jun 15, 2019
PR puppetlabs-toy-chest#330 introduced a regression where, when the cache expired, listing
a volume could repopulate the cache with different data and break
navigation. Fix so that VolumeList calls for a particular cache key
always uses the same path.

Signed-off-by: Michael Smith <[email protected]>
MikaelSmith added a commit to MikaelSmith/wash that referenced this pull request Jun 17, 2019
PR puppetlabs-toy-chest#330 introduced a regression where, when the cache expired, listing
a volume could repopulate the cache with different data and break
navigation. Fix so that VolumeList calls for a particular cache key
always uses the same path.

Signed-off-by: Michael Smith <[email protected]>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extend the Volume FS helper to enumerate other parts of the remote filesystem
2 participants