@@ -820,8 +820,6 @@ def run_database_creation_workload_for_source_version(
820
820
command:
821
821
- /var/local/db_init.sh
822
822
name: airflow-database-init-job
823
- securityContext:
824
- privileged: true
825
823
env:
826
824
- name: GCS_BUCKET
827
825
value: { bucket }
@@ -933,7 +931,7 @@ def _remove_temporary_kubeconfig(self: typing.Any) -> None:
933
931
934
932
def _grant_permissions (self : typing .Any ) -> None :
935
933
"""Grants required permissions."""
936
- if not self .is_drs_enabled :
934
+ if not self .is_drs_compliant :
937
935
logger .info ("*** Granting required permissions..." )
938
936
EnvironmentUtils .grant_permissions_to_the_bucket (
939
937
self .sql_service_account ,
@@ -946,7 +944,7 @@ def _grant_permissions(self: typing.Any) -> None:
946
944
def _revoke_permissions (self : typing .Any ) -> None :
947
945
"""Revokes no longer required permissions."""
948
946
logger .info ("*** Revoking no longer needed permissions..." )
949
- if not self .is_drs_enabled :
947
+ if not self .is_drs_compliant :
950
948
EnvironmentUtils .revoke_permissions_to_the_bucket (
951
949
self .sql_service_account ,
952
950
self .gcs_bucket_name ,
@@ -1043,12 +1041,6 @@ def _check_composer_system_namespace(self: typing.Any) -> None:
1043
1041
self .composer_system_namespace_exists = True
1044
1042
except Exception :
1045
1043
self .composer_system_namespace_exists = False
1046
- if self .composer_system_namespace_exists :
1047
- raise Exception (
1048
- "'composer-system' namespace has been detected in your GKE cluster. "
1049
- "It means that your environment is newer than this script. Please "
1050
- "check if newer version of this script is available."
1051
- )
1052
1044
1053
1045
def _check_cloud_sql_proxy (self : typing .Any ) -> None :
1054
1046
"""Sets sql proxy."""
@@ -1064,8 +1056,8 @@ def _check_cloud_sql_proxy(self: typing.Any) -> None:
1064
1056
1065
1057
def _check_drs_and_select_db_storage_bucket (self : typing .Any ) -> None :
1066
1058
"""Checks if the environment is DRS-compliant."""
1067
- logger .info ("*** Checking if DRS is enabled ..." )
1068
- self .is_drs_enabled = False
1059
+ logger .info ("*** Checking if the environment is DRS-compliant ..." )
1060
+ self .is_drs_compliant = False
1069
1061
bucket_name_prefix = self .cp_bucket_name [: - len ("-bucket" )]
1070
1062
agent_bucket_name = f"{ bucket_name_prefix } -agent"
1071
1063
try :
@@ -1077,17 +1069,19 @@ def _check_drs_and_select_db_storage_bucket(self: typing.Any) -> None:
1077
1069
log_command = False ,
1078
1070
log_error = False ,
1079
1071
)
1080
- self .is_drs_enabled = True
1072
+ self .is_drs_compliant = True
1081
1073
logger .info (
1082
- "%s bucket has been found -> DRS is enabled." , agent_bucket_name
1074
+ "%s bucket has been found -> environment is DRS compliant." ,
1075
+ agent_bucket_name ,
1083
1076
)
1084
1077
except Exception as e : # pylint: disable=broad-except
1085
1078
logger .info (
1086
- "%s bucket has not been found -> DRS is disabled. (%s)" ,
1079
+ "%s bucket has not been found -> environment is not DRS compliant."
1080
+ " (%s)" ,
1087
1081
agent_bucket_name ,
1088
1082
e ,
1089
1083
)
1090
- if self .is_drs_enabled :
1084
+ if self .is_drs_compliant :
1091
1085
self .gcs_bucket_name = agent_bucket_name
1092
1086
logger .info ("Bucket in customer project: %s." , self .cp_bucket_name )
1093
1087
logger .info ("Bucket accessible from tenant project: %s." , self .gcs_bucket_name )
@@ -1116,9 +1110,7 @@ def __init__(
1116
1110
self .is_good_airflow_version = (
1117
1111
lambda a , b , c : True if a == 2 and (b > 0 or c >= 1 ) else False
1118
1112
)
1119
- self .bad_airflow_message = (
1120
- "Import operation supports only Airflow 2.0.1+."
1121
- )
1113
+ self .bad_airflow_message = "Import operation supports only Airflow 2.0.1+."
1122
1114
1123
1115
def _read_source_fernet_key (self : typing .Any ) -> None :
1124
1116
"""Reads fernet key from source environment."""
@@ -1149,9 +1141,9 @@ def _cloud_storage_path_to_imported_table(self: typing.Any, table: str) -> None:
1149
1141
"""Translates table name into a path to CSV file."""
1150
1142
return f"gs://{ self .gcs_bucket_name } /import/tables/{ table } .csv"
1151
1143
1152
- def _copy_csv_files_to_tp_if_drs_is_enabled (self : typing .Any ) -> None :
1144
+ def _copy_csv_files_to_tp_if_drs_compliant (self : typing .Any ) -> None :
1153
1145
"""Copies CSV files to tenant project if DRS is enabled."""
1154
- if self .is_drs_enabled :
1146
+ if self .is_drs_compliant :
1155
1147
logger .info ("*** Copying CSV files to tenant project..." )
1156
1148
command = (
1157
1149
f"gsutil -m cp -r gs://{ self .cp_bucket_name } /import/tables/* "
@@ -1458,7 +1450,7 @@ def import_database(self: typing.Any) -> None:
1458
1450
self ._check_environment ()
1459
1451
self ._read_source_fernet_key ()
1460
1452
self ._fail_fast_if_there_are_no_files_to_import ()
1461
- self ._copy_csv_files_to_tp_if_drs_is_enabled ()
1453
+ self ._copy_csv_files_to_tp_if_drs_compliant ()
1462
1454
self ._delete_old_temporary_database_if_exists ()
1463
1455
self ._create_new_database ()
1464
1456
self ._initialize_new_database ()
@@ -1568,9 +1560,9 @@ def _postprocess_tables(self: typing.Any) -> None:
1568
1560
for table , _ , _ in tables :
1569
1561
self ._post_process_exported_table (table )
1570
1562
1571
- def _copy_csv_files_to_cp_if_drs_is_enabled (self : typing .Any ) -> None :
1572
- """Copies CSV files to customer's project if DRS is enabled ."""
1573
- if self .is_drs_enabled :
1563
+ def _copy_csv_files_to_cp_if_drs_compliant (self : typing .Any ) -> None :
1564
+ """Copies CSV files to customer's project for DRS-compliant env ."""
1565
+ if self .is_drs_compliant :
1574
1566
logger .info ("*** Copying CSV files to customer's project..." )
1575
1567
command = (
1576
1568
f"gsutil -m cp -r gs://{ self .gcs_bucket_name } /export/tables/* "
@@ -1625,7 +1617,7 @@ def export_database(self: typing.Any) -> None:
1625
1617
self ._export_tables ()
1626
1618
finally :
1627
1619
self ._revoke_permissions ()
1628
- self ._copy_csv_files_to_cp_if_drs_is_enabled ()
1620
+ self ._copy_csv_files_to_cp_if_drs_compliant ()
1629
1621
self ._postprocess_tables ()
1630
1622
self ._export_dags_plugins_and_data ()
1631
1623
self ._remove_temporary_kubeconfig ()
0 commit comments