-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add support for managing EFS provisioned throughput (#9)
* feat: improve TF validations * feat: add support for EFS provisioned throughput * chore: remove KMS key ARN validation * chore: satisfy linter * chore: fix typo in variable description * docs: add goal of the module
- Loading branch information
1 parent
1e619a9
commit b3733a1
Showing
10 changed files
with
151 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
scheduler/scheduler/resource_controllers/efs_file_system_controller.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import boto3 | ||
from typing import Tuple | ||
|
||
from scheduler.resource_controller import ResourceController | ||
|
||
EFS_MINIMAL_THROUGHPUT_CAPACITY = 1.0 | ||
|
||
efs = boto3.client("efs") | ||
|
||
|
||
class EfsFileSystemController(ResourceController): | ||
def __init__( | ||
self, | ||
id: str, | ||
provisioned_throughput_in_mibps: str, | ||
): | ||
super().__init__() | ||
self.id = id | ||
self.provisioned_throughput_in_mibps = float( | ||
int(provisioned_throughput_in_mibps) | ||
) | ||
|
||
def start(self) -> Tuple[bool, str]: | ||
file_system = efs.describe_file_systems(FileSystemId=self.id)["FileSystems"][0] | ||
if file_system["FileSystems"][0]["ThroughputMode"] != "provisioned": | ||
return ( | ||
False, | ||
f"EFS Filesystem {self.id} is not in provisioned throughput mode", | ||
) | ||
|
||
efs.update_file_system( | ||
FileSystemId=self.id, | ||
ThroughputMode="provisioned", | ||
ProvisionedThroughputInMibps=self.provisioned_throughput_in_mibps, | ||
) | ||
|
||
return ( | ||
True, | ||
f"Throughput capacity for {self.id} adjusted to {self.provisioned_throughput_in_mibps} MB/s", | ||
) | ||
|
||
def stop(self) -> Tuple[bool, str]: | ||
file_system = efs.describe_file_systems(FileSystemId=self.id)["FileSystems"][0] | ||
if file_system["FileSystems"][0]["ThroughputMode"] != "provisioned": | ||
return ( | ||
False, | ||
f"EFS Filesystem {self.id} is not in provisioned throughput mode", | ||
) | ||
|
||
efs.update_file_system( | ||
FileSystemId=self.id, | ||
ThroughputMode="provisioned", | ||
ProvisionedThroughputInMibps=EFS_MINIMAL_THROUGHPUT_CAPACITY, | ||
) | ||
|
||
return ( | ||
True, | ||
f"Throughput capacity for {self.id} adjusted to {EFS_MINIMAL_THROUGHPUT_CAPACITY} MB/s", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters