From 6772dd503d978d782115415b6f3db701d1410496 Mon Sep 17 00:00:00 2001
From: Ravi Gummadi <ravigumm@in.ibm.com>
Date: Thu, 2 Mar 2017 12:05:41 -0500
Subject: [PATCH] Cap the number of worker processes

Users can configure the number of worker processes. However when
it's not specified the calculated number of workers can get too
large on hosts with a large number of CPUs.

Change-Id: Ieb1afbd5c872cc4a991b51287b57404b8932fafa
---
 defaults/main.yml                                           | 4 ++--
 .../capping_ironic_wsgi_processes-6fa7306fc3c29de7.yaml     | 6 ++++++
 2 files changed, 8 insertions(+), 2 deletions(-)
 create mode 100644 releasenotes/notes/capping_ironic_wsgi_processes-6fa7306fc3c29de7.yaml

diff --git a/defaults/main.yml b/defaults/main.yml
index 40bf0650..6eb46d8e 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -223,8 +223,8 @@ ironic_service_user_name: "ironic"
 
 # Apache settings
 ironic_wsgi_threads: 1
-_ironic_wsgi_processes: "{{ ansible_processor_vcpus | default(1) // 4 }}"
-ironic_wsgi_processes: "{{ (_ironic_wsgi_processes | int > 1) | ternary(_ironic_wsgi_processes, 1) }}"
+ironic_wsgi_processes_max: 16
+ironic_wsgi_processes: "{{ [[ansible_processor_vcpus|default(4) // 4, 1] | max, ironic_wsgi_processes_max] | min }}"
 
 ### OpenStack Services to integrate with
 
diff --git a/releasenotes/notes/capping_ironic_wsgi_processes-6fa7306fc3c29de7.yaml b/releasenotes/notes/capping_ironic_wsgi_processes-6fa7306fc3c29de7.yaml
new file mode 100644
index 00000000..cc5982b0
--- /dev/null
+++ b/releasenotes/notes/capping_ironic_wsgi_processes-6fa7306fc3c29de7.yaml
@@ -0,0 +1,6 @@
+---
+features:
+  - Capping the default value for the variable ``ironic_wsgi_processes``
+    to 16 when the user doesn't configure this variable. Default value
+    is one fourth the number of vCPUs available on the machine with a
+    capping value of 16.