qontract-reconcile 0.10.2.dev334__py3-none-any.whl → 0.10.2.dev439__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.
Potentially problematic release.
This version of qontract-reconcile might be problematic. Click here for more details.
- {qontract_reconcile-0.10.2.dev334.dist-info → qontract_reconcile-0.10.2.dev439.dist-info}/METADATA +13 -12
- {qontract_reconcile-0.10.2.dev334.dist-info → qontract_reconcile-0.10.2.dev439.dist-info}/RECORD +366 -361
- reconcile/acs_rbac.py +2 -2
- reconcile/aus/advanced_upgrade_service.py +18 -12
- reconcile/aus/base.py +134 -32
- reconcile/aus/cluster_version_data.py +15 -5
- reconcile/aus/models.py +3 -1
- reconcile/aus/ocm_addons_upgrade_scheduler_org.py +1 -0
- reconcile/aus/ocm_upgrade_scheduler.py +8 -1
- reconcile/aus/ocm_upgrade_scheduler_org.py +20 -5
- reconcile/aus/version_gates/sts_version_gate_handler.py +54 -1
- reconcile/automated_actions/config/integration.py +16 -4
- reconcile/aws_account_manager/integration.py +8 -8
- reconcile/aws_account_manager/reconciler.py +3 -3
- reconcile/aws_ami_cleanup/integration.py +8 -12
- reconcile/aws_ami_share.py +69 -62
- reconcile/aws_cloudwatch_log_retention/integration.py +155 -126
- reconcile/aws_ecr_image_pull_secrets.py +3 -3
- reconcile/aws_iam_keys.py +1 -0
- reconcile/aws_saml_idp/integration.py +12 -4
- reconcile/aws_saml_roles/integration.py +32 -25
- reconcile/aws_version_sync/integration.py +6 -12
- reconcile/change_owners/bundle.py +3 -3
- reconcile/change_owners/change_log_tracking.py +3 -2
- reconcile/change_owners/change_owners.py +1 -1
- reconcile/change_owners/diff.py +2 -4
- reconcile/checkpoint.py +11 -3
- reconcile/cli.py +111 -18
- reconcile/dashdotdb_dora.py +5 -12
- reconcile/dashdotdb_slo.py +1 -1
- reconcile/database_access_manager.py +123 -117
- reconcile/dynatrace_token_provider/integration.py +1 -1
- reconcile/endpoints_discovery/integration.py +4 -1
- reconcile/endpoints_discovery/merge_request.py +1 -1
- reconcile/endpoints_discovery/merge_request_manager.py +9 -11
- reconcile/external_resources/factories.py +5 -12
- reconcile/external_resources/integration.py +1 -1
- reconcile/external_resources/manager.py +8 -5
- reconcile/external_resources/meta.py +0 -1
- reconcile/external_resources/metrics.py +1 -1
- reconcile/external_resources/model.py +20 -20
- reconcile/external_resources/reconciler.py +7 -4
- reconcile/external_resources/secrets_sync.py +8 -11
- reconcile/external_resources/state.py +26 -16
- reconcile/fleet_labeler/integration.py +1 -1
- reconcile/gabi_authorized_users.py +8 -5
- reconcile/gcp_image_mirror.py +2 -2
- reconcile/github_org.py +1 -1
- reconcile/github_owners.py +4 -0
- reconcile/gitlab_housekeeping.py +13 -15
- reconcile/gitlab_members.py +6 -12
- reconcile/gitlab_mr_sqs_consumer.py +2 -2
- reconcile/gitlab_owners.py +15 -11
- reconcile/gitlab_permissions.py +8 -12
- reconcile/glitchtip_project_alerts/integration.py +3 -1
- reconcile/gql_definitions/acs/acs_instances.py +10 -10
- reconcile/gql_definitions/acs/acs_policies.py +5 -5
- reconcile/gql_definitions/acs/acs_rbac.py +6 -6
- reconcile/gql_definitions/advanced_upgrade_service/aus_clusters.py +32 -32
- reconcile/gql_definitions/advanced_upgrade_service/aus_organization.py +26 -26
- reconcile/gql_definitions/app_interface_metrics_exporter/onboarding_status.py +6 -7
- reconcile/gql_definitions/app_sre_tekton_access_revalidation/roles.py +5 -5
- reconcile/gql_definitions/app_sre_tekton_access_revalidation/users.py +5 -5
- reconcile/gql_definitions/automated_actions/instance.py +51 -12
- reconcile/gql_definitions/aws_account_manager/aws_accounts.py +11 -11
- reconcile/gql_definitions/aws_ami_cleanup/aws_accounts.py +20 -10
- reconcile/gql_definitions/aws_cloudwatch_log_retention/aws_accounts.py +28 -68
- reconcile/gql_definitions/aws_saml_idp/aws_accounts.py +20 -10
- reconcile/gql_definitions/aws_saml_roles/aws_accounts.py +20 -10
- reconcile/gql_definitions/aws_saml_roles/roles.py +5 -5
- reconcile/gql_definitions/aws_version_sync/clusters.py +10 -10
- reconcile/gql_definitions/aws_version_sync/namespaces.py +5 -5
- reconcile/gql_definitions/change_owners/queries/change_types.py +5 -5
- reconcile/gql_definitions/change_owners/queries/self_service_roles.py +9 -9
- reconcile/gql_definitions/cluster_auth_rhidp/clusters.py +18 -18
- reconcile/gql_definitions/common/alerting_services_settings.py +9 -9
- reconcile/gql_definitions/common/app_code_component_repos.py +5 -5
- reconcile/gql_definitions/common/app_interface_custom_messages.py +5 -5
- reconcile/gql_definitions/common/app_interface_dms_settings.py +5 -5
- reconcile/gql_definitions/common/app_interface_repo_settings.py +5 -5
- reconcile/gql_definitions/common/app_interface_roles.py +120 -0
- reconcile/gql_definitions/common/app_interface_state_settings.py +10 -10
- reconcile/gql_definitions/common/app_interface_vault_settings.py +5 -5
- reconcile/gql_definitions/common/app_quay_repos_escalation_policies.py +5 -5
- reconcile/gql_definitions/common/apps.py +5 -5
- reconcile/gql_definitions/common/aws_vpc_requests.py +22 -9
- reconcile/gql_definitions/common/aws_vpcs.py +11 -11
- reconcile/gql_definitions/common/clusters.py +37 -35
- reconcile/gql_definitions/common/clusters_minimal.py +14 -14
- reconcile/gql_definitions/common/clusters_with_dms.py +6 -6
- reconcile/gql_definitions/common/clusters_with_peering.py +29 -30
- reconcile/gql_definitions/common/github_orgs.py +10 -10
- reconcile/gql_definitions/common/jira_settings.py +10 -10
- reconcile/gql_definitions/common/jiralert_settings.py +5 -5
- reconcile/gql_definitions/common/ldap_settings.py +5 -5
- reconcile/gql_definitions/common/namespaces.py +42 -44
- reconcile/gql_definitions/common/namespaces_minimal.py +15 -13
- reconcile/gql_definitions/common/ocm_env_telemeter.py +12 -12
- reconcile/gql_definitions/common/ocm_environments.py +19 -19
- reconcile/gql_definitions/common/pagerduty_instances.py +9 -9
- reconcile/gql_definitions/common/pgp_reencryption_settings.py +6 -6
- reconcile/gql_definitions/common/pipeline_providers.py +29 -29
- reconcile/gql_definitions/common/quay_instances.py +5 -5
- reconcile/gql_definitions/common/quay_orgs.py +5 -5
- reconcile/gql_definitions/common/reserved_networks.py +5 -5
- reconcile/gql_definitions/common/rhcs_provider_settings.py +5 -5
- reconcile/gql_definitions/common/saas_files.py +44 -44
- reconcile/gql_definitions/common/saas_target_namespaces.py +10 -10
- reconcile/gql_definitions/common/saasherder_settings.py +5 -5
- reconcile/gql_definitions/common/slack_workspaces.py +5 -5
- reconcile/gql_definitions/common/smtp_client_settings.py +19 -19
- reconcile/gql_definitions/common/state_aws_account.py +7 -8
- reconcile/gql_definitions/common/users.py +5 -5
- reconcile/gql_definitions/common/users_with_paths.py +5 -5
- reconcile/gql_definitions/cost_report/app_names.py +5 -5
- reconcile/gql_definitions/cost_report/cost_namespaces.py +5 -5
- reconcile/gql_definitions/cost_report/settings.py +9 -9
- reconcile/gql_definitions/dashdotdb_slo/slo_documents_query.py +43 -43
- reconcile/gql_definitions/dynatrace_token_provider/dynatrace_bootstrap_tokens.py +10 -10
- reconcile/gql_definitions/dynatrace_token_provider/token_specs.py +5 -5
- reconcile/gql_definitions/email_sender/apps.py +5 -5
- reconcile/gql_definitions/email_sender/emails.py +8 -8
- reconcile/gql_definitions/email_sender/users.py +6 -6
- reconcile/gql_definitions/endpoints_discovery/apps.py +10 -10
- reconcile/gql_definitions/external_resources/aws_accounts.py +9 -9
- reconcile/gql_definitions/external_resources/external_resources_modules.py +23 -23
- reconcile/gql_definitions/external_resources/external_resources_namespaces.py +494 -410
- reconcile/gql_definitions/external_resources/external_resources_settings.py +28 -26
- reconcile/gql_definitions/external_resources/fragments/external_resources_module_overrides.py +5 -5
- reconcile/gql_definitions/fleet_labeler/fleet_labels.py +40 -40
- reconcile/gql_definitions/fragments/aus_organization.py +5 -5
- reconcile/gql_definitions/fragments/aws_account_common.py +7 -5
- reconcile/gql_definitions/fragments/aws_account_managed.py +5 -5
- reconcile/gql_definitions/fragments/aws_account_sso.py +5 -5
- reconcile/gql_definitions/fragments/aws_infra_management_account.py +5 -5
- reconcile/gql_definitions/fragments/{aws_vpc_request_subnet.py → aws_organization.py} +12 -8
- reconcile/gql_definitions/fragments/aws_vpc.py +5 -5
- reconcile/gql_definitions/fragments/aws_vpc_request.py +12 -5
- reconcile/gql_definitions/fragments/container_image_mirror.py +5 -5
- reconcile/gql_definitions/fragments/deploy_resources.py +5 -5
- reconcile/gql_definitions/fragments/disable.py +5 -5
- reconcile/gql_definitions/fragments/email_service.py +5 -5
- reconcile/gql_definitions/fragments/email_user.py +5 -5
- reconcile/gql_definitions/fragments/jumphost_common_fields.py +5 -5
- reconcile/gql_definitions/fragments/membership_source.py +5 -5
- reconcile/gql_definitions/fragments/minimal_ocm_organization.py +5 -5
- reconcile/gql_definitions/fragments/oc_connection_cluster.py +5 -5
- reconcile/gql_definitions/fragments/ocm_environment.py +5 -5
- reconcile/gql_definitions/fragments/pipeline_provider_retention.py +5 -5
- reconcile/gql_definitions/fragments/prometheus_instance.py +5 -5
- reconcile/gql_definitions/fragments/resource_limits_requirements.py +5 -5
- reconcile/gql_definitions/fragments/resource_requests_requirements.py +5 -5
- reconcile/gql_definitions/fragments/resource_values.py +5 -5
- reconcile/gql_definitions/fragments/saas_slo_document.py +5 -5
- reconcile/gql_definitions/fragments/saas_target_namespace.py +5 -5
- reconcile/gql_definitions/fragments/serviceaccount_token.py +5 -5
- reconcile/gql_definitions/fragments/terraform_state.py +5 -5
- reconcile/gql_definitions/fragments/upgrade_policy.py +5 -5
- reconcile/gql_definitions/fragments/user.py +5 -5
- reconcile/gql_definitions/fragments/vault_secret.py +5 -5
- reconcile/gql_definitions/gcp/gcp_docker_repos.py +9 -9
- reconcile/gql_definitions/gcp/gcp_projects.py +9 -9
- reconcile/gql_definitions/gitlab_members/gitlab_instances.py +9 -9
- reconcile/gql_definitions/gitlab_members/permissions.py +9 -9
- reconcile/gql_definitions/glitchtip/glitchtip_instance.py +9 -9
- reconcile/gql_definitions/glitchtip/glitchtip_project.py +11 -11
- reconcile/gql_definitions/glitchtip_project_alerts/glitchtip_project.py +9 -9
- reconcile/gql_definitions/integrations/integrations.py +48 -51
- reconcile/gql_definitions/introspection.json +3207 -1683
- reconcile/gql_definitions/jenkins_configs/jenkins_configs.py +11 -11
- reconcile/gql_definitions/jenkins_configs/jenkins_instances.py +10 -10
- reconcile/gql_definitions/jira/jira_servers.py +5 -5
- reconcile/gql_definitions/jira_permissions_validator/jira_boards_for_permissions_validator.py +14 -10
- reconcile/gql_definitions/jumphosts/jumphosts.py +13 -13
- reconcile/gql_definitions/ldap_groups/roles.py +5 -5
- reconcile/gql_definitions/ldap_groups/settings.py +9 -9
- reconcile/gql_definitions/maintenance/maintenances.py +5 -5
- reconcile/gql_definitions/membershipsources/roles.py +5 -5
- reconcile/gql_definitions/ocm_labels/clusters.py +18 -19
- reconcile/gql_definitions/ocm_labels/organizations.py +5 -5
- reconcile/gql_definitions/openshift_cluster_bots/clusters.py +22 -22
- reconcile/gql_definitions/openshift_groups/managed_groups.py +5 -5
- reconcile/gql_definitions/openshift_groups/managed_roles.py +6 -6
- reconcile/gql_definitions/openshift_serviceaccount_tokens/tokens.py +10 -10
- reconcile/gql_definitions/quay_membership/quay_membership.py +6 -6
- reconcile/gql_definitions/rhcs/certs.py +33 -87
- reconcile/gql_definitions/rhcs/openshift_resource_rhcs_cert.py +43 -0
- reconcile/gql_definitions/rhidp/organizations.py +18 -18
- reconcile/gql_definitions/service_dependencies/jenkins_instance_fragment.py +5 -5
- reconcile/gql_definitions/service_dependencies/service_dependencies.py +8 -8
- reconcile/gql_definitions/sharding/aws_accounts.py +10 -10
- reconcile/gql_definitions/sharding/ocm_organization.py +8 -8
- reconcile/gql_definitions/skupper_network/site_controller_template.py +5 -5
- reconcile/gql_definitions/skupper_network/skupper_networks.py +10 -10
- reconcile/gql_definitions/slack_usergroups/clusters.py +5 -5
- reconcile/gql_definitions/slack_usergroups/permissions.py +9 -9
- reconcile/gql_definitions/slack_usergroups/users.py +5 -5
- reconcile/gql_definitions/slo_documents/slo_documents.py +5 -5
- reconcile/gql_definitions/status_board/status_board.py +6 -7
- reconcile/gql_definitions/statuspage/statuspages.py +9 -9
- reconcile/gql_definitions/templating/template_collection.py +5 -5
- reconcile/gql_definitions/templating/templates.py +5 -5
- reconcile/gql_definitions/terraform_cloudflare_dns/app_interface_cloudflare_dns_settings.py +6 -6
- reconcile/gql_definitions/terraform_cloudflare_dns/terraform_cloudflare_zones.py +11 -11
- reconcile/gql_definitions/terraform_cloudflare_resources/terraform_cloudflare_accounts.py +11 -11
- reconcile/gql_definitions/terraform_cloudflare_resources/terraform_cloudflare_resources.py +20 -25
- reconcile/gql_definitions/terraform_cloudflare_users/app_interface_setting_cloudflare_and_vault.py +6 -6
- reconcile/gql_definitions/terraform_cloudflare_users/terraform_cloudflare_roles.py +12 -12
- reconcile/gql_definitions/terraform_init/aws_accounts.py +23 -9
- reconcile/gql_definitions/terraform_repo/terraform_repo.py +9 -9
- reconcile/gql_definitions/terraform_resources/database_access_manager.py +5 -5
- reconcile/gql_definitions/terraform_resources/terraform_resources_namespaces.py +440 -407
- reconcile/gql_definitions/terraform_tgw_attachments/aws_accounts.py +23 -17
- reconcile/gql_definitions/unleash_feature_toggles/feature_toggles.py +9 -9
- reconcile/gql_definitions/vault_instances/vault_instances.py +61 -61
- reconcile/gql_definitions/vault_policies/vault_policies.py +11 -11
- reconcile/gql_definitions/vpc_peerings_validator/vpc_peerings_validator.py +8 -8
- reconcile/gql_definitions/vpc_peerings_validator/vpc_peerings_validator_peered_cluster_fragment.py +5 -5
- reconcile/integrations_manager.py +3 -3
- reconcile/jenkins_worker_fleets.py +10 -8
- reconcile/jira_permissions_validator.py +237 -122
- reconcile/ldap_groups/integration.py +1 -1
- reconcile/ocm/types.py +35 -56
- reconcile/ocm_aws_infrastructure_access.py +1 -1
- reconcile/ocm_clusters.py +4 -4
- reconcile/ocm_labels/integration.py +3 -2
- reconcile/ocm_machine_pools.py +33 -27
- reconcile/openshift_base.py +113 -5
- reconcile/openshift_cluster_bots.py +3 -2
- reconcile/openshift_namespace_labels.py +1 -1
- reconcile/openshift_namespaces.py +97 -101
- reconcile/openshift_resources_base.py +6 -2
- reconcile/openshift_rhcs_certs.py +74 -37
- reconcile/openshift_rolebindings.py +230 -130
- reconcile/openshift_saas_deploy.py +6 -7
- reconcile/openshift_saas_deploy_change_tester.py +9 -7
- reconcile/openshift_saas_deploy_trigger_cleaner.py +3 -5
- reconcile/openshift_serviceaccount_tokens.py +2 -2
- reconcile/openshift_upgrade_watcher.py +4 -4
- reconcile/openshift_users.py +5 -3
- reconcile/oum/labelset.py +5 -3
- reconcile/oum/models.py +1 -4
- reconcile/prometheus_rules_tester/integration.py +3 -3
- reconcile/quay_mirror.py +1 -1
- reconcile/queries.py +131 -0
- reconcile/rhidp/common.py +3 -5
- reconcile/rhidp/sso_client/base.py +16 -5
- reconcile/saas_auto_promotions_manager/merge_request_manager/renderer.py +1 -1
- reconcile/saas_auto_promotions_manager/subscriber.py +4 -3
- reconcile/skupper_network/integration.py +2 -2
- reconcile/slack_usergroups.py +35 -14
- reconcile/sql_query.py +1 -0
- reconcile/status_board.py +6 -6
- reconcile/statuspage/atlassian.py +7 -7
- reconcile/statuspage/integrations/maintenances.py +4 -3
- reconcile/statuspage/page.py +4 -9
- reconcile/statuspage/status.py +5 -8
- reconcile/templates/rosa-classic-cluster-creation.sh.j2 +5 -1
- reconcile/templates/rosa-hcp-cluster-creation.sh.j2 +4 -1
- reconcile/templating/lib/merge_request_manager.py +2 -2
- reconcile/templating/lib/rendering.py +3 -3
- reconcile/templating/renderer.py +12 -13
- reconcile/terraform_aws_route53.py +7 -1
- reconcile/terraform_cloudflare_dns.py +3 -3
- reconcile/terraform_cloudflare_resources.py +5 -5
- reconcile/terraform_cloudflare_users.py +3 -2
- reconcile/terraform_init/integration.py +187 -23
- reconcile/terraform_repo.py +16 -12
- reconcile/terraform_resources.py +17 -7
- reconcile/terraform_tgw_attachments.py +27 -19
- reconcile/terraform_users.py +7 -0
- reconcile/terraform_vpc_peerings.py +14 -3
- reconcile/terraform_vpc_resources/integration.py +20 -8
- reconcile/typed_queries/app_interface_roles.py +10 -0
- reconcile/typed_queries/aws_account_tags.py +41 -0
- reconcile/typed_queries/cost_report/app_names.py +1 -1
- reconcile/typed_queries/cost_report/cost_namespaces.py +2 -2
- reconcile/typed_queries/saas_files.py +13 -13
- reconcile/typed_queries/status_board.py +2 -2
- reconcile/unleash_feature_toggles/integration.py +4 -2
- reconcile/utils/acs/base.py +6 -3
- reconcile/utils/acs/policies.py +2 -2
- reconcile/utils/aggregated_list.py +4 -3
- reconcile/utils/aws_api.py +51 -20
- reconcile/utils/aws_api_typed/api.py +38 -9
- reconcile/utils/aws_api_typed/cloudformation.py +149 -0
- reconcile/utils/aws_api_typed/logs.py +73 -0
- reconcile/utils/aws_api_typed/organization.py +4 -2
- reconcile/utils/binary.py +7 -12
- reconcile/utils/datetime_util.py +67 -0
- reconcile/utils/deadmanssnitch_api.py +1 -1
- reconcile/utils/differ.py +2 -3
- reconcile/utils/early_exit_cache.py +11 -12
- reconcile/utils/expiration.py +7 -3
- reconcile/utils/external_resource_spec.py +24 -1
- reconcile/utils/filtering.py +1 -1
- reconcile/utils/gitlab_api.py +7 -5
- reconcile/utils/glitchtip/client.py +6 -2
- reconcile/utils/glitchtip/models.py +25 -28
- reconcile/utils/gql.py +4 -7
- reconcile/utils/helm.py +2 -1
- reconcile/utils/helpers.py +1 -1
- reconcile/utils/instrumented_wrappers.py +1 -1
- reconcile/utils/internal_groups/client.py +2 -2
- reconcile/utils/internal_groups/models.py +8 -17
- reconcile/utils/jinja2/utils.py +6 -8
- reconcile/utils/jira_client.py +82 -63
- reconcile/utils/jjb_client.py +28 -15
- reconcile/utils/jobcontroller/controller.py +2 -2
- reconcile/utils/jobcontroller/models.py +17 -1
- reconcile/utils/json.py +74 -0
- reconcile/utils/membershipsources/app_interface_resolver.py +4 -2
- reconcile/utils/membershipsources/models.py +16 -23
- reconcile/utils/membershipsources/resolver.py +4 -2
- reconcile/utils/merge_request_manager/merge_request_manager.py +4 -4
- reconcile/utils/merge_request_manager/parser.py +6 -6
- reconcile/utils/metrics.py +5 -5
- reconcile/utils/models.py +304 -82
- reconcile/utils/mr/app_interface_reporter.py +2 -2
- reconcile/utils/mr/base.py +2 -2
- reconcile/utils/mr/notificator.py +3 -3
- reconcile/utils/mr/update_access_report_base.py +3 -4
- reconcile/utils/mr/user_maintenance.py +3 -2
- reconcile/utils/oc.py +249 -203
- reconcile/utils/oc_filters.py +3 -3
- reconcile/utils/ocm/addons.py +0 -1
- reconcile/utils/ocm/base.py +18 -21
- reconcile/utils/ocm/cluster_groups.py +1 -1
- reconcile/utils/ocm/identity_providers.py +2 -2
- reconcile/utils/ocm/labels.py +1 -1
- reconcile/utils/ocm/products.py +9 -3
- reconcile/utils/ocm/search_filters.py +3 -6
- reconcile/utils/ocm/service_log.py +4 -6
- reconcile/utils/ocm/sre_capability_labels.py +20 -13
- reconcile/utils/openshift_resource.py +10 -5
- reconcile/utils/output.py +3 -2
- reconcile/utils/pagerduty_api.py +10 -7
- reconcile/utils/promotion_state.py +6 -11
- reconcile/utils/raw_github_api.py +1 -1
- reconcile/utils/rhcsv2_certs.py +138 -35
- reconcile/utils/rosa/session.py +16 -0
- reconcile/utils/runtime/integration.py +2 -3
- reconcile/utils/runtime/runner.py +2 -2
- reconcile/utils/saasherder/interfaces.py +13 -20
- reconcile/utils/saasherder/models.py +25 -21
- reconcile/utils/saasherder/saasherder.py +55 -31
- reconcile/utils/slack_api.py +26 -4
- reconcile/utils/sloth.py +224 -0
- reconcile/utils/sqs_gateway.py +2 -1
- reconcile/utils/state.py +2 -1
- reconcile/utils/structs.py +1 -1
- reconcile/utils/terraform_client.py +5 -4
- reconcile/utils/terrascript_aws_client.py +192 -114
- reconcile/utils/unleash/server.py +2 -8
- reconcile/utils/vault.py +5 -12
- reconcile/utils/vcs.py +8 -8
- reconcile/vault_replication.py +107 -42
- tools/app_interface_reporter.py +4 -4
- tools/cli_commands/cost_report/cost_management_api.py +3 -3
- tools/cli_commands/cost_report/view.py +7 -6
- tools/cli_commands/erv2.py +1 -1
- tools/cli_commands/systems_and_tools.py +5 -1
- tools/qontract_cli.py +31 -18
- tools/template_validation.py +3 -1
- reconcile/gql_definitions/cna/__init__.py +0 -0
- reconcile/gql_definitions/cna/queries/__init__.py +0 -0
- reconcile/gql_definitions/ocm_oidc_idp/__init__.py +0 -0
- reconcile/gql_definitions/ocm_subscription_labels/__init__.py +0 -0
- {qontract_reconcile-0.10.2.dev334.dist-info → qontract_reconcile-0.10.2.dev439.dist-info}/WHEEL +0 -0
- {qontract_reconcile-0.10.2.dev334.dist-info → qontract_reconcile-0.10.2.dev439.dist-info}/entry_points.txt +0 -0
|
@@ -16,7 +16,7 @@ from collections.abc import (
|
|
|
16
16
|
Sequence,
|
|
17
17
|
)
|
|
18
18
|
from contextlib import suppress
|
|
19
|
-
from datetime import
|
|
19
|
+
from datetime import datetime, timedelta
|
|
20
20
|
from types import TracebackType
|
|
21
21
|
from typing import Any
|
|
22
22
|
|
|
@@ -37,10 +37,12 @@ from sretoolbox.utils import (
|
|
|
37
37
|
from reconcile.github_org import get_default_config
|
|
38
38
|
from reconcile.status import RunningState
|
|
39
39
|
from reconcile.utils import helm
|
|
40
|
+
from reconcile.utils.datetime_util import utc_now
|
|
40
41
|
from reconcile.utils.github_api import GithubRepositoryApi
|
|
41
42
|
from reconcile.utils.gitlab_api import GitLabApi
|
|
42
43
|
from reconcile.utils.jenkins_api import JenkinsApi, JobBuildState
|
|
43
44
|
from reconcile.utils.jjb_client import JJB
|
|
45
|
+
from reconcile.utils.json import json_dumps
|
|
44
46
|
from reconcile.utils.oc import (
|
|
45
47
|
OCLocal,
|
|
46
48
|
StatusCodeError,
|
|
@@ -90,8 +92,7 @@ from reconcile.utils.state import State
|
|
|
90
92
|
from reconcile.utils.vcs import VCS
|
|
91
93
|
|
|
92
94
|
TARGET_CONFIG_HASH = "target_config_hash"
|
|
93
|
-
|
|
94
|
-
|
|
95
|
+
TEMPLATE_API_VERSION = "template.openshift.io/v1"
|
|
95
96
|
UNIQUE_SAAS_FILE_ENV_COMBO_LEN = 56
|
|
96
97
|
REQUEST_TIMEOUT = 60
|
|
97
98
|
|
|
@@ -763,7 +764,8 @@ class SaasHerder:
|
|
|
763
764
|
case "gitlab":
|
|
764
765
|
if not self.gitlab:
|
|
765
766
|
raise Exception("gitlab is not initialized")
|
|
766
|
-
project
|
|
767
|
+
if not (project := self.gitlab.get_project(url)):
|
|
768
|
+
raise Exception(f"Could not find gitlab project for {url}")
|
|
767
769
|
content = self.gitlab.get_raw_file(
|
|
768
770
|
project=project,
|
|
769
771
|
path=path,
|
|
@@ -799,7 +801,8 @@ class SaasHerder:
|
|
|
799
801
|
case "gitlab":
|
|
800
802
|
if not self.gitlab:
|
|
801
803
|
raise Exception("gitlab is not initialized")
|
|
802
|
-
project
|
|
804
|
+
if not (project := self.gitlab.get_project(url)):
|
|
805
|
+
raise Exception(f"Could not find gitlab project for {url}")
|
|
803
806
|
dir_contents = self.gitlab.get_directory_contents(
|
|
804
807
|
project,
|
|
805
808
|
ref=commit_sha,
|
|
@@ -824,7 +827,8 @@ class SaasHerder:
|
|
|
824
827
|
case "gitlab":
|
|
825
828
|
if not self.gitlab:
|
|
826
829
|
raise Exception("gitlab is not initialized")
|
|
827
|
-
project
|
|
830
|
+
if not (project := self.gitlab.get_project(url)):
|
|
831
|
+
raise Exception(f"Could not find gitlab project for {url}")
|
|
828
832
|
commits = project.commits.list(ref_name=ref, per_page=1, page=1)
|
|
829
833
|
return commits[0].id
|
|
830
834
|
case _:
|
|
@@ -869,10 +873,23 @@ class SaasHerder:
|
|
|
869
873
|
"""
|
|
870
874
|
if parameter_name in consolidated_parameters:
|
|
871
875
|
return False
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
+
return any(
|
|
877
|
+
template_parameter["name"] == parameter_name
|
|
878
|
+
for template_parameter in template.get("parameters") or []
|
|
879
|
+
)
|
|
880
|
+
|
|
881
|
+
@staticmethod
|
|
882
|
+
def _pre_process_template(template: dict[str, Any]) -> dict[str, Any]:
|
|
883
|
+
"""
|
|
884
|
+
The only supported apiVersion for OpenShift Template is "template.openshift.io/v1".
|
|
885
|
+
There are examples of templates using "v1", it can't pass validation on 4.19+ oc versions.
|
|
886
|
+
|
|
887
|
+
Args:
|
|
888
|
+
template (dict): The OpenShift template dictionary.
|
|
889
|
+
Returns:
|
|
890
|
+
dict: The OpenShift template dictionary with the correct apiVersion.
|
|
891
|
+
"""
|
|
892
|
+
return template | {"apiVersion": TEMPLATE_API_VERSION}
|
|
876
893
|
|
|
877
894
|
def _process_template(
|
|
878
895
|
self, spec: TargetSpec
|
|
@@ -962,7 +979,8 @@ class SaasHerder:
|
|
|
962
979
|
oc = OCLocal("cluster", None, None, local=True)
|
|
963
980
|
try:
|
|
964
981
|
resources: Iterable[Mapping[str, Any]] = oc.process(
|
|
965
|
-
template,
|
|
982
|
+
template=self._pre_process_template(template),
|
|
983
|
+
parameters=consolidated_parameters,
|
|
966
984
|
)
|
|
967
985
|
except StatusCodeError as e:
|
|
968
986
|
logging.error(f"{error_prefix} error processing template: {e!s}")
|
|
@@ -1177,13 +1195,13 @@ class SaasHerder:
|
|
|
1177
1195
|
images_list = threaded.run(
|
|
1178
1196
|
self._collect_images, resources, self.available_thread_pool_size
|
|
1179
1197
|
)
|
|
1180
|
-
|
|
1181
|
-
self.images.update(
|
|
1182
|
-
if not
|
|
1198
|
+
images_set = set(itertools.chain.from_iterable(images_list))
|
|
1199
|
+
self.images.update(images_set)
|
|
1200
|
+
if not images_set:
|
|
1183
1201
|
return False # no errors
|
|
1184
1202
|
images = threaded.run(
|
|
1185
1203
|
self._get_image,
|
|
1186
|
-
|
|
1204
|
+
images_set,
|
|
1187
1205
|
self.available_thread_pool_size,
|
|
1188
1206
|
image_patterns=spec.image_patterns,
|
|
1189
1207
|
image_auth=spec.image_auth,
|
|
@@ -1248,7 +1266,9 @@ class SaasHerder:
|
|
|
1248
1266
|
self.saas_files,
|
|
1249
1267
|
self.thread_pool_size,
|
|
1250
1268
|
)
|
|
1251
|
-
desired_state_specs = list(
|
|
1269
|
+
desired_state_specs: list[TargetSpec] = list(
|
|
1270
|
+
itertools.chain.from_iterable(results)
|
|
1271
|
+
)
|
|
1252
1272
|
promotions = threaded.run(
|
|
1253
1273
|
self.populate_desired_state_saas_file,
|
|
1254
1274
|
desired_state_specs,
|
|
@@ -1865,7 +1885,7 @@ class SaasHerder:
|
|
|
1865
1885
|
@staticmethod
|
|
1866
1886
|
def get_target_config_hash(target_config: Any) -> str:
|
|
1867
1887
|
m = hashlib.sha256()
|
|
1868
|
-
m.update(
|
|
1888
|
+
m.update(json_dumps(target_config).encode("utf-8"))
|
|
1869
1889
|
digest = m.hexdigest()[:16]
|
|
1870
1890
|
return digest
|
|
1871
1891
|
|
|
@@ -1896,21 +1916,23 @@ class SaasHerder:
|
|
|
1896
1916
|
name=target.name,
|
|
1897
1917
|
ref=target.ref,
|
|
1898
1918
|
promotion=(
|
|
1899
|
-
target.promotion.
|
|
1919
|
+
target.promotion.model_dump(by_alias=True) if target.promotion else None
|
|
1900
1920
|
),
|
|
1901
1921
|
secretParameters=(
|
|
1902
|
-
[p.
|
|
1922
|
+
[p.model_dump(by_alias=True) for p in target.secret_parameters]
|
|
1903
1923
|
if target.secret_parameters
|
|
1904
1924
|
else None
|
|
1905
1925
|
),
|
|
1906
1926
|
slos=(
|
|
1907
|
-
[slo.
|
|
1927
|
+
[slo.model_dump(by_alias=True) for slo in target.slos]
|
|
1908
1928
|
if target.slos
|
|
1909
1929
|
else None
|
|
1910
1930
|
),
|
|
1911
|
-
upstream=(
|
|
1931
|
+
upstream=(
|
|
1932
|
+
target.upstream.model_dump(by_alias=True) if target.upstream else None
|
|
1933
|
+
),
|
|
1912
1934
|
images=(
|
|
1913
|
-
[i.
|
|
1935
|
+
[i.model_dump(by_alias=True) for i in target.images]
|
|
1914
1936
|
if target.images
|
|
1915
1937
|
else None
|
|
1916
1938
|
),
|
|
@@ -1921,14 +1943,14 @@ class SaasHerder:
|
|
|
1921
1943
|
# before the GQL classes are introduced, the parameters attribute
|
|
1922
1944
|
# was a json string. Keep it that way to be backwards compatible.
|
|
1923
1945
|
saas_file_parameters=(
|
|
1924
|
-
|
|
1946
|
+
json_dumps(saas_file.parameters, compact=True)
|
|
1925
1947
|
if saas_file.parameters is not None
|
|
1926
1948
|
else None
|
|
1927
1949
|
),
|
|
1928
1950
|
# before the GQL classes are introduced, the parameters attribute
|
|
1929
1951
|
# was a json string. Keep it that way to be backwards compatible.
|
|
1930
1952
|
parameters=(
|
|
1931
|
-
|
|
1953
|
+
json_dumps(target.parameters, compact=True)
|
|
1932
1954
|
if target.parameters is not None
|
|
1933
1955
|
else None
|
|
1934
1956
|
),
|
|
@@ -1939,23 +1961,23 @@ class SaasHerder:
|
|
|
1939
1961
|
# before the GQL classes are introduced, the parameters attribute
|
|
1940
1962
|
# was a json string. Keep it that way to be backwards compatible.
|
|
1941
1963
|
rt_parameters=(
|
|
1942
|
-
|
|
1964
|
+
json_dumps(resource_template.parameters, compact=True)
|
|
1943
1965
|
if resource_template.parameters is not None
|
|
1944
1966
|
else None
|
|
1945
1967
|
),
|
|
1946
1968
|
)
|
|
1947
1969
|
if saas_file.managed_resource_names:
|
|
1948
1970
|
state_content["saas_file_managed_resource_names"] = [
|
|
1949
|
-
m.
|
|
1971
|
+
m.model_dump() for m in saas_file.managed_resource_names
|
|
1950
1972
|
]
|
|
1951
1973
|
# include secret parameters from resource template and saas file
|
|
1952
1974
|
if resource_template.secret_parameters:
|
|
1953
1975
|
state_content["rt_secretparameters"] = [
|
|
1954
|
-
p.
|
|
1976
|
+
p.model_dump() for p in resource_template.secret_parameters
|
|
1955
1977
|
]
|
|
1956
1978
|
if saas_file.secret_parameters:
|
|
1957
1979
|
state_content["saas_file_secretparameters"] = [
|
|
1958
|
-
p.
|
|
1980
|
+
p.model_dump() for p in saas_file.secret_parameters
|
|
1959
1981
|
]
|
|
1960
1982
|
return state_content
|
|
1961
1983
|
|
|
@@ -2024,7 +2046,7 @@ class SaasHerder:
|
|
|
2024
2046
|
if promotion.commit_sha in self.hotfix_versions.get(promotion.url, set()):
|
|
2025
2047
|
return True
|
|
2026
2048
|
|
|
2027
|
-
now =
|
|
2049
|
+
now = utc_now()
|
|
2028
2050
|
passed_soak_days = timedelta(days=0)
|
|
2029
2051
|
|
|
2030
2052
|
for channel in promotion.subscribe:
|
|
@@ -2126,7 +2148,7 @@ class SaasHerder:
|
|
|
2126
2148
|
if not (self.state and self._promotion_state):
|
|
2127
2149
|
raise Exception("state is not initialized")
|
|
2128
2150
|
|
|
2129
|
-
now =
|
|
2151
|
+
now = utc_now()
|
|
2130
2152
|
for promotion in self.promotions:
|
|
2131
2153
|
if promotion is None:
|
|
2132
2154
|
continue
|
|
@@ -2238,7 +2260,9 @@ class SaasHerder:
|
|
|
2238
2260
|
for rt in saas_file.resource_templates:
|
|
2239
2261
|
for target in rt.targets:
|
|
2240
2262
|
template_vars = {
|
|
2241
|
-
"resource": {
|
|
2263
|
+
"resource": {
|
|
2264
|
+
"namespace": target.namespace.model_dump(by_alias=True)
|
|
2265
|
+
}
|
|
2242
2266
|
}
|
|
2243
2267
|
if target.parameters:
|
|
2244
2268
|
for param in target.parameters:
|
reconcile/utils/slack_api.py
CHANGED
|
@@ -2,6 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
import json
|
|
4
4
|
import logging
|
|
5
|
+
import os
|
|
5
6
|
from typing import (
|
|
6
7
|
TYPE_CHECKING,
|
|
7
8
|
Any,
|
|
@@ -26,6 +27,23 @@ if TYPE_CHECKING:
|
|
|
26
27
|
MAX_RETRIES = 5
|
|
27
28
|
TIMEOUT = 30
|
|
28
29
|
|
|
30
|
+
# Slack API base URLs for different workspace types
|
|
31
|
+
SLACK_API_BASE_URL = "https://slack.com/api/"
|
|
32
|
+
SLACK_GOV_API_BASE_URL = "https://slack-gov.com/api/"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def is_gov_slack_workspace() -> bool:
|
|
36
|
+
"""
|
|
37
|
+
Determine if a workspace is a government Slack workspace.
|
|
38
|
+
|
|
39
|
+
:return: True if it's a gov-slack workspace, False otherwise
|
|
40
|
+
"""
|
|
41
|
+
# Check GOV_SLACK environment variable from OpenShift YAML configuration
|
|
42
|
+
# If not set, defaults to False (regular Slack)
|
|
43
|
+
gov_slack_env = os.getenv("GOV_SLACK", "false")
|
|
44
|
+
|
|
45
|
+
return gov_slack_env.lower() == "true"
|
|
46
|
+
|
|
29
47
|
|
|
30
48
|
class UserNotFoundError(Exception):
|
|
31
49
|
pass
|
|
@@ -53,14 +71,14 @@ class HasClientGlobalConfig(Protocol):
|
|
|
53
71
|
max_retries: int | None
|
|
54
72
|
timeout: int | None
|
|
55
73
|
|
|
56
|
-
def
|
|
74
|
+
def model_dump(self) -> dict[str, int | None]: ...
|
|
57
75
|
|
|
58
76
|
|
|
59
77
|
class HasClientMethodConfig(Protocol):
|
|
60
78
|
name: str
|
|
61
79
|
args: Any
|
|
62
80
|
|
|
63
|
-
def
|
|
81
|
+
def model_dump(self) -> dict[str, str]: ...
|
|
64
82
|
|
|
65
83
|
|
|
66
84
|
class HasClientConfig(Protocol):
|
|
@@ -165,7 +183,6 @@ class SlackApi:
|
|
|
165
183
|
api_config: SlackApiConfig | None = None,
|
|
166
184
|
init_usergroups: bool = True,
|
|
167
185
|
channel: str | None = None,
|
|
168
|
-
slack_url: str | None = None,
|
|
169
186
|
**chat_kwargs: Any,
|
|
170
187
|
) -> None:
|
|
171
188
|
"""
|
|
@@ -187,10 +204,15 @@ class SlackApi:
|
|
|
187
204
|
else:
|
|
188
205
|
self.config = SlackApiConfig()
|
|
189
206
|
|
|
207
|
+
# Determine the appropriate Slack API base URL based on GOV_SLACK environment variable
|
|
208
|
+
base_url = (
|
|
209
|
+
SLACK_GOV_API_BASE_URL if is_gov_slack_workspace() else SLACK_API_BASE_URL
|
|
210
|
+
)
|
|
211
|
+
|
|
190
212
|
self._sc = WebClient(
|
|
191
213
|
token=token,
|
|
192
214
|
timeout=self.config.timeout,
|
|
193
|
-
base_url=
|
|
215
|
+
base_url=base_url,
|
|
194
216
|
)
|
|
195
217
|
self._configure_client_retry()
|
|
196
218
|
|
reconcile/utils/sloth.py
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import subprocess
|
|
2
|
+
import tempfile
|
|
3
|
+
from io import StringIO
|
|
4
|
+
from typing import Any, NotRequired, TypedDict
|
|
5
|
+
|
|
6
|
+
import yaml
|
|
7
|
+
|
|
8
|
+
from reconcile.utils.ruamel import create_ruamel_instance
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class PrometheusRule(TypedDict):
|
|
12
|
+
record: NotRequired[str]
|
|
13
|
+
alert: NotRequired[str]
|
|
14
|
+
expr: str
|
|
15
|
+
labels: NotRequired[dict[str, str]]
|
|
16
|
+
annotations: NotRequired[dict[str, str]]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class PrometheusRuleGroup(TypedDict):
|
|
20
|
+
name: str
|
|
21
|
+
rules: list[PrometheusRule]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class PrometheusRuleSpec(TypedDict):
|
|
25
|
+
groups: list[PrometheusRuleGroup]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class SLOParametersDict(TypedDict):
|
|
29
|
+
window: str
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class SLO(TypedDict):
|
|
33
|
+
name: str
|
|
34
|
+
SLIType: str
|
|
35
|
+
SLISpecification: str
|
|
36
|
+
SLOTarget: float
|
|
37
|
+
SLOTargetUnit: str
|
|
38
|
+
SLOParameters: SLOParametersDict
|
|
39
|
+
SLODetails: str
|
|
40
|
+
dashboard: str
|
|
41
|
+
expr: str
|
|
42
|
+
SLIErrorQuery: NotRequired[str]
|
|
43
|
+
SLITotalQuery: NotRequired[str]
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class App(TypedDict):
|
|
47
|
+
name: str
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class SLODocument(TypedDict):
|
|
51
|
+
name: str
|
|
52
|
+
app: App
|
|
53
|
+
slos: NotRequired[list[SLO]]
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
class SlothGenerateError(Exception):
|
|
57
|
+
def __init__(self, msg: Any):
|
|
58
|
+
super().__init__("sloth generate failed: " + str(msg))
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class SlothInputError(Exception):
|
|
62
|
+
def __init__(self, msg: Any):
|
|
63
|
+
super().__init__("sloth input validation failed: " + str(msg))
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def process_sloth_output(output_file_path: str) -> str:
|
|
67
|
+
ruamel_instance = create_ruamel_instance()
|
|
68
|
+
with open(output_file_path, encoding="utf-8") as f:
|
|
69
|
+
data: PrometheusRuleSpec = ruamel_instance.load(f)
|
|
70
|
+
for group in data.get("groups", []):
|
|
71
|
+
for rule in group.get("rules", []):
|
|
72
|
+
labels = (
|
|
73
|
+
# sloth adds several sloth_* labels to alerting rules that are not compliant with prometheus-rule-1 schema
|
|
74
|
+
# see https://sloth.dev/examples/default/getting-started/#__tabbed_1_2
|
|
75
|
+
{k: v for k, v in rule["labels"].items() if not k.startswith("sloth")}
|
|
76
|
+
if rule.get("alert")
|
|
77
|
+
else rule["labels"] # retain all labels on record rules
|
|
78
|
+
)
|
|
79
|
+
annotations = (
|
|
80
|
+
# sloth adds a `title` key within annotations for alert rules: https://sloth.dev/examples/default/getting-started/#__tabbed_1_2
|
|
81
|
+
# this is not compliant with schema and is discarded
|
|
82
|
+
{k: v for k, v in rule["annotations"].items() if k != "title"}
|
|
83
|
+
if rule.get("alert")
|
|
84
|
+
else {} # record rules do not support annotations
|
|
85
|
+
)
|
|
86
|
+
if labels:
|
|
87
|
+
rule["labels"] = labels
|
|
88
|
+
else:
|
|
89
|
+
rule.pop("labels", None)
|
|
90
|
+
if annotations:
|
|
91
|
+
rule["annotations"] = annotations
|
|
92
|
+
else:
|
|
93
|
+
rule.pop("annotations", None)
|
|
94
|
+
with StringIO() as s:
|
|
95
|
+
ruamel_instance.dump(data, s)
|
|
96
|
+
return s.getvalue()
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def run_sloth(spec: dict[str, Any]) -> str:
|
|
100
|
+
with (
|
|
101
|
+
tempfile.NamedTemporaryFile(
|
|
102
|
+
encoding="utf-8", mode="w", suffix=".yml"
|
|
103
|
+
) as input_file,
|
|
104
|
+
tempfile.NamedTemporaryFile(
|
|
105
|
+
encoding="utf-8", mode="w", suffix=".yml"
|
|
106
|
+
) as output_file,
|
|
107
|
+
):
|
|
108
|
+
yaml.dump(spec, input_file, allow_unicode=True)
|
|
109
|
+
cmd = ["sloth", "generate", "-i", input_file.name, "-o", output_file.name]
|
|
110
|
+
try:
|
|
111
|
+
subprocess.run(cmd, capture_output=True, check=True, text=True)
|
|
112
|
+
except subprocess.CalledProcessError as e:
|
|
113
|
+
error_msg = f"{e}"
|
|
114
|
+
if e.stdout:
|
|
115
|
+
error_msg += f"\nstdout: {e.stdout}"
|
|
116
|
+
if e.stderr:
|
|
117
|
+
error_msg += f"\nstderr: {e.stderr}"
|
|
118
|
+
raise SlothGenerateError(error_msg) from e
|
|
119
|
+
return process_sloth_output(output_file.name)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def get_slo_target(slo: SLO) -> float:
|
|
123
|
+
"""
|
|
124
|
+
Ensure SLO target unit aligns with format expected by sloth for 'Objective' attribute
|
|
125
|
+
https://pkg.go.dev/github.com/slok/sloth/pkg/prometheus/api/v1#section-readme
|
|
126
|
+
"""
|
|
127
|
+
val = float(slo["SLOTarget"])
|
|
128
|
+
return val * (100.0 if slo.get("SLOTargetUnit") == "percent_0_1" else 1.0)
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def generate_sloth_rules(
|
|
132
|
+
slo_document: SLODocument,
|
|
133
|
+
version: str = "prometheus/v1",
|
|
134
|
+
) -> str:
|
|
135
|
+
"""Generate Prometheus rules for an slo_document_v1 using sloth
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
slo_document query:
|
|
139
|
+
{
|
|
140
|
+
slo_docs: slo_document_v1(filter: {name: "foo"}) {
|
|
141
|
+
name
|
|
142
|
+
app {
|
|
143
|
+
name
|
|
144
|
+
}
|
|
145
|
+
slos {
|
|
146
|
+
name
|
|
147
|
+
SLIType
|
|
148
|
+
SLOTargetUnit
|
|
149
|
+
SLOParameters {
|
|
150
|
+
window
|
|
151
|
+
}
|
|
152
|
+
expr
|
|
153
|
+
SLOTarget
|
|
154
|
+
SLIErrorQuery
|
|
155
|
+
SLITotalQuery
|
|
156
|
+
SLODetails
|
|
157
|
+
dashboard
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
version: Spec version (default: "prometheus/v1")
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
Generated Prometheus rules as YAML string
|
|
165
|
+
"""
|
|
166
|
+
if not slo_document.get("slos"):
|
|
167
|
+
raise SlothInputError("SLO document has no SLOs defined")
|
|
168
|
+
|
|
169
|
+
service = slo_document["app"]["name"]
|
|
170
|
+
# only process SLOs that have both error and total queries defined
|
|
171
|
+
slo_input = [
|
|
172
|
+
{
|
|
173
|
+
"name": slo["name"],
|
|
174
|
+
"objective": get_slo_target(slo),
|
|
175
|
+
"description": f"{slo['name']} SLO for {service}",
|
|
176
|
+
"sli": {
|
|
177
|
+
"events": {
|
|
178
|
+
"error_query": slo["SLIErrorQuery"].replace(
|
|
179
|
+
"{{window}}", "{{.window}}"
|
|
180
|
+
),
|
|
181
|
+
"total_query": slo["SLITotalQuery"].replace(
|
|
182
|
+
"{{window}}", "{{.window}}"
|
|
183
|
+
),
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"alerting": {
|
|
187
|
+
"name": f"{service.title()}{slo['name'].title()}",
|
|
188
|
+
"annotations": {
|
|
189
|
+
"summary": f"High error rate on {service} {slo['name']}",
|
|
190
|
+
"message": f"High error rate on {service} {slo['name']}",
|
|
191
|
+
"runbook": slo["SLODetails"],
|
|
192
|
+
"dashboard": slo["dashboard"],
|
|
193
|
+
},
|
|
194
|
+
"page_alert": {
|
|
195
|
+
"labels": {
|
|
196
|
+
"severity": "critical",
|
|
197
|
+
"service": service,
|
|
198
|
+
"slo": slo["name"],
|
|
199
|
+
}
|
|
200
|
+
},
|
|
201
|
+
"ticket_alert": {
|
|
202
|
+
"labels": {
|
|
203
|
+
"severity": "high",
|
|
204
|
+
"service": service,
|
|
205
|
+
"slo": slo["name"],
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
}
|
|
210
|
+
for slo in slo_document["slos"]
|
|
211
|
+
if slo.get("SLIErrorQuery") and slo.get("SLITotalQuery")
|
|
212
|
+
]
|
|
213
|
+
|
|
214
|
+
if not slo_input:
|
|
215
|
+
raise SlothInputError(
|
|
216
|
+
"No SLOs found with both SLIErrorQuery and SLITotalQuery defined"
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
spec = {
|
|
220
|
+
"version": version,
|
|
221
|
+
"service": service,
|
|
222
|
+
"slos": slo_input,
|
|
223
|
+
}
|
|
224
|
+
return run_sloth(spec)
|
reconcile/utils/sqs_gateway.py
CHANGED
|
@@ -4,6 +4,7 @@ from collections.abc import Iterable, Mapping
|
|
|
4
4
|
from typing import Any, Self
|
|
5
5
|
|
|
6
6
|
from reconcile.utils.aws_api import AWSApi
|
|
7
|
+
from reconcile.utils.json import json_dumps
|
|
7
8
|
from reconcile.utils.secret_reader import SecretReader
|
|
8
9
|
|
|
9
10
|
|
|
@@ -54,7 +55,7 @@ class SQSGateway:
|
|
|
54
55
|
return queue_account_name[0]
|
|
55
56
|
|
|
56
57
|
def send_message(self, body: Mapping[str, Any]) -> None:
|
|
57
|
-
self.sqs.send_message(QueueUrl=self.queue_url, MessageBody=
|
|
58
|
+
self.sqs.send_message(QueueUrl=self.queue_url, MessageBody=json_dumps(body))
|
|
58
59
|
|
|
59
60
|
def receive_messages(
|
|
60
61
|
self,
|
reconcile/utils/state.py
CHANGED
|
@@ -28,6 +28,7 @@ from reconcile.typed_queries.app_interface_vault_settings import (
|
|
|
28
28
|
)
|
|
29
29
|
from reconcile.typed_queries.get_state_aws_account import get_state_aws_account
|
|
30
30
|
from reconcile.utils.aws_api import aws_config_file_path
|
|
31
|
+
from reconcile.utils.json import json_dumps
|
|
31
32
|
from reconcile.utils.secret_reader import (
|
|
32
33
|
SecretReaderBase,
|
|
33
34
|
create_secret_reader,
|
|
@@ -355,7 +356,7 @@ class State:
|
|
|
355
356
|
self.client.put_object(
|
|
356
357
|
Bucket=self.bucket,
|
|
357
358
|
Key=f"{self.state_path}/{key}",
|
|
358
|
-
Body=
|
|
359
|
+
Body=json_dumps(value),
|
|
359
360
|
Metadata=metadata or {},
|
|
360
361
|
)
|
|
361
362
|
|
reconcile/utils/structs.py
CHANGED
|
@@ -36,6 +36,7 @@ from reconcile.typed_queries.app_interface_custom_messages import (
|
|
|
36
36
|
)
|
|
37
37
|
from reconcile.utils.aws_api import AWSApi
|
|
38
38
|
from reconcile.utils.aws_helper import get_region_from_availability_zone
|
|
39
|
+
from reconcile.utils.datetime_util import ensure_utc, utc_now
|
|
39
40
|
from reconcile.utils.external_resource_spec import (
|
|
40
41
|
ExternalResourceSpec,
|
|
41
42
|
ExternalResourceSpecInventory,
|
|
@@ -222,7 +223,7 @@ class TerraformClient:
|
|
|
222
223
|
if disable_deletions_detected:
|
|
223
224
|
raise RuntimeError("Terraform plan has disabled deletions detected")
|
|
224
225
|
|
|
225
|
-
@retry(no_retry_exceptions=RdsUpgradeValidationError)
|
|
226
|
+
@retry(no_retry_exceptions=(RdsUpgradeValidationError,))
|
|
226
227
|
def terraform_plan(
|
|
227
228
|
self, spec: TerraformSpec, enable_deletion: bool
|
|
228
229
|
) -> tuple[bool, list[AccountUser], bool]:
|
|
@@ -419,11 +420,11 @@ class TerraformClient:
|
|
|
419
420
|
deletion_approvals = account.get("deletionApprovals")
|
|
420
421
|
if not deletion_approvals:
|
|
421
422
|
return False
|
|
422
|
-
now =
|
|
423
|
+
now = utc_now()
|
|
423
424
|
for da in deletion_approvals:
|
|
424
425
|
try:
|
|
425
|
-
expiration =
|
|
426
|
-
da["expiration"], DATE_FORMAT
|
|
426
|
+
expiration = ensure_utc(
|
|
427
|
+
datetime.strptime(da["expiration"], DATE_FORMAT) # noqa: DTZ007
|
|
427
428
|
) + timedelta(days=1)
|
|
428
429
|
except ValueError:
|
|
429
430
|
raise DeletionApprovalExpirationValueError(
|