From 9b47d500ca463753097a52fcca264d5c983806bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20Mass=C3=A9?= Date: Thu, 3 May 2018 08:39:08 +0200 Subject: [PATCH] throttle the create/update/delete operations --- defaults/main.yml | 1 + tasks/create_activedocs.yml | 4 ++++ tasks/create_application_plans.yml | 4 ++++ tasks/create_default_application.yml | 4 ++++ tasks/create_mapping_rule.yml | 4 ++++ tasks/create_service.yml | 4 ++++ tasks/delete_unused_metrics.yml | 4 ++++ tasks/patch_default_application_for_oauth.yml | 4 ++++ tasks/promote.yml | 4 ++++ tasks/update_mapping_rule.yml | 4 ++++ tasks/update_mapping_rules.yml | 4 ++++ tasks/update_method.yml | 4 ++++ tasks/update_proxy.yml | 4 ++++ 13 files changed, 49 insertions(+) diff --git a/defaults/main.yml b/defaults/main.yml index c84d2fa..60969d2 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -2,6 +2,7 @@ threescale_cicd_openapi_file_format: YAML threescale_cicd_delay: 10 threescale_cicd_retries: 50 +threescale_cicd_throttling: 2 threescale_cicd_default_application_name: 'Ansible smoke-tests default application' threescale_cicd_default_application_description: 'This app is used to run smoke tests during the deployment phase. It will be automatically recreated if you delete it.' threescale_cicd_staging_environment_name: sandbox diff --git a/tasks/create_activedocs.yml b/tasks/create_activedocs.yml index d6a8abd..9c0fee8 100644 --- a/tasks/create_activedocs.yml +++ b/tasks/create_activedocs.yml @@ -99,6 +99,10 @@ changed_when: 'threescale_cicd_tmpresponse.status == 201' when: 'threescale_cicd_api_system_name not in threescale_cicd_existing_activedocs' +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' + - set_fact: threescale_cicd_api_activedocs_id: '{{ threescale_cicd_tmpresponse.json.api_doc.id }}' when: 'threescale_cicd_api_system_name not in threescale_cicd_existing_activedocs' diff --git a/tasks/create_application_plans.yml b/tasks/create_application_plans.yml index 347b51b..c0e53ac 100644 --- a/tasks/create_application_plans.yml +++ b/tasks/create_application_plans.yml @@ -32,3 +32,7 @@ threescale_cicd_existing_application_plans: '{{ threescale_cicd_existing_application_plans|union([ threescale_cicd_tmp_plan.system_name ]) }}' threescale_cicd_existing_application_plans_details: '{{ threescale_cicd_existing_application_plans_details|union([{ "system_name": threescale_cicd_tmp_plan.system_name, "id": threescale_cicd_tmpresponse.json.application_plan.id }]) }}' when: 'threescale_cicd_tmp_plan.system_name not in threescale_cicd_existing_application_plans' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/create_default_application.yml b/tasks/create_default_application.yml index 55ccfe1..efb51fc 100644 --- a/tasks/create_default_application.yml +++ b/tasks/create_default_application.yml @@ -83,3 +83,7 @@ - include_tasks: patch_default_application_for_oauth.yml when: 'threescale_cicd_api_security_scheme.type == ''oauth2''' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/create_mapping_rule.yml b/tasks/create_mapping_rule.yml index 9234cc7..f6fa095 100644 --- a/tasks/create_mapping_rule.yml +++ b/tasks/create_mapping_rule.yml @@ -22,3 +22,7 @@ status_code: 201 register: threescale_cicd_tmpresponse changed_when: 'threescale_cicd_tmpresponse.status == 201' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/create_service.yml b/tasks/create_service.yml index 61313d0..3da7932 100644 --- a/tasks/create_service.yml +++ b/tasks/create_service.yml @@ -52,3 +52,7 @@ threescale_cicd_existing_services: '{{ threescale_cicd_existing_services|union([ threescale_cicd_tmpresponse.json.service.system_name ]) }}' threescale_cicd_existing_services_details: '{{ threescale_cicd_existing_services_details|union([ { ''id'': threescale_cicd_tmpresponse.json.service.id, ''system_name'': threescale_cicd_tmpresponse.json.service.system_name } ]) }}' when: 'threescale_cicd_api_system_name not in threescale_cicd_existing_services' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/delete_unused_metrics.yml b/tasks/delete_unused_metrics.yml index 2bb815e..10424c2 100644 --- a/tasks/delete_unused_metrics.yml +++ b/tasks/delete_unused_metrics.yml @@ -19,3 +19,7 @@ with_items: '{{ threescale_cicd_tmp_metrics_to_delete }}' loop_control: loop_var: threescale_cicd_tmp_metric + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/patch_default_application_for_oauth.yml b/tasks/patch_default_application_for_oauth.yml index 7701c00..c5743e5 100644 --- a/tasks/patch_default_application_for_oauth.yml +++ b/tasks/patch_default_application_for_oauth.yml @@ -59,3 +59,7 @@ headers: Authorization: 'Bearer {{ threescale_cicd_openapi_tmp_access_token }}' Content-Type: 'application/json' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/promote.yml b/tasks/promote.yml index a382607..76fcc79 100644 --- a/tasks/promote.yml +++ b/tasks/promote.yml @@ -36,3 +36,7 @@ method: POST register: threescale_cicd_tmpresponse when: 'threescale_cicd_tmp_staging_proxy_version != threescale_cicd_tmp_production_proxy_version' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/update_mapping_rule.yml b/tasks/update_mapping_rule.yml index dd74ea9..a11a965 100644 --- a/tasks/update_mapping_rule.yml +++ b/tasks/update_mapping_rule.yml @@ -24,3 +24,7 @@ status_code: 200 register: threescale_cicd_tmpresponse changed_when: 'threescale_cicd_tmpresponse.status == 200' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/update_mapping_rules.yml b/tasks/update_mapping_rules.yml index e459489..520fd90 100644 --- a/tasks/update_mapping_rules.yml +++ b/tasks/update_mapping_rules.yml @@ -53,3 +53,7 @@ with_items: '{{ threescale_cicd_tmp_mapping_rules_to_delete }}' loop_control: loop_var: threescale_cicd_tmp_mapping_rule_to_delete + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/update_method.yml b/tasks/update_method.yml index eb088c0..19e1d93 100644 --- a/tasks/update_method.yml +++ b/tasks/update_method.yml @@ -41,3 +41,7 @@ threescale_cicd_existing_metrics: '{{ threescale_cicd_existing_metrics|union([ threescale_cicd_tmp_operation.key ]) }}' threescale_cicd_existing_metrics_details: '{{ threescale_cicd_existing_metrics_details|union([ { "system_name": threescale_cicd_tmp_operation.key, "id": threescale_cicd_tmpresponse.json|json_query("method.id") } ]) }}' when: 'threescale_cicd_tmp_operation.key not in threescale_cicd_existing_metrics' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}' diff --git a/tasks/update_proxy.yml b/tasks/update_proxy.yml index 608d1bd..34d4d13 100644 --- a/tasks/update_proxy.yml +++ b/tasks/update_proxy.yml @@ -17,3 +17,7 @@ body: '{{ threescale_cicd_tmp_body_update_proxy }}' register: threescale_cicd_tmpresponse changed_when: 'threescale_cicd_tmpresponse.status == 200' + +- name: Wait for a couple seconds + pause: + seconds: '{{ threescale_cicd_throttling }}'