-
Notifications
You must be signed in to change notification settings - Fork 131
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
Add a DriveOpt func for configuring CacheType #401
Conversation
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 { |
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.
Generally variables in Go are camelCase.
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.
Ack. Will change to camelCase
drives.go
Outdated
if cache_type == "" { | ||
return func(_ *models.Drive) { | ||
// no-op | ||
} | ||
} |
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.
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?
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.
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>
d394d1a
to
96eca0b
Compare
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.
The change itself looks good. Can you squash the two commits into one? It may not be much meaningful for future readers.
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.
Looks good to me.
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.