File tree 2 files changed +25
-0
lines changed
lib/puppet/indirector/catalog
spec/unit/indirector/catalog
2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,14 @@ def find(request)
13
13
14
14
session = Puppet . lookup ( :http_session )
15
15
api = session . route_to ( :puppet )
16
+
17
+ ip_address = begin
18
+ " (#{ Resolv . getaddress ( api . url . host ) } )"
19
+ rescue Resolv ::ResolvError
20
+ nil
21
+ end
22
+ Puppet . notice ( "Requesting catalog from #{ api . url . host } :#{ api . url . port } #{ ip_address } " )
23
+
16
24
_ , catalog = api . post_catalog (
17
25
request . key ,
18
26
facts : request . options [ :facts_for_catalog ] ,
Original file line number Diff line number Diff line change @@ -25,6 +25,23 @@ def catalog_response(catalog)
25
25
expect ( described_class . indirection . find ( certname ) ) . to be_a ( Puppet ::Resource ::Catalog )
26
26
end
27
27
28
+ it 'logs a notice when requesting a catalog' do
29
+ expect ( Puppet ) . to receive ( :notice ) . with ( "Requesting catalog from compiler.example.com:8140" )
30
+
31
+ stub_request ( :post , uri ) . to_return ( **catalog_response ( catalog ) )
32
+
33
+ described_class . indirection . find ( certname )
34
+ end
35
+
36
+ it 'logs a notice when the IP address is resolvable when requesting a catalog' do
37
+ allow ( Resolv ) . to receive_message_chain ( :getaddress ) . and_return ( '192.0.2.0' )
38
+ expect ( Puppet ) . to receive ( :notice ) . with ( "Requesting catalog from compiler.example.com:8140 (192.0.2.0)" )
39
+
40
+ stub_request ( :post , uri ) . to_return ( **catalog_response ( catalog ) )
41
+
42
+ described_class . indirection . find ( certname )
43
+ end
44
+
28
45
it "serializes the environment" do
29
46
stub_request ( :post , uri )
30
47
. with ( query : hash_including ( 'environment' => 'outerspace' ) )
You can’t perform that action at this time.
0 commit comments