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

Add a DriveOpt func for configuring CacheType #401

Merged

Conversation

swagatbora90
Copy link
Contributor

@swagatbora90 swagatbora90 commented Apr 27, 2022

Issue #, if available:

Description of changes:
Adding a optional function to set "CacheType" of a Drive. "CacheType" is an optional field that we can now set for models.Drive and supports 2 values: "Unsafe" and "Writeback".

The aim is to make use of this function in firecracker-containerd if client requests CacheType to be set for the root drive or the other mounted drives

Testing:
make test

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@swagatbora90 swagatbora90 requested a review from a team as a code owner April 27, 2022 00:46
drives.go Outdated
@@ -103,3 +103,15 @@ func WithRateLimiter(limiter models.RateLimiter) DriveOpt {
d.RateLimiter = &limiter
}
}

// WithCacheType sets the cache strategy for the block device
func WithCacheType(cache_type string) DriveOpt {
Copy link
Contributor

Choose a reason for hiding this comment

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

Generally variables in Go are camelCase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack. Will change to camelCase

drives.go Outdated
Comment on lines 109 to 113
if cache_type == "" {
return func(_ *models.Drive) {
// no-op
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems we don't do this kind of check in most of helpers here. Do you have specific reasons to do here?

One concern I have is that if someone pass "" unintentionally, it would be ignored. Should we pass "" as is and let Firecracker error out?

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 do see your point about letting Firecracker handle everything as is. I added this input validation since I might have to use this later from FC-CD and pass "". Though I can add a helper in FC-CD to do just that.

Will remove this check from here.

Signed-off-by: Swagat Bora <sbora@amazon.com>
Copy link
Contributor

@kzys kzys left a comment

Choose a reason for hiding this comment

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

The change itself looks good. Can you squash the two commits into one? It may not be much meaningful for future readers.

Copy link
Contributor

@aarongoulet aarongoulet left a comment

Choose a reason for hiding this comment

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

Looks good to me. :shipit:

@aarongoulet aarongoulet added the enhancement New feature or request label Apr 27, 2022
@aarongoulet aarongoulet merged commit 47505a9 into firecracker-microvm:main Apr 27, 2022
@swagatbora90 swagatbora90 deleted the add-cache-type-support branch July 17, 2023 21:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants