Skip to content

Commit 6031fd4

Browse files
Revert "new: Add support for Linode Disk Encryption (linode#413)" (linode#435)
1 parent 639588d commit 6031fd4

13 files changed

+20
-177
lines changed

linode_api4/groups/linode.py

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import base64
22
import os
33
from collections.abc import Iterable
4-
from typing import Optional, Union
54

6-
from linode_api4 import InstanceDiskEncryptionType
75
from linode_api4.common import load_and_validate_keys
86
from linode_api4.errors import UnexpectedResponseError
97
from linode_api4.groups import Group
@@ -130,15 +128,7 @@ def kernels(self, *filters):
130128

131129
# create things
132130
def instance_create(
133-
self,
134-
ltype,
135-
region,
136-
image=None,
137-
authorized_keys=None,
138-
disk_encryption: Optional[
139-
Union[InstanceDiskEncryptionType, str]
140-
] = None,
141-
**kwargs,
131+
self, ltype, region, image=None, authorized_keys=None, **kwargs
142132
):
143133
"""
144134
Creates a new Linode Instance. This function has several modes of operation:
@@ -273,8 +263,6 @@ def instance_create(
273263
:type metadata: dict
274264
:param firewall: The firewall to attach this Linode to.
275265
:type firewall: int or Firewall
276-
:param disk_encryption: The disk encryption policy for this Linode.
277-
:type disk_encryption: InstanceDiskEncryptionType or str
278266
:param interfaces: An array of Network Interfaces to add to this Linode’s Configuration Profile.
279267
At least one and up to three Interface objects can exist in this array.
280268
:type interfaces: list[ConfigInterface] or list[dict[str, Any]]
@@ -342,9 +330,6 @@ def instance_create(
342330
"authorized_keys": authorized_keys,
343331
}
344332

345-
if disk_encryption is not None:
346-
params["disk_encryption"] = str(disk_encryption)
347-
348333
params.update(kwargs)
349334

350335
result = self.client.post("/linode/instances", data=params)

linode_api4/objects/linode.py

Lines changed: 1 addition & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,12 @@
2222
from linode_api4.objects.base import MappedObject
2323
from linode_api4.objects.filtering import FilterableAttribute
2424
from linode_api4.objects.networking import IPAddress, IPv6Range, VPCIPAddress
25-
from linode_api4.objects.serializable import StrEnum
2625
from linode_api4.objects.vpc import VPC, VPCSubnet
2726
from linode_api4.paginated_list import PaginatedList
2827

2928
PASSWORD_CHARS = string.ascii_letters + string.digits + string.punctuation
3029

3130

32-
class InstanceDiskEncryptionType(StrEnum):
33-
"""
34-
InstanceDiskEncryptionType defines valid values for the
35-
Instance(...).disk_encryption field.
36-
37-
API Documentation: TODO
38-
"""
39-
40-
enabled = "enabled"
41-
disabled = "disabled"
42-
43-
4431
class Backup(DerivedBase):
4532
"""
4633
A Backup of a Linode Instance.
@@ -127,7 +114,6 @@ class Disk(DerivedBase):
127114
"filesystem": Property(),
128115
"updated": Property(is_datetime=True),
129116
"linode_id": Property(identifier=True),
130-
"disk_encryption": Property(),
131117
}
132118

133119
def duplicate(self):
@@ -676,8 +662,6 @@ class Instance(Base):
676662
"host_uuid": Property(),
677663
"watchdog_enabled": Property(mutable=True),
678664
"has_user_data": Property(),
679-
"disk_encryption": Property(),
680-
"lke_cluster_id": Property(),
681665
}
682666

683667
@property
@@ -1407,16 +1391,7 @@ def ip_allocate(self, public=False):
14071391
i = IPAddress(self._client, result["address"], result)
14081392
return i
14091393

1410-
def rebuild(
1411-
self,
1412-
image,
1413-
root_pass=None,
1414-
authorized_keys=None,
1415-
disk_encryption: Optional[
1416-
Union[InstanceDiskEncryptionType, str]
1417-
] = None,
1418-
**kwargs,
1419-
):
1394+
def rebuild(self, image, root_pass=None, authorized_keys=None, **kwargs):
14201395
"""
14211396
Rebuilding an Instance deletes all existing Disks and Configs and deploys
14221397
a new :any:`Image` to it. This can be used to reset an existing
@@ -1434,8 +1409,6 @@ def rebuild(
14341409
be a single key, or a path to a file containing
14351410
the key.
14361411
:type authorized_keys: list or str
1437-
:param disk_encryption: The disk encryption policy for this Linode.
1438-
:type disk_encryption: InstanceDiskEncryptionType or str
14391412
14401413
:returns: The newly generated password, if one was not provided
14411414
(otherwise True)
@@ -1453,10 +1426,6 @@ def rebuild(
14531426
"root_pass": root_pass,
14541427
"authorized_keys": authorized_keys,
14551428
}
1456-
1457-
if disk_encryption is not None:
1458-
params["disk_encryption"] = str(disk_encryption)
1459-
14601429
params.update(kwargs)
14611430

14621431
result = self._client.post(
@@ -1786,22 +1755,6 @@ def stats(self):
17861755
"{}/stats".format(Instance.api_endpoint), model=self
17871756
)
17881757

1789-
@property
1790-
def lke_cluster(self) -> Optional["LKECluster"]:
1791-
"""
1792-
Returns the LKE Cluster this Instance is a node of.
1793-
1794-
:returns: The LKE Cluster this Instance is a node of.
1795-
:rtype: Optional[LKECluster]
1796-
"""
1797-
1798-
# Local import to prevent circular dependency
1799-
from linode_api4.objects.lke import ( # pylint: disable=import-outside-toplevel
1800-
LKECluster,
1801-
)
1802-
1803-
return LKECluster(self._client, self.lke_cluster_id)
1804-
18051758
def stats_for(self, dt):
18061759
"""
18071760
Returns stats for the month containing the given datetime

linode_api4/objects/lke.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@ class LKENodePool(DerivedBase):
132132
"cluster_id": Property(identifier=True),
133133
"type": Property(slug_relationship=Type),
134134
"disks": Property(),
135-
"disk_encryption": Property(),
136135
"count": Property(mutable=True),
137136
"nodes": Property(
138137
volatile=True

test/fixtures/linode_instances.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
"tags": ["something"],
4242
"host_uuid": "3a3ddd59d9a78bb8de041391075df44de62bfec8",
4343
"watchdog_enabled": true,
44-
"disk_encryption": "disabled",
45-
"lke_cluster_id": null,
4644
"placement_group": {
4745
"id": 123,
4846
"label": "test",
@@ -88,8 +86,6 @@
8886
"tags": [],
8987
"host_uuid": "3a3ddd59d9a78bb8de041391075df44de62bfec8",
9088
"watchdog_enabled": false,
91-
"disk_encryption": "enabled",
92-
"lke_cluster_id": 18881,
9389
"placement_group": null
9490
}
9591
]

test/fixtures/linode_instances_123_disks.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
"id": 12345,
1111
"updated": "2017-01-01T00:00:00",
1212
"label": "Ubuntu 17.04 Disk",
13-
"created": "2017-01-01T00:00:00",
14-
"disk_encryption": "disabled"
13+
"created": "2017-01-01T00:00:00"
1514
},
1615
{
1716
"size": 512,
@@ -20,8 +19,7 @@
2019
"id": 12346,
2120
"updated": "2017-01-01T00:00:00",
2221
"label": "512 MB Swap Image",
23-
"created": "2017-01-01T00:00:00",
24-
"disk_encryption": "disabled"
22+
"created": "2017-01-01T00:00:00"
2523
}
2624
]
2725
}

test/fixtures/linode_instances_123_disks_12345_clone.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"id": 12345,
66
"updated": "2017-01-01T00:00:00",
77
"label": "Ubuntu 17.04 Disk",
8-
"created": "2017-01-01T00:00:00",
9-
"disk_encryption": "disabled"
8+
"created": "2017-01-01T00:00:00"
109
}
1110

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"id": "123456",
3-
"instance_id": 456,
3+
"instance_id": 123458,
44
"status": "ready"
55
}

test/fixtures/lke_clusters_18881_pools_456.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@
2323
"example tag",
2424
"another example"
2525
],
26-
"type": "g6-standard-4",
27-
"disk_encryption": "enabled"
26+
"type": "g6-standard-4"
2827
}

test/integration/helpers.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ def wait_for_condition(
7979

8080

8181
# Retry function to help in case of requests sending too quickly before instance is ready
82-
def retry_sending_request(
83-
retries: int, condition: Callable, *args, **kwargs
84-
) -> object:
82+
def retry_sending_request(retries: int, condition: Callable, *args) -> object:
8583
curr_t = 0
8684
while curr_t < retries:
8785
try:
8886
curr_t += 1
89-
res = condition(*args, **kwargs)
87+
res = condition(*args)
9088
return res
9189
except ApiError:
9290
if curr_t >= retries:

test/integration/models/linode/test_linode.py

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import time
2-
from test.integration.conftest import get_region
32
from test.integration.helpers import (
43
get_test_label,
54
retry_sending_request,
@@ -19,7 +18,7 @@
1918
Instance,
2019
Type,
2120
)
22-
from linode_api4.objects.linode import InstanceDiskEncryptionType, MigrationType
21+
from linode_api4.objects.linode import MigrationType
2322

2423

2524
@pytest.fixture(scope="session")
@@ -143,30 +142,6 @@ def create_linode_for_long_running_tests(test_linode_client, e2e_test_firewall):
143142
linode_instance.delete()
144143

145144

146-
@pytest.fixture(scope="function")
147-
def linode_with_disk_encryption(test_linode_client, request):
148-
client = test_linode_client
149-
150-
target_region = get_region(client, {"Disk Encryption"})
151-
timestamp = str(time.time_ns())
152-
label = "TestSDK-" + timestamp
153-
154-
disk_encryption = request.param
155-
156-
linode_instance, password = client.linode.instance_create(
157-
"g6-nanode-1",
158-
target_region,
159-
image="linode/ubuntu23.04",
160-
label=label,
161-
booted=False,
162-
disk_encryption=disk_encryption,
163-
)
164-
165-
yield linode_instance
166-
167-
linode_instance.delete()
168-
169-
170145
# Test helper
171146
def get_status(linode: Instance, status: str):
172147
return linode.status == status
@@ -195,7 +170,8 @@ def test_linode_transfer(test_linode_client, linode_with_volume_firewall):
195170

196171
def test_linode_rebuild(test_linode_client):
197172
client = test_linode_client
198-
chosen_region = get_region(client, {"Disk Encryption"})
173+
available_regions = client.regions()
174+
chosen_region = available_regions[4]
199175
label = get_test_label() + "_rebuild"
200176

201177
linode, password = client.linode.instance_create(
@@ -204,18 +180,12 @@ def test_linode_rebuild(test_linode_client):
204180

205181
wait_for_condition(10, 100, get_status, linode, "running")
206182

207-
retry_sending_request(
208-
3,
209-
linode.rebuild,
210-
"linode/debian10",
211-
disk_encryption=InstanceDiskEncryptionType.disabled,
212-
)
183+
retry_sending_request(3, linode.rebuild, "linode/debian10")
213184

214185
wait_for_condition(10, 100, get_status, linode, "rebuilding")
215186

216187
assert linode.status == "rebuilding"
217188
assert linode.image.id == "linode/debian10"
218-
assert linode.disk_encryption == InstanceDiskEncryptionType.disabled
219189

220190
wait_for_condition(10, 300, get_status, linode, "running")
221191

@@ -418,18 +388,6 @@ def test_linode_volumes(linode_with_volume_firewall):
418388
assert "test" in volumes[0].label
419389

420390

421-
@pytest.mark.parametrize(
422-
"linode_with_disk_encryption", ["disabled"], indirect=True
423-
)
424-
def test_linode_with_disk_encryption_disabled(linode_with_disk_encryption):
425-
linode = linode_with_disk_encryption
426-
427-
assert linode.disk_encryption == InstanceDiskEncryptionType.disabled
428-
assert (
429-
linode.disks[0].disk_encryption == InstanceDiskEncryptionType.disabled
430-
)
431-
432-
433391
def wait_for_disk_status(disk: Disk, timeout):
434392
start_time = time.time()
435393
while True:

test/integration/models/lke/test_lke.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
import base64
22
import re
3-
from test.integration.conftest import get_region
43
from test.integration.helpers import (
54
get_test_label,
65
send_request_when_resource_available,
76
wait_for_condition,
87
)
9-
from typing import Any, Dict
108

119
import pytest
1210

1311
from linode_api4 import (
14-
InstanceDiskEncryptionType,
1512
LKEClusterControlPlaneACLAddressesOptions,
1613
LKEClusterControlPlaneACLOptions,
1714
LKEClusterControlPlaneOptions,
@@ -24,7 +21,7 @@
2421
def lke_cluster(test_linode_client):
2522
node_type = test_linode_client.linode.types()[1] # g6-standard-1
2623
version = test_linode_client.lke.versions()[0]
27-
region = get_region(test_linode_client, {"Disk Encryption", "Kubernetes"})
24+
region = test_linode_client.regions().first()
2825
node_pools = test_linode_client.lke.node_pool(node_type, 3)
2926
label = get_test_label() + "_cluster"
3027

@@ -41,7 +38,7 @@ def lke_cluster(test_linode_client):
4138
def lke_cluster_with_acl(test_linode_client):
4239
node_type = test_linode_client.linode.types()[1] # g6-standard-1
4340
version = test_linode_client.lke.versions()[0]
44-
region = get_region(test_linode_client, {"Kubernetes"})
41+
region = test_linode_client.regions().first()
4542
node_pools = test_linode_client.lke.node_pool(node_type, 1)
4643
label = get_test_label() + "_cluster"
4744

@@ -84,21 +81,9 @@ def test_get_lke_clusters(test_linode_client, lke_cluster):
8481
def test_get_lke_pool(test_linode_client, lke_cluster):
8582
cluster = lke_cluster
8683

87-
wait_for_condition(
88-
10,
89-
500,
90-
get_node_status,
91-
cluster,
92-
"ready",
93-
)
94-
9584
pool = test_linode_client.load(LKENodePool, cluster.pools[0].id, cluster.id)
9685

97-
def _to_comparable(p: LKENodePool) -> Dict[str, Any]:
98-
return {k: v for k, v in p._raw_json.items() if k not in {"nodes"}}
99-
100-
assert _to_comparable(cluster.pools[0]) == _to_comparable(pool)
101-
assert pool.disk_encryption == InstanceDiskEncryptionType.enabled
86+
assert cluster.pools[0].id == pool.id
10287

10388

10489
def test_cluster_dashboard_url_view(lke_cluster):

0 commit comments

Comments
 (0)