Skip to content

Commit

Permalink
less failure on unexpected reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
cjimti committed Jul 16, 2020
1 parent 6672e5b commit 432354d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions amp.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,30 +157,29 @@ func (a *Api) mutatePod(ar admissionv1.AdmissionReview) *admissionv1.AdmissionRe
pod := corev1.Pod{}
deserializer := codecs.UniversalDeserializer()
if _, _, err := deserializer.Decode(raw, nil, &pod); err != nil {
a.Log.Error("deserializer failure", zap.Error(err))
return toAdmissionResponse(err)
a.Log.Warn("deserializer failure", zap.Error(err))
return &reviewResponse
}
logInfo = append(logInfo, zap.String("Pod", pod.Name))

a.Log.Info("Pod for review",
append(logInfo,
zap.Any("Labels", pod.Labels),
zap.Any("Annotation", pod.Annotations),
zap.Any("PodLabels", pod.Labels),
zap.Any("PodAnnotations", pod.Annotations),
zap.Any("PodNamespace", pod.Namespace),
)...,
)



reviewResponse := admissionv1.AdmissionResponse{}
// always allow (amp is only for pod mutation)
reviewResponse.Allowed = true

ns, err := a.Cs.CoreV1().Namespaces().Get(pod.Namespace, metav1.GetOptions{})
if err != nil {
a.Log.Error("unable to get namespace",
a.Log.Warn("unable to get namespace",
append(logInfo, zap.Error(err))...,
)
return toAdmissionResponse(err)
return &reviewResponse
}

// lookup endpoint by namespace annotation
Expand Down

0 comments on commit 432354d

Please sign in to comment.