@@ -834,53 +834,6 @@ def write_results(endpoint_counts, operation_samples, stats, swagger_mapper=None
834
834
for endpoint , count in sorted_endpoints :
835
835
output .append (f"{ endpoint } | { count } " )
836
836
837
- # Find and display missing endpoints from Swagger spec
838
- if swagger_mapper and swagger_mapper .path_to_operation :
839
- all_swagger_operations = set (swagger_mapper .path_to_operation .values ())
840
- found_operations = set (endpoint_counts .keys ())
841
-
842
- # Only count operations that are actually from Swagger (not fallback)
843
- swagger_found = found_operations & all_swagger_operations
844
- missing_operations = all_swagger_operations - swagger_found
845
-
846
- # Filter out alpha and beta versions from missing operations
847
- stable_missing_operations = {
848
- op for op in missing_operations
849
- if not any (version in op for version in
850
- ['V1alpha' , 'V1beta' , 'V2alpha' , 'V2beta' , 'V3alpha' , 'V3beta' , 'alpha' , 'beta' ])
851
- }
852
-
853
- # Filter out ineligible endpoints from missing operations
854
- if ineligible_endpoints :
855
- stable_missing_operations = stable_missing_operations - ineligible_endpoints
856
-
857
- # Filter out pending eligible endpoints from missing operations
858
- if pending_eligible_endpoints :
859
- stable_missing_operations = stable_missing_operations - pending_eligible_endpoints
860
-
861
- # Filter out deprecated operations from missing operations
862
- if deprecated_operations :
863
- stable_missing_operations = stable_missing_operations - deprecated_operations
864
-
865
- if stable_missing_operations :
866
- filtered_count = len (missing_operations ) - len (stable_missing_operations )
867
-
868
- output .append ("" )
869
- output .append ("=" * 70 )
870
- output .append ("STABLE ENDPOINTS NOT FOUND IN AUDIT LOG" )
871
- output .append ("=" * 70 )
872
- output .append (f"Total missing stable endpoints: { len (stable_missing_operations )} " )
873
- if filtered_count > 0 :
874
- output .append (
875
- f"(Filtered out { filtered_count } alpha/beta/deprecated/ineligible/pending eligible endpoints)" )
876
- output .append (
877
- f"These are stable, non-deprecated API endpoints defined in the Swagger spec but not exercised in this audit log:" )
878
- output .append ("" )
879
-
880
- # Sort missing operations alphabetically
881
- for operation in sorted (stable_missing_operations ):
882
- output .append (f"{ operation } | NOT FOUND" )
883
-
884
837
result_text = "\n " .join (output )
885
838
886
839
if output_file :
@@ -900,6 +853,61 @@ def write_results(endpoint_counts, operation_samples, stats, swagger_mapper=None
900
853
_write_audit_operations_json (filtered_endpoint_counts , operation_samples , ineligible_endpoints ,
901
854
pending_eligible_endpoints , deprecated_operations , audit_operations_json )
902
855
856
+ # Find and display missing endpoints from Swagger spec
857
+ if swagger_mapper and swagger_mapper .path_to_operation :
858
+ warn_on_missing_stable_endpoints (deprecated_operations , endpoint_counts , ineligible_endpoints ,
859
+ pending_eligible_endpoints , swagger_mapper )
860
+
861
+
862
+ def warn_on_missing_stable_endpoints (deprecated_operations , endpoint_counts , ineligible_endpoints ,
863
+ pending_eligible_endpoints , swagger_mapper ):
864
+ all_swagger_operations = set (swagger_mapper .path_to_operation .values ())
865
+ found_operations = set (endpoint_counts .keys ())
866
+ # Only count operations that are actually from Swagger (not fallback)
867
+ swagger_found = found_operations & all_swagger_operations
868
+ missing_operations = all_swagger_operations - swagger_found
869
+ # Filter out alpha and beta versions from missing operations
870
+ stable_missing_operations = {
871
+ op for op in missing_operations
872
+ if not any (version in op for version in
873
+ ['V1alpha' , 'V1beta' , 'V2alpha' , 'V2beta' , 'V3alpha' , 'V3beta' , 'alpha' , 'beta' ])
874
+ }
875
+ # Filter out ineligible endpoints from missing operations
876
+ if ineligible_endpoints :
877
+ stable_missing_operations = stable_missing_operations - ineligible_endpoints
878
+ # Filter out pending eligible endpoints from missing operations
879
+ if pending_eligible_endpoints :
880
+ stable_missing_operations = stable_missing_operations - pending_eligible_endpoints
881
+ # Filter out deprecated operations from missing operations
882
+ if deprecated_operations :
883
+ stable_missing_operations = stable_missing_operations - deprecated_operations
884
+ if stable_missing_operations :
885
+ filtered_count = len (missing_operations ) - len (stable_missing_operations )
886
+
887
+ # Log stable missing operations directly to stdout (not to output file)
888
+ print ("" )
889
+ print ("=" * 70 )
890
+ print ("STABLE ENDPOINTS NOT FOUND IN AUDIT LOG" )
891
+ print ("=" * 70 )
892
+ print (f"Total missing stable endpoints: { len (stable_missing_operations )} " )
893
+ if filtered_count > 0 :
894
+ print (f"(Filtered out { filtered_count } alpha/beta/deprecated/ineligible/pending eligible endpoints)" )
895
+ print (
896
+ "These are stable, non-deprecated API endpoints defined in the Swagger spec but not exercised in this audit log:" )
897
+ print ()
898
+
899
+ # Sort missing operations alphabetically
900
+ for operation in sorted (stable_missing_operations ):
901
+ print (f"{ operation } | NOT FOUND" )
902
+
903
+ print ()
904
+ print ("ACTION REQUIRED:" )
905
+ print ("For each missing stable endpoint, please either:" )
906
+ print ("1. Add conformance tests to exercise these API operations, OR" )
907
+ print ("2. Add them to pending_eligible_endpoints.yaml if they should be excluded from conformance testing" )
908
+ print ()
909
+ sys .exit (1 )
910
+
903
911
904
912
def _write_audit_operations_json (filtered_endpoint_counts , operation_samples , ineligible_endpoints ,
905
913
pending_eligible_endpoints , deprecated_operations ,
@@ -998,6 +1006,36 @@ def main():
998
1006
write_results (endpoint_counts , operation_samples , stats , swagger_mapper , args .output , args .sort ,
999
1007
ineligible_endpoints , pending_eligible_endpoints , args .audit_operations_json )
1000
1008
1009
+ warn_on_pending_operations (args , endpoint_counts , pending_eligible_endpoints )
1010
+
1011
+
1012
+ def warn_on_pending_operations (args , endpoint_counts , pending_eligible_endpoints ):
1013
+ # Check if any pending eligible endpoints are already being exercised in audit logs
1014
+ exercised_pending_eligible = []
1015
+ for operation in pending_eligible_endpoints :
1016
+ if operation in endpoint_counts :
1017
+ exercised_pending_eligible .append ((operation , endpoint_counts [operation ]))
1018
+ if exercised_pending_eligible :
1019
+ print ("\n ERROR: Found pending eligible endpoints that are already being exercised in audit logs!" )
1020
+ print ("=" * 80 )
1021
+ print ("The following operations are marked as 'pending eligible' but are actually being used:" )
1022
+ print ()
1023
+ for operation , count in sorted (exercised_pending_eligible , key = lambda x : x [0 ]):
1024
+ print (f" { operation } | { count } calls" )
1025
+ print ()
1026
+ print (f"Total exercised pending eligible operations: { len (exercised_pending_eligible )} " )
1027
+ print ()
1028
+ print ("ACTION REQUIRED:" )
1029
+ print ("Please update the pending_eligible_endpoints.yaml file to remove these operations" )
1030
+ print ("since they are now being actively tested in the audit logs." )
1031
+ if args .pending_eligible_endpoints_url :
1032
+ print (f"File location: { args .pending_eligible_endpoints_url } " )
1033
+ else :
1034
+ print (
1035
+ "Default file: https://raw.githubusercontent.com/kubernetes/kubernetes/refs/heads/master/test/conformance/testdata/pending_eligible_endpoints.yaml" )
1036
+ print ()
1037
+ sys .exit (1 )
1038
+
1001
1039
1002
1040
if __name__ == '__main__' :
1003
1041
main ()
0 commit comments