Skip to content

Conversation

@dcantah
Copy link
Contributor

@dcantah dcantah commented Dec 3, 2020

  • Add helper functions to setup the disks for a base WCOW layer.

Signed-off-by: Daniel Canter [email protected]

@dcantah dcantah requested a review from a team as a code owner December 3, 2020 01:43
@dcantah dcantah force-pushed the computestorage-helpers branch 2 times, most recently from cc2426c to 7468926 Compare December 3, 2020 10:27
Copy link

@katiewasnothere katiewasnothere left a comment

Choose a reason for hiding this comment

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

LGTM

@dcantah dcantah force-pushed the computestorage-helpers branch from 7468926 to 7f9e8d4 Compare December 3, 2020 21:55
@dcantah dcantah force-pushed the computestorage-helpers branch from 7f9e8d4 to 6c45a15 Compare December 5, 2020 02:15
// already exist. `SetupBaseOSLayer` will create these files internally. We also remove the base and
// differencing disks if they exist in case we're asking for a different size.
if _, err := os.Stat(hivesPath); err == nil {
os.RemoveAll(hivesPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

should we worry about any potential issues here? or paths validity/permissions will happen before calling this? I might be off here and those concerns are not relevant at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you elaborate? I'm not fully following

Copy link
Contributor

Choose a reason for hiding this comment

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

we're ignoring the error from os.RemoveAll. I took a quick look and some of them are (e.g.) handle wrong paths (with dots in them as one of the cases) and potentially wrong permissions (I think). Is this something we should worry about? for example we're unable to remove something due to wrong path/permissions and we proceed and potentially run into something unexpected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh gotcha gotcha. We can check the error for RemoveAll as we're going to error out in HCS if they couldn't remove anyways, better to just fail earlier. Thanks for the clarification!


// Create the differencing disk that will be what's copied for the final rw layer
// for a container.
if err = vhd.CreateDiffVhd(diffVhdPath, baseVhdPath, defaultVHDXBlockSizeInMB); err != nil {
Copy link
Contributor

@anmaxvl anmaxvl Dec 7, 2020

Choose a reason for hiding this comment

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

the shared logic should be applied to both container and pod? if yes, is there a clean way to incapsulate it into one place, so we don't need to worry about having to remember to check both places? nothing needs to change, more of a patterns question here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto here, not fully following the question :(

Copy link
Contributor

Choose a reason for hiding this comment

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

mostly referring to similarities in what SetupContainerBaseLayer and SetupSandboxBaseLayer do in the beginning of the method (i.e. os.RemoveAll calls) on the same paths as well as in the end CreateDiffVhd/Grant*calls in the end, which is some shared code at the start and at the end with some different functionality in between.

so my question basically comes down to: can we dedup this somehow?

again, I'm not too worried about this. just seen some code that does stuff like:

func DoSomethingGenericWithSideEffect(func sideEffectAction(...), ...) {
    stuffAtTheStart()

    sideEffectAction(...)

    stuffAtTheEnd()
}

this is obviously not a place to do it, but for mostly educational purposes I was asking about other options (patterns) do we usually have?

Copy link
Contributor

Choose a reason for hiding this comment

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

I wouldn't worry about this too much and we can discuss this offline

* Add helper functions to setup the disks for a base WCOW layer.

Signed-off-by: Daniel Canter <[email protected]>
@dcantah dcantah force-pushed the computestorage-helpers branch from 6c45a15 to b0ed708 Compare December 8, 2020 03:07
Copy link
Contributor

@anmaxvl anmaxvl left a comment

Choose a reason for hiding this comment

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

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants