@@ -81,6 +81,21 @@ func getAesmdVolume(needsAesmd bool, epcUserCount int32, aesmdPresent bool) *cor
8181 }
8282}
8383
84+ func warnWrongResources (resources map [string ]int64 ) []string {
85+ warnings := make ([]string , 0 )
86+
87+ _ , ok := resources [encl ]
88+ if ok {
89+ warnings = append (warnings , encl + " should not be used in Pod spec directly" )
90+ }
91+
92+ _ , ok = resources [provision ]
93+ if ok {
94+ warnings = append (warnings , provision + " should not be used in Pod spec directly" )
95+ }
96+ return warnings
97+ }
98+
8499func (s * SgxMutator ) Handle (ctx context.Context , req admission.Request ) admission.Response {
85100 pod := & corev1.Pod {}
86101
@@ -91,6 +106,7 @@ func (s *SgxMutator) Handle(ctx context.Context, req admission.Request) admissio
91106 totalEpc := int64 (0 )
92107 epcUserCount := int32 (0 )
93108 aesmdPresent := bool (false )
109+ warnings := make ([]string , 0 )
94110
95111 if pod .Annotations == nil {
96112 pod .Annotations = make (map [string ]string )
@@ -104,6 +120,8 @@ func (s *SgxMutator) Handle(ctx context.Context, req admission.Request) admissio
104120 return admission .Errored (http .StatusInternalServerError , err )
105121 }
106122
123+ warnings = append (warnings , warnWrongResources (requestedResources )... )
124+
107125 // the container has no sgx.intel.com/epc
108126 epcSize , ok := requestedResources [epc ]
109127 if ! ok {
@@ -190,7 +208,7 @@ func (s *SgxMutator) Handle(ctx context.Context, req admission.Request) admissio
190208 return admission .Errored (http .StatusInternalServerError , err )
191209 }
192210
193- return admission .PatchResponseFromRaw (req .Object .Raw , marshaledPod )
211+ return admission .PatchResponseFromRaw (req .Object .Raw , marshaledPod ). WithWarnings ( warnings ... )
194212}
195213
196214// SgxMutator implements admission.DecoderInjector.
0 commit comments