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

change azure disk host cache to ReadOnly by default #72229

Merged
merged 1 commit into from Jan 5, 2019

Conversation

andyzhangx
Copy link
Member

@andyzhangx andyzhangx commented Dec 20, 2018

What type of PR is this?
/kind bug

What this PR does / why we need it:
change azure disk host cache to ReadOnly by default
The default value None would lead to slow perf. And according to below doc: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/premium-storage-performance#disk-caching

default host cache should be ReadOnly, the reason why we use “cachingMode: None” by default in k8s is that there is a critical disk bug due to this cachingMode setting(ReadOnly & ReadWrite) which would lead to disk i/o error, and this issue has been fixed in the middle of this year by azure disk team.

I would also like to change the default value(from ReadWrite to ReadOnly) of caching mode in direct azure disk PV creation, there is one statement in the host cache doc:

Using ReadWrite cache with an application that does not handle persisting the required data can lead to data loss, if the VM crashes.

ReadWrite cache may lead to data loss when VM crashes according to below doc:
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/premium-storage-performance#disk-caching

Which issue(s) this PR fixes:

Fixes #72228

Special notes for your reviewer:

Release note:

the azure disk persistent volume provisioner has changed the default host cache to ReadOnly, if `cachingmode` is not specified in the StorageClass parameters

/sig azure
/hold

hold this RP temporalily, I will let azure disk team do final confirmation whether ReadOnly is the best default value.
From my side, I have verified that the original issue has been fixed in azure, we can move to use ReadOnly host cache now.

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. kind/bug Categorizes issue or PR as related to a bug. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. sig/azure cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority Indicates a PR lacks a `priority/foo` label and requires one. sig/storage Categorizes an issue or PR as relevant to SIG Storage. labels Dec 20, 2018
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Dec 20, 2018
@andyzhangx
Copy link
Member Author

cc @khenidak @brendandburns

@liggitt
Copy link
Member

liggitt commented Dec 20, 2018

clarify the release note that the changed value is in the azure provisioner, for storage classes that do not specify a caching mode. existing PVs and direct PV creation already defaulted cachingmode to readwrite, and will continue to do so:

func SetDefaults_AzureDiskVolumeSource(obj *v1.AzureDiskVolumeSource) {
if obj.CachingMode == nil {
obj.CachingMode = new(v1.AzureDataDiskCachingMode)
*obj.CachingMode = v1.AzureDataDiskCachingReadWrite
}

@andyzhangx
Copy link
Member Author

andyzhangx commented Dec 21, 2018

Thanks for your remindar.
@liggitt I would also like to change the default value(from ReadWrite to ReadOnly) of caching mode in direct azure disk PV creation, there is one statement in the host cache doc:

Using ReadWrite cache with an application that does not handle persisting the required data can lead to data loss, if the VM crashes.

ReadWrite cache may lead to data loss when VM crashes according to below doc:
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/premium-storage-performance#disk-caching

Let me submit another commit in this PR.
cc @jsafrane

@k8s-ci-robot k8s-ci-robot added sig/apps Categorizes an issue or PR as relevant to SIG Apps. and removed approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 21, 2018
@andyzhangx
Copy link
Member Author

andyzhangx commented Dec 21, 2018

/hold cancel
/assign @liggitt

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 21, 2018
@andyzhangx
Copy link
Member Author

/assign @liggitt

@liggitt
Copy link
Member

liggitt commented Dec 21, 2018

I would also like to change the default value(from ReadWrite to ReadOnly) of caching mode in direct azure disk PV creation, there is one statement in the host cache doc:

Using ReadWrite cache with an application that does not handle persisting the required data can lead to data loss, if the VM crashes.

ReadWrite cache may lead to data loss when VM crashes according to below doc:
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/premium-storage-performance#disk-caching

Reading through that, I agree ReadWrite is not a great default for PVs, but changing an API default is considered a breaking change. We'd need to understand the full impact of changing the default to ReadOnly for an application that was properly handling persisting data. Would it only result in a performance degradation, or would it change behavior in breaking ways as well?

@andyzhangx
Copy link
Member Author

Reading through that, I agree ReadWrite is not a great default for PVs, but changing an API default is considered a breaking change. We'd need to understand the full impact of changing the default to ReadOnly for an application that was properly handling persisting data. Would it only result in a performance degradation, or would it change behavior in breaking ways as well?

Hi @liggitt, I don't think k8s users could properly handling persisting data when using ReadWrite cache, since the write cache is stored in memory in the host OS. ReadWrite cache setting is more suitable for OS level application, e.g. SQL Server, while k8s container only knows about storage, it is not aware of the write cache in memory in host OS. Change ReadWrite to ReadOnly is actually a bug fix for possible data loss.

Below are details about host cache setting, it also applies to Linux:
https://blogs.msdn.microsoft.com/windowsazurestorage/2012/06/27/exploring-windows-azure-drives-disks-and-images/
"
The read cache is stored both on disk and in memory in the host OS. The write cache is stored in memory in the host OS.

WARNING: If your application does not use FILE_FLAG_WRITE_THROUGH, the write cache could result in data loss because the data could be sitting in the host OS memory waiting to be written when the physical machine crashes unexpectedly.
"

@liggitt
Copy link
Member

liggitt commented Dec 28, 2018

I don't think k8s users could properly handling persisting data when using ReadWrite cache, since the write cache is stored in memory in the host OS.

Write caches are common in many environments, both in software and in hardware. Software responsible for persisting data typically makes use of syscalls like fsync() to ensure data has actually been persisted. I'm not familiar with the FILE_FLAG_WRITE_THROUGH option documented, but it sounds similar to fsync().

A couple questions:

  1. Would making use of the OS-appropriate method (e.g. fsync(), FILE_FLAG_WRITE_THROUGH, etc) ensure data was properly persisted? The case for changing the default is weaker if standard methods for ensuring data is persisted are honored by this cache.
  2. Would changing the default from Read/Write to ReadOnly modify functional behavior or just performance characteristics? The case for changing the default is weaker if it could cause any functional regression in applications that currently are working properly

@liggitt
Copy link
Member

liggitt commented Dec 28, 2018

It looks like the field was added in 1.4 with a default of None (dea4b02#diff-14b477f6f8ca5978c702f4d21641e43f), and the default was changed to ReadWrite in 1.7 (4177b28#diff-14b477f6f8ca5978c702f4d21641e43fR242)

change cachingMode default value for azure disk PV

revert back to ReadWrite in azure disk PV setting
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andyzhangx

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 4, 2019
@andyzhangx
Copy link
Member Author

Hi @liggitt I have reverted the code change of the cachingMode change in azure disk default PV setting, now this PR only changes the cachingMode from None to ReadOnly in azure disk storage class which is quite safe.
Could you take a look? Thanks.

@liggitt
Copy link
Member

liggitt commented Jan 4, 2019

updated release note. lgtm, will let @kubernetes/sig-storage-pr-reviews tag

@andyzhangx
Copy link
Member Author

/assign @feiskyer
/priority important-soon

@k8s-ci-robot k8s-ci-robot added priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. and removed needs-priority Indicates a PR lacks a `priority/foo` label and requires one. labels Jan 4, 2019
@liggitt liggitt removed their assignment Jan 4, 2019
Copy link
Member

@feiskyer feiskyer left a comment

Choose a reason for hiding this comment

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

/lgtm
/retest

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jan 5, 2019
@andyzhangx
Copy link
Member Author

/test pull-kubernetes-e2e-gce-100-performance
/test pull-kubernetes-e2e-kops-aws

@k8s-ci-robot k8s-ci-robot merged commit b006342 into kubernetes:master Jan 5, 2019
@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Jan 5, 2019

@andyzhangx: The following test failed, say /retest to rerun them all:

Test name Commit Details Rerun command
pull-kubernetes-e2e-kops-aws 53145d7 link /test pull-kubernetes-e2e-kops-aws

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

k8s-ci-robot added a commit that referenced this pull request Jan 8, 2019
…2229-upstream-release-1.13

Automated cherry pick of #72229
k8s-ci-robot added a commit that referenced this pull request Jan 8, 2019
…2229-upstream-release-1.12

Automated cherry pick of #72229
k8s-ci-robot added a commit that referenced this pull request Jan 12, 2019
…2229-upstream-release-1.11

Automated cherry pick of #72229
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/apps Categorizes an issue or PR as relevant to SIG Apps. sig/storage Categorizes an issue or PR as relevant to SIG Storage. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

change azure disk host cache to ReadOnly
4 participants