|
|
@@ -90,7 +90,9 @@ func (c *CreateKubeEventHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
|
|
|
|
|
|
w.WriteHeader(http.StatusCreated)
|
|
|
|
|
|
- if strings.ToLower(string(request.EventType)) == "critical" && strings.ToLower(request.ResourceType) == "pod" {
|
|
|
+ if strings.ToLower(string(request.EventType)) == "critical" &&
|
|
|
+ strings.ToLower(request.ResourceType) == "pod" &&
|
|
|
+ request.Message != "Unable to determine the root cause of the error" {
|
|
|
agent, err := c.GetAgent(r, cluster, request.Namespace)
|
|
|
|
|
|
if err != nil {
|
|
|
@@ -106,6 +108,19 @@ func (c *CreateKubeEventHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+func mapKubeEventToMessage(event *types.CreateKubeEventRequest) string {
|
|
|
+ if strings.HasSuffix(event.Reason, "RunContainerError") {
|
|
|
+ if strings.Contains(event.Message, "exec:") {
|
|
|
+ return fmt.Sprintf("Application launch error: %s\n",
|
|
|
+ strings.Split(strings.SplitAfter(event.Message, "exec: ")[1], ": unknown")[0])
|
|
|
+ }
|
|
|
+ } else if strings.HasSuffix(event.Reason, "ImagePullBackOff") {
|
|
|
+ return "Deployment error: The application image could not be pulled from the registry"
|
|
|
+ }
|
|
|
+
|
|
|
+ return event.Message
|
|
|
+}
|
|
|
+
|
|
|
func notifyPodCrashing(
|
|
|
config *config.Config,
|
|
|
agent *kubernetes.Agent,
|
|
|
@@ -113,6 +128,11 @@ func notifyPodCrashing(
|
|
|
cluster *models.Cluster,
|
|
|
event *types.CreateKubeEventRequest,
|
|
|
) error {
|
|
|
+ // if cluster has notifications turned off, don't alert
|
|
|
+ if cluster.NotificationsDisabled {
|
|
|
+ return nil
|
|
|
+ }
|
|
|
+
|
|
|
// attempt to get a matching Porter release to get the notification configuration
|
|
|
var conf *models.NotificationConfig
|
|
|
var notifConfig *types.NotificationConfig
|
|
|
@@ -231,7 +251,7 @@ func notifyPodCrashing(
|
|
|
ClusterName: cluster.Name,
|
|
|
Name: event.OwnerName,
|
|
|
Namespace: event.Namespace,
|
|
|
- Info: fmt.Sprintf("%s:%s", event.Reason, event.Message),
|
|
|
+ Info: mapKubeEventToMessage(event),
|
|
|
URL: fmt.Sprintf(
|
|
|
"%s/applications/%s/%s/%s?project_id=%d",
|
|
|
config.ServerConf.ServerURL,
|