Bug 1467244 - Dynamic Volume Provisioner creates unencrypted volumes
Summary: Dynamic Volume Provisioner creates unencrypted volumes
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Storage
Version: 3.8.0
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: 3.10.z
Assignee: Jan Safranek
QA Contact: Liang Xia
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2017-07-03 08:45 UTC by Vladislav Walek
Modified: 2018-08-31 06:18 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: No Doc Update
Doc Text:
undefined
Clone Of:
Environment:
Last Closed: 2018-08-31 06:18:10 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2018:2376 0 None None None 2018-08-31 06:18:58 UTC

Description Vladislav Walek 2017-07-03 08:45:14 UTC
Description of problem:

We are using the AWS dynamic volume provisioner with KMS encrypted EBS volumes. 
If the storageclass is configured with "encrypted: true" an a KMS key id but no key rights are granted for the EC2 instance, the volume creation should fail.
Instead, the volumes are created unencrypted.

Version-Release number of selected component (if applicable):
OpenShift Container Platform 3.5 on AWS

How reproducible:

Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:

Master Log:

Node Log (of failed PODs):

PV Dump:

PVC Dump:

StorageClass Dump (if StorageClass used by PV/PVC):

Additional info:

Comment 1 Jan Safranek 2017-07-03 12:46:56 UTC
I'll look at it

Comment 2 Jan Safranek 2017-07-03 14:51:01 UTC
I reproduced something, not sure if it is the same bug... When StorageClass for AWS refers to an non-existing encryption key then dynamic provisioning looks like it's working, it provisions a PV and binds it to a PVC, but the underlying AWS EBS does not exist.

The reason is that AWS API returns a successfully created AWS EBS when creating one with invalid KSM:

$ aws ec2 create-volume --size=1 --volume-type=gp2 --availability-zone=us-east-1d --encrypted --kms-key-id=arn:aws:kms:us-east-1:599999999999:alias/nonExistingKey

{
    "VolumeId": "vol-0441169d687c7f108",
    "Size": 1,
...
}

But the volume actually does not exist:

$ aws ec2 describe-volumes --volume-ids=vol-0441169d687c7f108

An error occurred (InvalidVolume.NotFound) when calling the DescribeVolumes operation: The volume 'vol-0441169d687c7f108' does not exist.


Please ask the customer if it observes similar behavior (or what behavior do they actually observe... openshift-master logs would be helpful)

Comment 3 Jan Safranek 2017-07-03 15:16:07 UTC
Filled an issue upstream: https://github.com/kubernetes/kubernetes/issues/48438

Comment 6 Jan Safranek 2017-07-14 11:52:06 UTC
Posted a PR  upstream: https://github.com/kubernetes/kubernetes/pull/48936

Not sure if it fixes customer problem though.

Comment 8 Vladislav Walek 2017-07-20 08:36:41 UTC
Hello Jan,

here are the steps how to reproduce the issue:

this issue is similar to ours, but not the same. Steps to reproduce our issue:

* Create a new KMS key and grant no usage rights to anyone
* Create a new StorageClass with "encrypted: true" and specify the newly created KMS key
* Create a PersistentVolumeClaim

Expected result:
The volume creation should fail, as the OpenShift master does not have the rights to create encrypted EBS volumes with the specified KMS key.

Actual result:
The volume creation succeeds but the volume is not encrypted.

Comment 9 Jan Safranek 2017-07-20 16:00:05 UTC
> The volume creation succeeds but the volume is not encrypted.

I see a different behavior. On my machine, Kubernetes looks like it provisions AWS EBS + Kubernetes PV, however the EBS disappears in a second. I can't check if it's encrypted or unencrypted. I'll fix it by checking if any provided key exists before trying to create a volume with it. If nobody (incl. Kubernetes) has no access to the key, then I can't check existence of the key and it will behave the same way...

Comment 12 Jan Safranek 2017-09-08 10:59:50 UTC
Origin PR: https://github.com/openshift/origin/pull/16234

Comment 16 Jan Safranek 2018-01-08 09:58:11 UTC
It should be fixed in 3.8 by Kubernetes rebase.

Comment 27 Jan Safranek 2018-04-03 13:05:30 UTC
I can confirm the bug persists if OpenShift gets AccessDeniedException when checking KMS key.

And this can't be easily fixed: AccessDeniedException says that OpenShift can't access the key, it does not say that OpenShift can't provision volumes with that key - KMS may allow AWS EBS to use the key for encryption.

AWS does *not* return any sane error code when provisioning with inaccessible key fails, it returns a volume that exists for a while and then it's deleted.

AWS suggests is to subscribe to CloudWatch Events:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-cloud-watch-events.html#create-fail-key

This will require 1) quite big change in AWS provider and 2) OpenShift needs to get new permissions to read CloudWatch, which is IMO no-go.

Comment 34 Jan Safranek 2018-06-22 06:50:40 UTC
Origin PR: https://github.com/openshift/origin/pull/20072

Comment 37 Jan Safranek 2018-08-10 07:52:50 UTC
It's fixed in v3.10.8-1, waiting for qa to pick it up.

Comment 39 Liang Xia 2018-08-27 08:15:36 UTC
Tried the same step as in #comment 22,

# oc describe pvc mypvc
Name:          mypvc
Namespace:     default
StorageClass:  test
Status:        Pending
Volume:        
Labels:        name=dynamic-pvc
Annotations:   volume.beta.kubernetes.io/storage-provisioner=kubernetes.io/aws-ebs
Finalizers:    [kubernetes.io/pvc-protection]
Capacity:      
Access Modes:  
Events:
  Type     Reason              Age               From                         Message
  ----     ------              ----              ----                         -------
  Warning  ProvisioningFailed  3m (x26 over 9m)  persistentvolume-controller  Failed to provision volume with StorageClass "test": failed to create encrypted volume: the volume disappeared after creation, most likely due to inaccessible KMS encryption key



According #comment 32, we have clear error message now. 
Moving bug to verified.


# oc version
oc v3.10.34
kubernetes v1.10.0+b81c8f8
features: Basic-Auth GSSAPI Kerberos SPNEGO

Comment 40 Liang Xia 2018-08-27 08:18:02 UTC
# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.5 (Maipo)

# uname -a
Linux ip-172-18-8-164.ec2.internal 3.10.0-862.9.1.el7.x86_64 #1 SMP Wed Jun 27 04:30:39 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux

Comment 42 errata-xmlrpc 2018-08-31 06:18:10 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:2376


Note You need to log in before you can comment on or make changes to this bug.