craigcondit commented on code in PR #469:
URL: https://github.com/apache/yunikorn-k8shim/pull/469#discussion_r1025818112
##########
pkg/plugin/admissioncontrollers/webhook/admission_controller.go:
##########
@@ -212,39 +230,99 @@ func (c *admissionController) processWorkload(req
*admissionv1.AdmissionRequest)
return admissionResponseBuilder(uid, false, err.Error(), nil)
}
- if failureResponse := c.checkUserInfoAnnotation(func() (string, bool) {
- a, ok := annotations[userInfoAnnotation]
+ userName := req.UserInfo.Username
+ groups := req.UserInfo.Groups
+ failureResponse, userInfoSet := c.checkUserInfoAnnotation(func()
(string, bool) {
+ a, ok := annotations[common.UserInfoAnnotation]
return a, ok
- }, req.UserInfo.Username, req.UserInfo.Groups, uid); failureResponse !=
nil {
+ }, userName, groups, uid)
+ if failureResponse != nil {
return failureResponse
}
+ if !userInfoSet && !c.conf.GetBypassAuth() {
+ patch, err := c.annotationHandler.GetPatchForWorkload(req,
userName, groups)
+ if err != nil {
+ log.Logger().Error("could not generate patch for
workload", zap.Error(err))
+ return admissionResponseBuilder(uid, false,
err.Error(), nil)
+ }
+
+ patchBytes, patchErr := json.Marshal(patch)
+ if patchErr != nil {
+ log.Logger().Error("failed to marshal patch",
zap.Error(patchErr))
+ return admissionResponseBuilder(uid, false,
patchErr.Error(), nil)
+ }
+ log.Logger().Info("updating annotations on workload",
zap.String("type", req.Kind.Kind),
+ zap.Any("generated patch", patch))
+ return admissionResponseBuilder(uid, true, "", patchBytes)
+ }
+
return admissionResponseBuilder(uid, true, "", nil)
}
-func (c *admissionController) checkUserInfoAnnotation(getAnnotation func()
(string, bool), userName string, groups []string, uid string)
*admissionv1.AdmissionResponse {
- if annotation, ok := getAnnotation(); ok && !c.conf.GetBypassAuth() {
+func (c *admissionController) processPodUpdate(req
*admissionv1.AdmissionRequest, namespace string) *admissionv1.AdmissionResponse
{
+ uid := string(req.UID)
+
+ var newPod v1.Pod
+ if err := json.Unmarshal(req.Object.Raw, &newPod); err != nil {
+ log.Logger().Error("unmarshal failed", zap.Error(err))
+ return admissionResponseBuilder(uid, false, err.Error(), nil)
+ }
+
+ if labelAppValue, ok := newPod.Labels[constants.LabelApp]; ok {
+ if labelAppValue == yunikornPod {
+ log.Logger().Info("pod update - ignore yunikorn pod")
+ return admissionResponseBuilder(uid, true, "", nil)
+ }
+ }
+
+ if !c.shouldProcessNamespace(namespace) {
Review Comment:
To expand on this... especially in plugin mode, yunikorn will get basically
all traffic, but use label/noLabel to determine which pods to send to the
embedded default scheduler.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]