Skip to content

Commit

Permalink
Prune pdb
Browse files Browse the repository at this point in the history
  • Loading branch information
dturn committed Aug 9, 2018
1 parent b9aefc5 commit cf2271b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions lib/kubernetes-deploy/deploy_task.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def prune_whitelist
extensions/v1beta1/Ingress
apps/v1beta1/StatefulSet
autoscaling/v1/HorizontalPodAutoscaler
policy/v1beta1/PodDisruptionBudget
)
if server_version >= Gem::Version.new('1.8.0')
wl << "batch/v1beta1/CronJob"
Expand Down
13 changes: 0 additions & 13 deletions test/integration-serial/run_serial_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,13 +158,6 @@ def test_crd_can_fail
end

def test_crd_pruning
widget = Class.new(KubernetesDeploy::KubernetesResource) do
def deploy_method
:replace
end
end
KubernetesDeploy.const_set("Widget", widget)

assert_deploy_success(deploy_fixtures("crd", subset: %w(mail.yml widgets.yml)))
assert_logs_match_all([
"Phase 1: Initializing deploy",
Expand All @@ -184,12 +177,6 @@ def deploy_method
/The following resources were pruned: widget(.stable.example.io)? "my-first-widget"/,
"Pruned 1 resource and successfully deployed 2 resource"
])

result = deploy_fixtures("crd", subset: %w(mail_cr.yml)) do |f|
mail = f.dig("mail_cr.yml", "Mail").first
mail["spec"]["something"] = 5
end
assert_deploy_success(result)
ensure
apiextensions_v1beta1_kubeclient.delete_custom_resource_definition("mail.stable.example.io")
apiextensions_v1beta1_kubeclient.delete_custom_resource_definition("widgets.stable.example.io")
Expand Down
9 changes: 8 additions & 1 deletion test/integration/kubernetes_deploy_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ def test_pruning_works
'daemonset(\.extensions)? "ds-app"',
'statefulset(\.apps)? "stateful-busybox"',
'job(\.batch)? "hello-job"',
'poddisruptionbudget(.policy)? "test"',
] # not necessarily listed in this order
expected_msgs = [/Pruned 9 resources and successfully deployed 6 resources/]
expected_msgs = [/Pruned 10 resources and successfully deployed 6 resources/]
expected_pruned.map do |resource|
expected_msgs << /The following resources were pruned:.*#{resource}/
end
Expand Down Expand Up @@ -1070,4 +1071,10 @@ def test_hpa_can_be_pruned
assert_deploy_success(deploy_fixtures("hpa", subset: ["deployment.yml"]))
assert_logs_match_all([/The following resources were pruned: horizontalpodautoscaler(.autoscaling)? "hello-hpa"/])
end

def test_not_apply_resource_can_be_pruned
assert_deploy_success(deploy_fixtures("hello-cloud", subset: %w(disruption-budgets.yml configmap-data.yml)))
assert_deploy_success(deploy_fixtures("hello-cloud", subset: %w(configmap-data.yml)))
assert_logs_match_all([/The following resources were pruned: poddisruptionbudget(.policy)? "test"/])
end
end

0 comments on commit cf2271b

Please sign in to comment.