From 664a85363a94cd36541f3245be79e7565230ce6a Mon Sep 17 00:00:00 2001
From: Shuting Zhao <shutting06@gmail.com>
Date: Tue, 5 Nov 2019 12:59:22 -0800
Subject: [PATCH] correct scenario test

---
 pkg/engine/overlay.go                                         | 4 +++-
 samples/best_practices/add_safe-to-evict_annotation.yaml      | 2 +-
 test/output/pod-with-emptydir.yaml                            | 2 --
 .../samples/best_practices/scenario_mutate_safe-to-evict.yaml | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/pkg/engine/overlay.go b/pkg/engine/overlay.go
index e7fb0d5258..7c574bcba0 100644
--- a/pkg/engine/overlay.go
+++ b/pkg/engine/overlay.go
@@ -33,7 +33,9 @@ func processOverlay(rule kyverno.Rule, resource unstructured.Unstructured) (resp
 	if err != nil && strings.Contains(err.Error(), "Conditions are not met") {
 		glog.Errorf("Resource %s/%s/%s does not meet the conditions in the rule %s with overlay pattern %s", resource.GetKind(), resource.GetNamespace(), resource.GetName(), rule.Name, rule.Mutation.Overlay)
 		//TODO: send zero response and not consider this as applied?
-		return RuleResponse{}, resource
+		response.Success = false
+		response.Message = fmt.Sprintf("Resource %s/%s/%s: %v.", resource.GetKind(), resource.GetNamespace(), resource.GetName(), err)
+		return response, resource
 	}
 
 	if err != nil {
diff --git a/samples/best_practices/add_safe-to-evict_annotation.yaml b/samples/best_practices/add_safe-to-evict_annotation.yaml
index 2e45dccd49..5e8427970a 100644
--- a/samples/best_practices/add_safe-to-evict_annotation.yaml
+++ b/samples/best_practices/add_safe-to-evict_annotation.yaml
@@ -35,4 +35,4 @@ spec:
         spec:          
           volumes: 
           - (hostPath):
-            path: "*"
+              path: "*"
diff --git a/test/output/pod-with-emptydir.yaml b/test/output/pod-with-emptydir.yaml
index e7bc8b2897..f729d797a3 100644
--- a/test/output/pod-with-emptydir.yaml
+++ b/test/output/pod-with-emptydir.yaml
@@ -2,8 +2,6 @@ apiVersion: v1
 kind: Pod
 metadata:
   name: pod-with-emptydir
-  annotations:
-    cluster-autoscaler.kubernetes.io/safe-to-evict: true
 spec:
   containers:
   - image: k8s.gcr.io/test-webserver
diff --git a/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml b/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml
index e6b4ea9f93..241971eb7e 100644
--- a/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml
+++ b/test/scenarios/samples/best_practices/scenario_mutate_safe-to-evict.yaml
@@ -20,4 +20,4 @@ expected:
         - name: host-path-add-safe-to-evict
           type: Mutation
           success: false
-          message: "successfully processed overlay"          
\ No newline at end of file
+          message: "Resource Pod//pod-with-emptydir: Conditions are not met at /spec/volumes/0/hostPath/, resource field hostPath is not present."
\ No newline at end of file