Skip to content

Commit 5aed7eb

Browse files
bvliucopybara-github
authored andcommitted
Cleanup and deprecate managed single-server Azure MySQL and Postgres databases.
PiperOrigin-RevId: 819851591
1 parent f9e71e6 commit 5aed7eb

File tree

2 files changed

+59
-206
lines changed

2 files changed

+59
-206
lines changed

perfkitbenchmarker/providers/azure/azure_flexible_server.py

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
"""Relational database provisioning and teardown for Azure RDS."""
14+
"""Azure Flexible server provisioning and teardown."""
1515

1616
import datetime
1717
import logging
@@ -52,8 +52,6 @@ class AzureFlexibleServer(azure_relational_db.AzureRelationalDb):
5252
Instructions from:
5353
https://learn.microsoft.com/en-us/azure/postgresql/flexible-server/
5454
55-
On teardown, all resources are deleted.
56-
5755
Note that the client VM's region and the region requested for the database
5856
must be the same.
5957
"""
@@ -66,18 +64,8 @@ class AzureFlexibleServer(azure_relational_db.AzureRelationalDb):
6664
]
6765

6866
@staticmethod
69-
def GetDefaultEngineVersion(engine: str):
70-
"""Returns the default version of a given database engine.
71-
72-
Args:
73-
engine: type of database (my_sql or postgres).
74-
75-
Returns:
76-
(string): Default engine version.
77-
Raises:
78-
RelationalDbEngineNotFoundError: if an unknown engine is
79-
requested.
80-
"""
67+
def GetDefaultEngineVersion(engine: str) -> str:
68+
"""Returns the default version of a given database engine."""
8169
if engine == sql_engine_utils.POSTGRES:
8270
return DEFAULT_POSTGRES_VERSION
8371
elif engine == sql_engine_utils.MYSQL:
@@ -87,8 +75,8 @@ def GetDefaultEngineVersion(engine: str):
8775
'Unsupported engine {}'.format(engine)
8876
)
8977

90-
def _Create(self):
91-
"""Creates the Azure RDS instance."""
78+
def _Create(self) -> None:
79+
"""Creates the Azure database instance."""
9280
ha_flag = ENABLE_HA if self.spec.high_availability else DISABLE_HA
9381
cmd = [
9482
azure.AZURE_PATH,
@@ -120,17 +108,16 @@ def _Create(self):
120108

121109
vm_util.IssueCommand(cmd, timeout=CREATE_AZURE_DB_TIMEOUT)
122110

123-
def GetAzCommandForEngine(self):
111+
def GetAzCommandForEngine(self) -> str:
124112
engine = self.spec.engine
125113
if engine == sql_engine_utils.FLEXIBLE_SERVER_POSTGRES:
126114
return 'postgres'
127115
elif engine == sql_engine_utils.FLEXIBLE_SERVER_MYSQL:
128116
return 'mysql'
129117
else:
130118
raise NotImplementedError('Unsupported engine {}'.format(engine))
131-
return engine
132119

133-
def _PostCreate(self):
120+
def _PostCreate(self) -> None:
134121
"""Perform general post create operations on the cluster."""
135122
# Calling the grand parent class.
136123
super(azure_relational_db.AzureRelationalDb, self)._PostCreate()
@@ -180,21 +167,10 @@ def SetDbConfiguration(self, name: str, value: str) -> Tuple[str, str, int]:
180167
'--server',
181168
self.instance_id,
182169
]
183-
return vm_util.IssueCommand(cmd)
170+
return vm_util.IssueCommand(cmd, raise_on_failure=False)
184171

185-
def _IsInstanceReady(self, timeout=IS_READY_TIMEOUT):
186-
"""Return true if the instance is ready.
187-
188-
This method will query the instance every 5 seconds until
189-
its instance state is 'Ready', or until a timeout occurs.
190-
191-
Args:
192-
timeout: timeout in seconds
193-
194-
Returns:
195-
True if the resource was ready in time, False if the wait timed out
196-
or an Exception occurred.
197-
"""
172+
def _IsInstanceReady(self, timeout: int = IS_READY_TIMEOUT) -> bool:
173+
"""See base class."""
198174
start_time = datetime.datetime.now()
199175

200176
while True:
@@ -203,15 +179,15 @@ def _IsInstanceReady(self, timeout=IS_READY_TIMEOUT):
203179
return False
204180

205181
server_show_json = self._AzServerShow()
206-
state = server_show_json['state']
207182
if server_show_json is not None:
183+
state = server_show_json['state']
208184
if state == 'Ready':
209185
break
210186
time.sleep(5)
211187
return True
212188

213-
def _ApplyDbFlags(self):
214-
"""Applies the MySqlFlags to a managed instance."""
189+
def _ApplyDbFlags(self) -> None:
190+
"""Apply database flags to the instance."""
215191
for flag in FLAGS.db_flags:
216192
name_and_value = flag.split('=')
217193
cmd = [

0 commit comments

Comments
 (0)