Skip to content

Commit b682a5d

Browse files
authored
Updated log messages (#148)
* Updated log messages * Enable local hook to remove __init__.py files * Updated documentation * Update project version to 0.3.18 * Update changelog for version v0.3.18 Updated version number and log message details.
1 parent fcd57dd commit b682a5d

4 files changed

Lines changed: 35 additions & 25 deletions

File tree

cfa/cloudops/_function_app_client.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ def _find_available_function_app(self) -> str:
105105
result = self.conn.sql(query).fetchdf()
106106
if not result.empty:
107107
available_function_app = result.iloc[0]["FunctionAppName"]
108+
logger.info(
109+
f"FunctionAppClient._find_available_function_app: Found available function app: {available_function_app}"
110+
)
108111
return available_function_app
109112

110113
def _allocate_function_app(self):
@@ -120,6 +123,9 @@ def _allocate_function_app(self):
120123
TO '{FUNCTION_APPS_CSV_PATH}'
121124
(HEADER, DELIMITER ',', OVERWRITE 1)
122125
""")
126+
logger.info(
127+
f"FunctionAppClient._allocate_function_app: Assigned function app to user package: {self.function_app_name}"
128+
)
123129
return True
124130

125131
def _log_into_portal(self) -> bool:
@@ -146,12 +152,12 @@ def _log_into_portal(self) -> bool:
146152
check=True,
147153
)
148154
logger.info(
149-
"cfaazurefunction.log_into_portal(): Logged into Azure Portal successfully "
155+
"FunctionAppClient.log_into_portal(): Logged into Azure Portal successfully "
150156
)
151157
return True
152158
except subprocess.CalledProcessError as e:
153159
logger.error(
154-
f"cfaazurefunction.log_into_portal(): Error logging into Azure Portal.{e}"
160+
f"FunctionAppClient.log_into_portal(): Error logging into Azure Portal.{e}"
155161
)
156162
return False
157163

@@ -173,12 +179,12 @@ def _enable_health_check(self):
173179
check=True,
174180
)
175181
logger.info(
176-
"cfaazurefunction.enable_health_check(): Function health check enabled."
182+
"FunctionAppClient.enable_health_check(): Function health check enabled."
177183
)
178184
return True
179185
except subprocess.CalledProcessError as e:
180186
logger.error(
181-
f"cfaazurefunction.enable_health_check(): Error updating health check {e}"
187+
f"FunctionAppClient.enable_health_check(): Error updating health check {e}"
182188
)
183189
return False
184190

@@ -200,12 +206,12 @@ def _update_app_settings(self, settings: List[Tuple[str, str]]):
200206
arguments.append(f"{key}={value}")
201207
subprocess.run(arguments, check=True)
202208
logger.info(
203-
"cfaazurefunction.update_app_settings(): Function app settings updated successfully."
209+
"FunctionAppClient.update_app_settings(): Function app settings updated successfully."
204210
)
205211
return True
206212
except subprocess.CalledProcessError as e:
207213
logger.error(
208-
f"cfaazurefunction.update_app_settings(): Error updating app settings for Function App {e}"
214+
f"FunctionAppClient.update_app_settings(): Error updating app settings for Function App {e}"
209215
)
210216
return False
211217

@@ -289,7 +295,7 @@ def _publish_function(
289295
os.chdir(parent_path)
290296
self._delete_deployment_folder()
291297
logger.info(
292-
"cfaazurefunction.publish_function(): Function app published successfully to {self.function_app_name}."
298+
"FunctionAppClient.publish_function(): Function app published successfully to {self.function_app_name}."
293299
)
294300

295301
# Now update the schedule in function app
@@ -382,7 +388,7 @@ def my_function():
382388
function_name = self._find_available_function_app()
383389
if not function_name:
384390
logger.error(
385-
"cfaazurefunction.deploy_function(): Deployment aborted because no function apps are available. Please provision additional function apps."
391+
"FunctionAppClient.deploy_function(): Deployment aborted because no function apps are available. Please provision additional function apps."
386392
)
387393
return False
388394
self.function_app_name = function_name
@@ -398,7 +404,7 @@ def my_function():
398404
return False
399405
if not self._allocate_function_app():
400406
logger.info(
401-
"cfaazurefunction.deploy_function(): Unable to assign function app to user provided applicaion."
407+
"FunctionAppClient.deploy_function(): Unable to assign function app to user provided application."
402408
)
403409
if not self._restart_function():
404410
logger.error(

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
77
The versioning pattern is `major.minor.patch`.
88

99
---
10+
## v0.3.18
11+
- updated log messages in `FunctionAppClient` module to store the correct class name
12+
1013
## v0.3.17
1114
- set a maximum version for libraries to avoid breaking changes from updates
1215

@@ -15,6 +18,7 @@ The versioning pattern is `major.minor.patch`.
1518

1619
## v0.3.15
1720
- set an upper limit for azure-mgmt-batch package to undo its breaking changes
21+
>>>>>>> main
1822
1923
## v0.3.14
2024
- fixed defect in `batch_helpers.get_rel_mnt_path` function for getting optional mount configuration in a pool

docs/FunctionAppClient/index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -303,9 +303,9 @@ FunctionAppClient performs the following operations when the user invokes the `d
303303

304304
| Sequence | Operation | Purpose | Error Log Prefix |
305305
|----------|------------------|---------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------|
306-
| 1 | log_into_portal | Log into Azure portal as service principal | `cfaazurefunction.log_into_portal(): Error logging into Azure Portal.` |
307-
| 2 | publish_function | Create a zip file with Python template and user package. Upload the zip file to function app created in the previous step. | `cfaazurefunction.publish_function(): Error publishing Function App` |
308-
| 3 | restart_function | Restart the function app | `cfaazurefunction.restart_function(): Error restarting Function App` |
306+
| 1 | log_into_portal | Log into Azure portal as service principal | `FunctionAppClient.log_into_portal(): Error logging into Azure Portal.` |
307+
| 2 | publish_function | Create a zip file with Python template and user package. Upload the zip file to function app created in the previous step. | `FunctionAppClient.publish_function(): Error publishing Function App` |
308+
| 3 | restart_function | Restart the function app | `FunctionAppClient.restart_function(): Error restarting Function App` |
309309

310310
All errors and exceptions encountered during deployment shall be written to the console (e.g., Shell, PowerShell). The error log prefix indicates which stage that error occurred in.
311311

@@ -327,29 +327,29 @@ Select logs from cfatimer panel:
327327
### Detailed Error Messages
328328

329329
### Login Errors:
330-
- `cfaazurefunction.retrieve_secret()`: Unable to connect to Key Vault: `AZURE_SERVICE_PRINCIPAL_ID` environment variable is missing.
331-
- `cfaazurefunction.retrieve_secret()`: One of these must be provided: `AZURE_SERVICE_PRINCIPAL_SECRET_NAME` or `AZURE_SERVICE_PRINCIPAL_SECRET`
332-
- `cfaazurefunction.log_into_portal()`: Error logging into Azure Portal.
330+
- `FunctionAppClient.retrieve_secret()`: Unable to connect to Key Vault: `AZURE_SERVICE_PRINCIPAL_ID` environment variable is missing.
331+
- `FunctionAppClient.retrieve_secret()`: One of these must be provided: `AZURE_SERVICE_PRINCIPAL_SECRET_NAME` or `AZURE_SERVICE_PRINCIPAL_SECRET`
332+
- `FunctionAppClient.log_into_portal()`: Error logging into Azure Portal.
333333

334334
### Health Check Errors:
335-
- `cfaazurefunction.enable_health_check()`: Error updating health check
335+
- `FunctionAppClient.enable_health_check()`: Error updating health check
336336

337337
### App Settings Errors:
338-
- `cfaazurefunction.update_app_settings()`: Error updating app settings for Function App
338+
- `FunctionAppClient.update_app_settings()`: Error updating app settings for Function App
339339

340340
### Publishing Errors:
341-
- `cfaazurefunction.publish_function()`: Error publishing Function App
341+
- `FunctionAppClient.publish_function()`: Error publishing Function App
342342

343343
### Restart Errors:
344-
- `cfaazurefunction.restart_function()`: Error restarting Function App
344+
- `FunctionAppClient.restart_function()`: Error restarting Function App
345345

346346
### Deployment Errors:
347347

348-
- `cfaazurefunction.deploy_function()`: Deployment aborted due to missing service principal credentials.
349-
- `cfaazurefunction.deploy_function()`: Deployment aborted due to login failure.
350-
- `cfaazurefunction.deploy_function()`: Deployment aborted because no function apps are available.
351-
- `cfaazurefunction.deploy_function()`: Deployment did not complete because Function App publish operation failed.
352-
- `cfaazurefunction.deploy_function()`: Deployment was completed however Function App restart operation failed.
348+
- `FunctionAppClient.deploy_function()`: Deployment aborted due to missing service principal credentials.
349+
- `FunctionAppClient.deploy_function()`: Deployment aborted due to login failure.
350+
- `FunctionAppClient.deploy_function()`: Deployment aborted because no function apps are available.
351+
- `FunctionAppClient.deploy_function()`: Deployment did not complete because Function App publish operation failed.
352+
- `FunctionAppClient.deploy_function()`: Deployment was completed however Function App restart operation failed.
353353

354354
### Permissions Issues
355355
Ensure the Service Principal has the necessary permissions to read from and write to the Azure Blob Storage.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "cfa.cloudops"
3-
version = "0.3.17"
3+
version = "0.3.18"
44
description = "Cloud storage, batch, functions, MLOps assistance"
55
authors = [
66
{name = "Ryan Raasch", email = "xng3@cdc.gov"}

0 commit comments

Comments
 (0)