From 22992c0a63138ffda783d2c4f6841c9768783357 Mon Sep 17 00:00:00 2001
From: Edmilson Soares Junior <edsoaresjunior@yahoo.com.br>
Date: Wed, 30 Jan 2019 14:56:49 -0200
Subject: [PATCH] Use current timeout management variables

configtimeout was deprecated since Puppet 4 and replaced with
http_connection_timeout and http_read_timeout.
---
 manifests/agent/config.pp          |  9 +++++++--
 manifests/init.pp                  | 15 ++++++++++-----
 manifests/params.pp                |  3 ++-
 spec/classes/puppet_server_spec.rb |  3 ++-
 4 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/manifests/agent/config.pp b/manifests/agent/config.pp
index 47b5748a..fbe9c26c 100644
--- a/manifests/agent/config.pp
+++ b/manifests/agent/config.pp
@@ -15,9 +15,14 @@
     'noop':              value => $::puppet::agent_noop;
     'usecacheonfailure': value => $::puppet::usecacheonfailure;
   }
-  if $::puppet::configtimeout != undef {
+  if $::puppet::http_connect_timeout != undef {
     puppet::config::agent {
-      'configtimeout':   value => $::puppet::configtimeout;
+      'http_connect_timeout': value => $::puppet::http_connect_timeout;
+    }
+  }
+  if $::puppet::http_read_timeout != undef {
+    puppet::config::agent {
+      'http_read_timeout': value => $::puppet::http_read_timeout;
     }
   }
   if $::puppet::prerun_command {
diff --git a/manifests/init.pp b/manifests/init.pp
index 261c80f3..b51690bb 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -92,10 +92,6 @@
 #
 # $module_repository::                      Use a different puppet module repository
 #
-# $configtimeout::                          How long the client should wait for the
-#                                           configuration to be retrieved before
-#                                           considering it a failure.
-#
 # $ca_server::                              Use a different ca server. Should be either
 #                                           a string with the location of the ca_server
 #                                           or 'false'.
@@ -119,6 +115,14 @@
 #
 # $additional_settings::                    A hash of additional main settings.
 #
+# $http_connect_timeout::                   The maximum amount of time an agent waits
+#                                           when establishing an HTTP connection.
+#
+# $http_read_timeout::                      The time an agent waits for one block to be
+#                                           read from an HTTP connection. If nothing is
+#                                           read after the elapsed interval then the
+#                                           connection will be closed.
+#
 # == Advanced puppet parameters
 #
 # $user::                                   Override the name of the puppet user.
@@ -578,7 +582,8 @@
   Boolean $agent_noop = $puppet::params::agent_noop,
   Boolean $show_diff = $puppet::params::show_diff,
   Optional[Stdlib::HTTPUrl] $module_repository = $puppet::params::module_repository,
-  Optional[Integer[0]] $configtimeout = $puppet::params::configtimeout,
+  Optional[Integer[0]] $http_connect_timeout = $puppet::params::http_connect_timeout,
+  Optional[Integer[0]] $http_read_timeout = $puppet::params::http_read_timeout,
   Optional[Variant[String, Boolean]] $ca_server = $puppet::params::ca_server,
   Optional[Integer[0, 65535]] $ca_port = $puppet::params::ca_port,
   Optional[String] $ca_crl_filepath = $puppet::params::ca_crl_filepath,
diff --git a/manifests/params.pp b/manifests/params.pp
index 1ea2fc60..6503623b 100644
--- a/manifests/params.pp
+++ b/manifests/params.pp
@@ -152,7 +152,8 @@
     }
   }
 
-  $configtimeout = undef
+  $http_connect_timeout = undef
+  $http_read_timeout = undef
 
   $autosign         = "${dir}/autosign.conf"
   $autosign_entries = []
diff --git a/spec/classes/puppet_server_spec.rb b/spec/classes/puppet_server_spec.rb
index d9faaf9c..e2d21dd4 100644
--- a/spec/classes/puppet_server_spec.rb
+++ b/spec/classes/puppet_server_spec.rb
@@ -141,7 +141,8 @@
 
         it { should contain_concat(conf_file) }
 
-        it { should_not contain_puppet__config__agent('configtimeout') }
+        it { should_not contain_puppet__config__agent('http_connect_timeout') }
+        it { should_not contain_puppet__config__agent('http_read_timeout') }
         it { should_not contain_class('puppetdb') }
         it { should_not contain_class('puppetdb::master::config') }
         it { should_not contain_file("#{confdir}/custom_trusted_oid_mapping.yaml") }