airbyte-internal-ops 0.9.1__py3-none-any.whl → 0.10.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -64,6 +64,19 @@ attempts
64
64
  --------
65
65
  id, job_id, attempt_number, log_path, output, status, created_at, updated_at,
66
66
  ended_at, failure_summary, processing_task_queue, attempt_sync_config
67
+
68
+ connector_rollout
69
+ -----------------
70
+ id, actor_definition_id, release_candidate_version_id, initial_version_id, state,
71
+ initial_rollout_pct, current_target_rollout_pct, final_target_rollout_pct,
72
+ has_breaking_changes, max_step_wait_time_mins, updated_by, created_at, updated_at,
73
+ completed_at, expires_at, error_msg, failed_reason, rollout_strategy, workflow_run_id,
74
+ paused_reason, filters, tag
75
+
76
+ Note: state values: 'initialized', 'workflow_started', 'in_progress', 'paused',
77
+ 'finalizing', 'succeeded', 'errored', 'failed_rolled_back', 'canceled'
78
+ Active states: initialized, workflow_started, in_progress, paused, finalizing, errored
79
+ Terminal states: succeeded, failed_rolled_back, canceled
67
80
  """
68
81
 
69
82
  from __future__ import annotations
@@ -1010,3 +1023,288 @@ SELECT_CONNECTIONS_BY_SOURCE_CONNECTOR_AND_STREAM_AND_ORG = sqlalchemy.text(
1010
1023
  LIMIT :limit
1011
1024
  """
1012
1025
  )
1026
+
1027
+ # =============================================================================
1028
+ # Connector Rollout Queries
1029
+ # =============================================================================
1030
+
1031
+ # List all rollouts for a connector definition, with version details
1032
+ SELECT_CONNECTOR_ROLLOUTS = sqlalchemy.text(
1033
+ """
1034
+ SELECT
1035
+ cr.id AS rollout_id,
1036
+ cr.actor_definition_id,
1037
+ cr.state,
1038
+ cr.initial_rollout_pct,
1039
+ cr.current_target_rollout_pct,
1040
+ cr.final_target_rollout_pct,
1041
+ cr.has_breaking_changes,
1042
+ cr.max_step_wait_time_mins,
1043
+ cr.rollout_strategy,
1044
+ cr.workflow_run_id,
1045
+ cr.error_msg,
1046
+ cr.failed_reason,
1047
+ cr.paused_reason,
1048
+ cr.tag,
1049
+ cr.created_at,
1050
+ cr.updated_at,
1051
+ cr.completed_at,
1052
+ cr.expires_at,
1053
+ rc_version.docker_image_tag AS rc_docker_image_tag,
1054
+ rc_version.docker_repository AS rc_docker_repository,
1055
+ initial_version.docker_image_tag AS initial_docker_image_tag,
1056
+ initial_version.docker_repository AS initial_docker_repository
1057
+ FROM connector_rollout cr
1058
+ JOIN actor_definition_version rc_version
1059
+ ON cr.release_candidate_version_id = rc_version.id
1060
+ LEFT JOIN actor_definition_version initial_version
1061
+ ON cr.initial_version_id = initial_version.id
1062
+ WHERE
1063
+ cr.actor_definition_id = :actor_definition_id
1064
+ ORDER BY
1065
+ cr.created_at DESC
1066
+ LIMIT :limit
1067
+ """
1068
+ )
1069
+
1070
+ # List all active (non-terminal) rollouts across all connectors
1071
+ # Active states: initialized, workflow_started, in_progress, paused, finalizing, errored
1072
+ SELECT_ACTIVE_CONNECTOR_ROLLOUTS = sqlalchemy.text(
1073
+ """
1074
+ SELECT
1075
+ cr.id AS rollout_id,
1076
+ cr.actor_definition_id,
1077
+ cr.state,
1078
+ cr.initial_rollout_pct,
1079
+ cr.current_target_rollout_pct,
1080
+ cr.final_target_rollout_pct,
1081
+ cr.has_breaking_changes,
1082
+ cr.max_step_wait_time_mins,
1083
+ cr.rollout_strategy,
1084
+ cr.workflow_run_id,
1085
+ cr.error_msg,
1086
+ cr.failed_reason,
1087
+ cr.paused_reason,
1088
+ cr.tag,
1089
+ cr.created_at,
1090
+ cr.updated_at,
1091
+ cr.completed_at,
1092
+ cr.expires_at,
1093
+ rc_version.docker_image_tag AS rc_docker_image_tag,
1094
+ rc_version.docker_repository AS rc_docker_repository,
1095
+ initial_version.docker_image_tag AS initial_docker_image_tag,
1096
+ initial_version.docker_repository AS initial_docker_repository
1097
+ FROM connector_rollout cr
1098
+ JOIN actor_definition_version rc_version
1099
+ ON cr.release_candidate_version_id = rc_version.id
1100
+ LEFT JOIN actor_definition_version initial_version
1101
+ ON cr.initial_version_id = initial_version.id
1102
+ WHERE
1103
+ cr.state IN ('initialized', 'workflow_started', 'in_progress', 'paused', 'finalizing', 'errored')
1104
+ ORDER BY
1105
+ cr.created_at DESC
1106
+ LIMIT :limit
1107
+ """
1108
+ )
1109
+
1110
+ # List active (non-terminal) rollouts for a specific connector definition
1111
+ # Active states: initialized, workflow_started, in_progress, paused, finalizing, errored
1112
+ SELECT_ACTIVE_CONNECTOR_ROLLOUTS_BY_DEFINITION = sqlalchemy.text(
1113
+ """
1114
+ SELECT
1115
+ cr.id AS rollout_id,
1116
+ cr.actor_definition_id,
1117
+ cr.state,
1118
+ cr.initial_rollout_pct,
1119
+ cr.current_target_rollout_pct,
1120
+ cr.final_target_rollout_pct,
1121
+ cr.has_breaking_changes,
1122
+ cr.max_step_wait_time_mins,
1123
+ cr.rollout_strategy,
1124
+ cr.workflow_run_id,
1125
+ cr.error_msg,
1126
+ cr.failed_reason,
1127
+ cr.paused_reason,
1128
+ cr.tag,
1129
+ cr.created_at,
1130
+ cr.updated_at,
1131
+ cr.completed_at,
1132
+ cr.expires_at,
1133
+ rc_version.docker_image_tag AS rc_docker_image_tag,
1134
+ rc_version.docker_repository AS rc_docker_repository,
1135
+ initial_version.docker_image_tag AS initial_docker_image_tag,
1136
+ initial_version.docker_repository AS initial_docker_repository
1137
+ FROM connector_rollout cr
1138
+ JOIN actor_definition_version rc_version
1139
+ ON cr.release_candidate_version_id = rc_version.id
1140
+ LEFT JOIN actor_definition_version initial_version
1141
+ ON cr.initial_version_id = initial_version.id
1142
+ WHERE
1143
+ cr.actor_definition_id = :actor_definition_id
1144
+ AND cr.state IN ('initialized', 'workflow_started', 'in_progress', 'paused', 'finalizing', 'errored')
1145
+ ORDER BY
1146
+ cr.created_at DESC
1147
+ LIMIT :limit
1148
+ """
1149
+ )
1150
+
1151
+ # Get a specific rollout by ID
1152
+ SELECT_CONNECTOR_ROLLOUT_BY_ID = sqlalchemy.text(
1153
+ """
1154
+ SELECT
1155
+ cr.id AS rollout_id,
1156
+ cr.actor_definition_id,
1157
+ cr.state,
1158
+ cr.initial_rollout_pct,
1159
+ cr.current_target_rollout_pct,
1160
+ cr.final_target_rollout_pct,
1161
+ cr.has_breaking_changes,
1162
+ cr.max_step_wait_time_mins,
1163
+ cr.rollout_strategy,
1164
+ cr.workflow_run_id,
1165
+ cr.error_msg,
1166
+ cr.failed_reason,
1167
+ cr.paused_reason,
1168
+ cr.filters,
1169
+ cr.tag,
1170
+ cr.created_at,
1171
+ cr.updated_at,
1172
+ cr.completed_at,
1173
+ cr.expires_at,
1174
+ rc_version.docker_image_tag AS rc_docker_image_tag,
1175
+ rc_version.docker_repository AS rc_docker_repository,
1176
+ initial_version.docker_image_tag AS initial_docker_image_tag,
1177
+ initial_version.docker_repository AS initial_docker_repository
1178
+ FROM connector_rollout cr
1179
+ JOIN actor_definition_version rc_version
1180
+ ON cr.release_candidate_version_id = rc_version.id
1181
+ LEFT JOIN actor_definition_version initial_version
1182
+ ON cr.initial_version_id = initial_version.id
1183
+ WHERE
1184
+ cr.id = :rollout_id
1185
+ """
1186
+ )
1187
+
1188
+ # =============================================================================
1189
+ # Connector Rollout Monitoring Queries
1190
+ # =============================================================================
1191
+
1192
+ # Get actors pinned to a specific rollout (via scoped_configuration.origin = rollout_id)
1193
+ # This shows which actors are currently participating in the rollout
1194
+ SELECT_ACTORS_PINNED_TO_ROLLOUT = sqlalchemy.text(
1195
+ """
1196
+ SELECT
1197
+ actor.id AS actor_id,
1198
+ actor.name AS actor_name,
1199
+ actor.actor_definition_id,
1200
+ actor.workspace_id,
1201
+ workspace.name AS workspace_name,
1202
+ workspace.organization_id,
1203
+ scoped_configuration.origin_type AS pin_origin_type,
1204
+ scoped_configuration.origin AS pin_origin,
1205
+ scoped_configuration.created_at AS pin_created_at,
1206
+ scoped_configuration.value AS pinned_version_id
1207
+ FROM scoped_configuration
1208
+ JOIN actor
1209
+ ON scoped_configuration.scope_id = actor.id
1210
+ JOIN workspace
1211
+ ON actor.workspace_id = workspace.id
1212
+ WHERE
1213
+ scoped_configuration.key = 'connector_version'
1214
+ AND scoped_configuration.scope_type = 'actor'
1215
+ AND scoped_configuration.origin = :rollout_id
1216
+ ORDER BY
1217
+ scoped_configuration.created_at DESC
1218
+ """
1219
+ )
1220
+
1221
+ # Get rollout monitoring stats: aggregate counts for a rollout
1222
+ # Returns: total actors for connector, actors with any pin, actors pinned to this rollout
1223
+ SELECT_ROLLOUT_AGGREGATE_STATS = sqlalchemy.text(
1224
+ """
1225
+ WITH rollout_info AS (
1226
+ SELECT
1227
+ cr.id AS rollout_id,
1228
+ cr.actor_definition_id,
1229
+ cr.release_candidate_version_id
1230
+ FROM connector_rollout cr
1231
+ WHERE cr.id = :rollout_id
1232
+ ),
1233
+ total_actors AS (
1234
+ SELECT COUNT(*) AS num_actors
1235
+ FROM actor
1236
+ WHERE actor.actor_definition_id = (SELECT actor_definition_id FROM rollout_info)
1237
+ AND actor.tombstone = false
1238
+ ),
1239
+ pinned_actors AS (
1240
+ SELECT COUNT(DISTINCT scoped_configuration.scope_id) AS num_pinned
1241
+ FROM scoped_configuration
1242
+ JOIN actor ON scoped_configuration.scope_id = actor.id
1243
+ WHERE scoped_configuration.key = 'connector_version'
1244
+ AND scoped_configuration.scope_type = 'actor'
1245
+ AND actor.actor_definition_id = (SELECT actor_definition_id FROM rollout_info)
1246
+ AND actor.tombstone = false
1247
+ ),
1248
+ rollout_pinned_actors AS (
1249
+ SELECT COUNT(DISTINCT scoped_configuration.scope_id) AS num_rollout_pinned
1250
+ FROM scoped_configuration
1251
+ WHERE scoped_configuration.key = 'connector_version'
1252
+ AND scoped_configuration.scope_type = 'actor'
1253
+ AND scoped_configuration.origin = :rollout_id
1254
+ )
1255
+ SELECT
1256
+ (SELECT rollout_id FROM rollout_info) AS rollout_id,
1257
+ (SELECT actor_definition_id FROM rollout_info) AS actor_definition_id,
1258
+ (SELECT num_actors FROM total_actors) AS num_actors,
1259
+ (SELECT num_pinned FROM pinned_actors) AS num_actors_pinned,
1260
+ (SELECT num_rollout_pinned FROM rollout_pinned_actors) AS num_pinned_to_rollout
1261
+ """
1262
+ )
1263
+
1264
+ # Get per-actor sync stats for actors pinned to a rollout
1265
+ # Returns: actor_id, succeeded count, failed count, connection count
1266
+ SELECT_ROLLOUT_ACTOR_SYNC_STATS = sqlalchemy.text(
1267
+ """
1268
+ WITH rollout_actors AS (
1269
+ SELECT DISTINCT
1270
+ scoped_configuration.scope_id AS actor_id
1271
+ FROM scoped_configuration
1272
+ WHERE scoped_configuration.key = 'connector_version'
1273
+ AND scoped_configuration.scope_type = 'actor'
1274
+ AND scoped_configuration.origin = :rollout_id
1275
+ ),
1276
+ actor_connections AS (
1277
+ SELECT
1278
+ ra.actor_id,
1279
+ COUNT(DISTINCT c.id) AS num_connections
1280
+ FROM rollout_actors ra
1281
+ LEFT JOIN connection c
1282
+ ON c.source_id = ra.actor_id OR c.destination_id = ra.actor_id
1283
+ WHERE c.status != 'deprecated' OR c.status IS NULL
1284
+ GROUP BY ra.actor_id
1285
+ ),
1286
+ actor_job_stats AS (
1287
+ SELECT
1288
+ ra.actor_id,
1289
+ COUNT(CASE WHEN j.status = 'succeeded' THEN 1 END) AS num_succeeded,
1290
+ COUNT(CASE WHEN j.status = 'failed' THEN 1 END) AS num_failed
1291
+ FROM rollout_actors ra
1292
+ LEFT JOIN connection c
1293
+ ON c.source_id = ra.actor_id OR c.destination_id = ra.actor_id
1294
+ LEFT JOIN jobs j
1295
+ ON j.scope = c.id::text
1296
+ AND j.config_type = 'sync'
1297
+ AND j.created_at >= :cutoff_date
1298
+ GROUP BY ra.actor_id
1299
+ )
1300
+ SELECT
1301
+ ra.actor_id,
1302
+ COALESCE(ajs.num_succeeded, 0) AS num_succeeded,
1303
+ COALESCE(ajs.num_failed, 0) AS num_failed,
1304
+ COALESCE(ac.num_connections, 0) AS num_connections
1305
+ FROM rollout_actors ra
1306
+ LEFT JOIN actor_job_stats ajs ON ra.actor_id = ajs.actor_id
1307
+ LEFT JOIN actor_connections ac ON ra.actor_id = ac.actor_id
1308
+ ORDER BY COALESCE(ajs.num_failed, 0) DESC, COALESCE(ajs.num_succeeded, 0) DESC
1309
+ """
1310
+ )