summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2008-02-14 08:11:41 +1100
committerJames Turnbull <james@lovedthanlost.net>2008-02-14 08:11:41 +1100
commit9f224f2327ca691f4263e36708ef4e7386b2c4b4 (patch)
treeb4d2302a9e36ce9f0a8944c3eabd0ee1c4c29cf9
parent8cfe4e7a984eb92afd92fa1128d2fa8c1a021976 (diff)
parenta42c3ae7eba819053d8f01a339a9c865092d15e2 (diff)
downloadpuppet-9f224f2327ca691f4263e36708ef4e7386b2c4b4.tar.gz
puppet-9f224f2327ca691f4263e36708ef4e7386b2c4b4.tar.xz
puppet-9f224f2327ca691f4263e36708ef4e7386b2c4b4.zip
Merge branch '0.24.x' of git://reductivelabs.com/puppet into 0.24.x
-rw-r--r--CHANGELOG4
-rwxr-xr-xbin/puppetdoc18
-rw-r--r--lib/puppet/pgraph.rb29
-rw-r--r--lib/puppet/reference/node_source.rb9
-rw-r--r--lib/puppet/reference/report.rb21
-rw-r--r--lib/puppet/simple_graph.rb15
-rwxr-xr-xspec/unit/simple_graph.rb11
7 files changed, 38 insertions, 69 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ff65331cb..635aabf25 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+ Fixed #1021 -- the problem was that my method of determining
+ the in-degree sometimes resulted in a lower number than the
+ number of in-edges.
+
Fixed #997 -- virtual defined types are no longer evaluated.
NOTE: This introduces a behaviour change, in that you previously
could realize a resource within a virtual defined resource, and now
diff --git a/bin/puppetdoc b/bin/puppetdoc
index be86cc618..82e4c076b 100755
--- a/bin/puppetdoc
+++ b/bin/puppetdoc
@@ -128,11 +128,19 @@ else
else
with_contents = true
end
+ exit_code = 0
options[:references].sort { |a,b| a.to_s <=> b.to_s }.each do |name|
- section = Puppet::Util::Reference.reference(name)
-
- # Add the per-section text, but with no ToC
- text += section.send(options[:format], with_contents)
+ raise "Could not find reference %s" % name unless section = Puppet::Util::Reference.reference(name)
+
+ begin
+ # Add the per-section text, but with no ToC
+ text += section.send(options[:format], with_contents)
+ rescue => detail
+ puts detail.backtrace
+ $stderr.puts "Could not generate reference %s: %s" % [name, detail]
+ exit_code = 1
+ next
+ end
end
unless with_contents # We've only got one reference
@@ -147,6 +155,8 @@ else
else
puts text
end
+
+ exit exit_code
end
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb
index 71547802e..3bcc2ced0 100644
--- a/lib/puppet/pgraph.rb
+++ b/lib/puppet/pgraph.rb
@@ -19,23 +19,6 @@ class Puppet::PGraph < Puppet::SimpleGraph
super
end
- # Make sure whichever edge has a label keeps the label
- def copy_label(source, target, label)
- # 'require' relationships will not have a label,
- # and all 'subscribe' relationships have the same
- # label, at least for now.
-
- # Labels default to {}, so we can't just test for nil.
- newlabel = label || {}
- oldlabel = edge_label(source, target) || {}
- if ! newlabel.empty? and oldlabel.empty?
- edge_label_set(source, target, label)
- # We should probably check to see if the labels both exist
- # and don't match, but we'd just throw an error which the user
- # couldn't do anyting about.
- end
- end
-
# Which resources a given resource depends upon.
def dependents(resource)
tree_from_vertex(resource).keys
@@ -115,23 +98,11 @@ class Puppet::PGraph < Puppet::SimpleGraph
t = edge.target
end
- # We don't want to add multiple copies of the
- # same edge, but we *do* want to make sure we
- # keep labels around.
- # XXX This will *not* work when we support multiple
- # types of labels, and only works now because
- # you can only do simple subscriptions.
- if edge?(s, t)
- copy_label(s, t, edge.label)
- next
- end
add_edge(s, t, edge.label)
end
# Now get rid of the edge, so remove_vertex! works correctly.
remove_edge!(edge)
- Puppet.debug "%s: %s => %s: %s" % [container,
- edge.source, edge.target, edge?(edge.source, edge.target)]
end
end
remove_vertex!(container)
diff --git a/lib/puppet/reference/node_source.rb b/lib/puppet/reference/node_source.rb
deleted file mode 100644
index 29a01f850..000000000
--- a/lib/puppet/reference/node_source.rb
+++ /dev/null
@@ -1,9 +0,0 @@
-require 'puppet/node'
-
-noderef = Puppet::Util::Reference.newreference :node_source, :doc => "Sources of node configuration information" do
- Puppet::Network::Handler.node.docs
-end
-
-noderef.header = "
-Nodes can be searched for in different locations. This document describes those different locations.
-"
diff --git a/lib/puppet/reference/report.rb b/lib/puppet/reference/report.rb
deleted file mode 100644
index a8086f8bc..000000000
--- a/lib/puppet/reference/report.rb
+++ /dev/null
@@ -1,21 +0,0 @@
-report = Puppet::Util::Reference.newreference :report, :doc => "All available transaction reports" do
- Puppet::Network::Handler.report.reportdocs
-end
-
-report.header = "
-Puppet clients can report back to the server after each transaction. This
-transaction report is sent as a YAML dump of the
-``Puppet::Transaction::Report`` class and includes every log message that was
-generated during the transaction along with as many metrics as Puppet knows how
-to collect. See `ReportsAndReporting Reports and Reporting`:trac:
-for more information on how to use reports.
-
-Currently, clients default to not sending in reports; you can enable reporting
-by setting the ``report`` parameter to true.
-
-To use a report, set the ``reports`` parameter on the server; multiple
-reports must be comma-separated. You can also specify ``none`` to disable
-reports entirely.
-
-Puppet provides multiple report handlers that will process client reports:
-"
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 503e4814c..48f393f77 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -51,10 +51,12 @@ class Puppet::SimpleGraph
# Create methods for returning the degree and edges.
[:in, :out].each do |direction|
- define_method("%s_degree" % direction) do
- @adjacencies[direction].length
- end
-
+ # LAK:NOTE If you decide to create methods for directly
+ # testing the degree, you'll have to get the values and flatten
+ # the results -- you might have duplicate edges, which can give
+ # a false impression of what the degree is. That's just
+ # as expensive as just getting the edge list, so I've decided
+ # to only add this method.
define_method("%s_edges" % direction) do
@adjacencies[direction].values.flatten
end
@@ -126,8 +128,9 @@ class Puppet::SimpleGraph
# Collect each of our vertices, with the number of in-edges each has.
@vertices.each do |name, wrapper|
- zeros << wrapper if wrapper.in_degree == 0
- degree[wrapper.vertex] = wrapper.in_edges
+ edges = wrapper.in_edges
+ zeros << wrapper if edges.length == 0
+ degree[wrapper.vertex] = edges
end
# Iterate over each 0-degree vertex, decrementing the degree of
diff --git a/spec/unit/simple_graph.rb b/spec/unit/simple_graph.rb
index c8fe14cf3..e1e42e40f 100755
--- a/spec/unit/simple_graph.rb
+++ b/spec/unit/simple_graph.rb
@@ -266,4 +266,15 @@ describe Puppet::SimpleGraph, " when sorting the graph" do
add_edges :a => :b, :b => :e, :c => :a, :d => :c
proc { @graph.topsort }.should_not raise_error
end
+
+ # Our graph's add_edge method is smart enough not to add
+ # duplicate edges, so we use the objects, which it doesn't
+ # check.
+ it "should be able to sort graphs with duplicate edges" do
+ one = Puppet::Relationship.new(:a, :b)
+ @graph.add_edge(one)
+ two = Puppet::Relationship.new(:a, :b)
+ @graph.add_edge(two)
+ proc { @graph.topsort }.should_not raise_error
+ end
end