INNER CODE UNIT · Go

maxLogLength

airwallex/k8s-pod-restart-info-collector · controller.go:270

			maxLogLength := 7500 - len(podStatus+podEvents+nodeEvents)
			if maxLogLength > 0 && len(containerLogs) > maxLogLength {
				containerLogs = containerLogs[len(containerLogs)-maxLogLength:]
			}
			containerLogs = fmt.Sprintf("• Pod Logs Before Restart\n```\n%s```\n", containerLogs)
		}

		msg := SlackMessage{
			Title:  fmt.Sprintf("*Pod restarted!*\n*cluster: `%s`, pod: `%s`, namespace: `%s`*", c.slack.ClusterName, pod.Name, pod.Namespace),
			Text:   podStatus + podEvents + nodeEvents + containerLogs,
			Footer: fmt.Sprintf("%s, %s, %s", c.slack.ClusterName, pod.Name, pod.Namespace),
		}
		// klog.Infoln(msg.Title + "\n" + msg.Text + "\n" + msg.Footer)
		slackChannel := getSlackChannelFromPod(pod)
		err = c.slack.sendToChannel(msg, slackChannel)
		if err != nil {
			return err
		}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…