@@ -659,16 +659,6 @@ impl EvaluationEnvironment {
659
659
// to define inside of the expression
660
660
let allowed = rhai_engine. eval_expression :: < bool > ( expression. as_str ( ) ) ?;
661
661
662
- // The API Server puts some limitations on the warnings:
663
- // - they cannot exceed 256 characters
664
- // - the size of all the warnings cannot exceed 4096 characters
665
- // - they are returned as HTTP headers, hence not all characters are allowed
666
- //
667
- // Because of these reasons, we use the warning struct only to
668
- // tell the user whether a member policy was evaluated or not. When it was
669
- // evaluated we just tell the outcome (allow/reject).
670
- let mut warnings = vec ! [ ] ;
671
-
672
662
// The details of each policy evaluation are returned as part of the
673
663
// AdmissionResponse.status.details.causes
674
664
let mut status_causes = vec ! [ ] ;
@@ -677,13 +667,6 @@ impl EvaluationEnvironment {
677
667
678
668
for policy_id in & policy_ids {
679
669
if let Some ( result) = evaluation_results. get ( policy_id) {
680
- let outcome = if result. allowed {
681
- "allowed"
682
- } else {
683
- "rejected"
684
- } ;
685
- warnings. push ( format ! ( "{policy_id}: {outcome}" , ) ) ;
686
-
687
670
if !result. allowed {
688
671
let cause = admission_response:: StatusCause {
689
672
field : Some ( format ! ( "spec.policies.{}" , policy_id) ) ,
@@ -692,14 +675,11 @@ impl EvaluationEnvironment {
692
675
} ;
693
676
status_causes. push ( cause) ;
694
677
}
695
- } else {
696
- warnings. push ( format ! ( "{}: not evaluated" , policy_id) ) ;
697
678
}
698
679
}
699
680
debug ! (
700
681
?policy_id,
701
682
?allowed,
702
- ?warnings,
703
683
?status_causes,
704
684
"policy group evaluation result"
705
685
) ;
@@ -727,7 +707,7 @@ impl EvaluationEnvironment {
727
707
patch : None ,
728
708
status,
729
709
audit_annotations : None ,
730
- warnings : Some ( warnings ) ,
710
+ warnings : None ,
731
711
} )
732
712
}
733
713
}
@@ -1060,11 +1040,6 @@ mod tests {
1060
1040
#[ case:: all_policies_are_evaluated(
1061
1041
"group_policy_with_unhappy_or_bracket_happy_and_unhappy_bracket" ,
1062
1042
false ,
1063
- vec![
1064
- "unhappy_policy_2: rejected" ,
1065
- "unhappy_policy_1: rejected" ,
1066
- "happy_policy_1: allowed" ,
1067
- ] ,
1068
1043
vec![
1069
1044
admission_response:: StatusCause {
1070
1045
field: Some ( "spec.policies.unhappy_policy_1" . to_string( ) ) ,
@@ -1081,17 +1056,11 @@ mod tests {
1081
1056
#[ case:: not_all_policies_are_evaluated(
1082
1057
"group_policy_with_unhappy_or_happy_or_unhappy" ,
1083
1058
true ,
1084
- vec![
1085
- "unhappy_policy_1: rejected" ,
1086
- "unhappy_policy_2: not evaluated" ,
1087
- "happy_policy_1: allowed" ,
1088
- ] ,
1089
1059
Vec :: new( ) , // no expected causes, since the request is accepted
1090
1060
) ]
1091
1061
fn group_policy_warning_assignments (
1092
1062
#[ case] policy_id : & str ,
1093
1063
#[ case] admission_accepted : bool ,
1094
- #[ case] expected_warnings : Vec < & str > ,
1095
1064
#[ case] expected_status_causes : Vec < admission_response:: StatusCause > ,
1096
1065
) {
1097
1066
let policy_id = PolicyID :: Policy ( policy_id. to_string ( ) ) ;
@@ -1111,15 +1080,7 @@ mod tests {
1111
1080
. validate ( & policy_id, & validate_request)
1112
1081
. expect ( "should not have errored" ) ;
1113
1082
assert_eq ! ( response. allowed, admission_accepted) ;
1114
-
1115
- let warnings = response. warnings . expect ( "should have warnings" ) ;
1116
- for expected in expected_warnings {
1117
- assert ! (
1118
- warnings. iter( ) . any( |w| w. contains( expected) ) ,
1119
- "could not find warning {}" ,
1120
- expected
1121
- ) ;
1122
- }
1083
+ assert_eq ! ( response. warnings, None ) ;
1123
1084
1124
1085
if admission_accepted {
1125
1086
assert ! ( response. status. is_none( ) ) ;
0 commit comments