Esempio n. 1
0
        public void Record(string action, string reason, string message, V1ObjectReference objRef)
        {
            var occurrence = DateTime.Now;
            var key        = new EventKey($"{objRef.ApiVersion}/{objRef.Kind}", action, reason, message, $"{objRef.NamespaceProperty}/{objRef.Name}");

            if (!events.ContainsKey(key))
            {
                Logger.LogDebug("Initializing new EventDetail entry for {objName}", key.ToString());
                events.Add(key, EventDetails.Initialize(objRef.Name, occurrence));
            }

            EventDetails details = events[key];

            details.AddOccurrence(occurrence);

            Logger.LogDebug("Writing event to Kubernetes ({key}, Count: {count}", key.ToString(), details.Count);
            V1Event ev = new V1Event(objRef,
                                     new V1ObjectMeta()
            {
                Name = details.Name
            },
                                     action: action,
                                     message: message,
                                     reason: reason,
                                     firstTimestamp: details.FirstSeen,
                                     lastTimestamp: details.LastSeen,
                                     count: details.Count);

            Kubernetes.ReplaceNamespacedEventAsync(ev, details.Name, objRef.NamespaceProperty);
        }