Skip to content

Remove the default value for '--data-template' and stop auto-deleting the data directory#1210

Merged
stevenengler merged 3 commits intoshadow:devfrom
stevenengler:data-directory
Apr 1, 2021
Merged

Remove the default value for '--data-template' and stop auto-deleting the data directory#1210
stevenengler merged 3 commits intoshadow:devfrom
stevenengler:data-directory

Conversation

@stevenengler
Copy link
Copy Markdown
Contributor

Closes #1191.

@stevenengler stevenengler added Type: Maintenance Refactoring, cleanup, documenation, or process improvements Component: Main Composing the core Shadow executable labels Mar 23, 2021
@stevenengler stevenengler self-assigned this Mar 23, 2021
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 23, 2021

Codecov Report

Merging #1210 (a44acb4) into dev (59b4d55) will decrease coverage by 0.15%.
The diff coverage is 23.52%.

❗ Current head a44acb4 differs from pull request most recent head 53e3e42. Consider uploading reports for the commit 53e3e42 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #1210      +/-   ##
==========================================
- Coverage   55.59%   55.44%   -0.16%     
==========================================
  Files         142      140       -2     
  Lines       20346    20270      -76     
  Branches     4974     4958      -16     
==========================================
- Hits        11312    11238      -74     
- Misses       5963     5973      +10     
+ Partials     3071     3059      -12     
Flag Coverage Δ
tests 55.44% <23.52%> (-0.16%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/main/core/controller.c 58.36% <0.00%> (-0.46%) ⬇️
src/main/core/support/options.c 61.90% <ø> (-0.28%) ⬇️
src/main/core/manager.c 63.89% <26.66%> (-1.02%) ⬇️
src/support/logger/logger.c 64.86% <0.00%> (-18.92%) ⬇️
src/shim/shim_event.c 66.66% <0.00%> (-8.34%) ⬇️
src/main/routing/dns.c 59.64% <0.00%> (-2.93%) ⬇️
src/main/core/worker.c 77.04% <0.00%> (-1.64%) ⬇️
src/shim/preload_libraries.c 69.53% <0.00%> (-0.50%) ⬇️
src/main/host/syscall_handler.c 51.07% <0.00%> (-0.41%) ⬇️
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 59b4d55...53e3e42. Read the comment docs.

@stevenengler stevenengler requested a review from sporksmith March 23, 2021 23:52
if (g_file_test(manager->dataPath, G_FILE_TEST_EXISTS)) {
gboolean success = utility_removeAll(manager->dataPath);
utility_assert(success);
critical("data directory already exists");
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would be helpful to include the path in this message

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added the path

if (g_file_test(templateDataPath, G_FILE_TEST_EXISTS)) {
gboolean success = utility_copyAll(templateDataPath, manager->dataPath);
utility_assert(success);
const gchar* templateDataPath = options_getDataTemplatePath(options);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be worth breaking this out into a helper function. If so you can use early returns to unnest some of this logic. e.g.

if (!g_file_test(absTemplatePath, G_FILE_TEST_EXISTS) {
  critical("...")
  return
}
...

(Or if we upgrade these to error we can unnest either way)

Copy link
Copy Markdown
Contributor Author

@stevenengler stevenengler Apr 1, 2021

Choose a reason for hiding this comment

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

I made these call error(), and now they're not longer nested.

controller->bootstrapEndTime, managerSeed, element->preloadPath.string->str,
element->environment.isSet ? element->environment.string->str : NULL);

if (controller->manager == NULL) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's a bit surprising to have to check a new function for a NULL return. Since this is the only call site it's probably not that big of a deal in practice, but for an error that's ultimately going to result in exiting the simulation we might as well just error at that point rather than bubbling errors back up.

If we do want to make such a method fallible, we should probably call it something else; maybe tryNew

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I made all of the new code call error() instead of returning NULL, but I left the NULL check here since manager_new() can already return NULL from the existing code (since only a single manager can exist at a time), so I think it's still good to have this check.

@stevenengler stevenengler requested a review from sporksmith April 1, 2021 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Main Composing the core Shadow executable Type: Maintenance Refactoring, cleanup, documenation, or process improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants