Skip to content

Commit 0bf3b90

Browse files
committed
Merge branch 'ci_feature' into ci_feature_prod
2 parents 4148765 + 153dab0 commit 0bf3b90

15 files changed

+2511
-1665
lines changed

source/code/dockerapi/DockerRemoteApi.cpp

Lines changed: 297 additions & 195 deletions
Large diffs are not rendered by default.

source/code/plugin/filter_container_log.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ def shutdown
2121
end
2222

2323
def filter(tag, time, record)
24+
begin
25+
#Try to force utf-8 encoding on the string so that all characters can flow through to
26+
#$log.info "before : #{record['LogEntry']}"
27+
record['LogEntry'].force_encoding('UTF-8')
28+
rescue
29+
$log.error "Failed to convert record['LogEntry'] : '#{record['LogEntry']}' to UTF-8 using force_encoding."
30+
$log.error "Current string encoding for record['LogEntry'] is #{record['LogEntry'].encoding}"
31+
end
32+
2433
record['Computer'] = @hostname
2534
wrapper = {
2635
"DataType"=>"CONTAINER_LOG_BLOB",

source/code/plugin/in_cadvisor_perf.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ def enumerate()
5454
#router.emit(@tag, time, record) if record
5555
end
5656

57-
router.emit_stream(@tag, eventStream) if eventStream
57+
router.emit_stream(@tag, eventStream) if eventStream
58+
if (ENV['ISTEST'] == true && eventStream.count > 0)
59+
$log.info("in_cadvisor_perf::emit-stream : Success @ #{Time.now.utc.iso8601}")
60+
end
61+
5862
rescue => errorStr
5963
$log.warn "Failed to retrieve cadvisor metric data: #{errorStr}"
6064
$log.debug_backtrace(errorStr.backtrace)

source/code/plugin/in_kube_nodes.rb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,25 @@ def enumerate
6868
# populate the KubeNodeInventory Status field. A possible value for this field could be "Ready OutofDisk"
6969
# implying that the node is ready for hosting pods, however its out of disk.
7070

71-
if items['status'].key?("conditions") && !items['status']['conditions'].empty?
71+
if items['status'].key?("conditions") && !items['status']['conditions'].empty?
72+
allNodeConditions=""
7273
items['status']['conditions'].each do |condition|
7374
if condition['status'] == "True"
74-
record['Status'] += condition['type']
75+
if !allNodeConditions.empty?
76+
allNodeConditions = allNodeConditions + "," + condition['type']
77+
else
78+
allNodeConditions = condition['type']
79+
end
7580
end
7681
#collect last transition to/from ready (no matter ready is true/false)
7782
if condition['type'] == "Ready" && !condition['lastTransitionTime'].nil?
7883
record['LastTransitionTimeReady'] = condition['lastTransitionTime']
7984
end
8085
end
86+
if !allNodeConditions.empty?
87+
record['Status'] = allNodeConditions
88+
end
89+
8190
end
8291

8392
record['KubeletVersion'] = items['status']['nodeInfo']['kubeletVersion']
@@ -90,6 +99,9 @@ def enumerate
9099
eventStream.add(emitTime, wrapper) if wrapper
91100
end
92101
router.emit_stream(@tag, eventStream) if eventStream
102+
if (ENV['ISTEST'] == true && eventStream.count > 0)
103+
$log.info("in_kube_nodeinventory::emit-stream : Success @ #{Time.now.utc.iso8601}")
104+
end
93105
end
94106
rescue => errorStr
95107
$log.warn "Failed to retrieve node inventory: #{errorStr}"

source/code/plugin/in_kube_podinventory.rb

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,39 @@ def parse_and_emit_records(podInventory, serviceList)
9292
record['PodLabel'] = [items['metadata']['labels']]
9393
record['Namespace'] = podNameSpace
9494
record['PodCreationTimeStamp'] = items['metadata']['creationTimestamp']
95-
record['PodStartTime'] = items['status']['startTime']
96-
record['PodStatus'] = items['status']['phase']
97-
record['PodIp'] =items['status']['podIP']
95+
#for unscheduled (non-started) pods startTime does NOT exist
96+
if !items['status']['startTime'].nil?
97+
record['PodStartTime'] = items['status']['startTime']
98+
else
99+
record['PodStartTime'] = ""
100+
end
101+
#podStatus
102+
# the below is for accounting 'NodeLost' scenario, where-in the pod(s) in the lost node is still being reported as running
103+
podReadyCondition = true
104+
if !items['status']['reason'].nil? && items['status']['reason'] == "NodeLost"
105+
items['status']['conditions'].each do |condition|
106+
if condition['type'] == "Ready" && condition['status'] == "False"
107+
podReadyCondition = false
108+
break
109+
end
110+
end
111+
end
112+
if podReadyCondition == false
113+
record['PodStatus'] = "Unknown"
114+
else
115+
record['PodStatus'] = items['status']['phase']
116+
end
117+
#for unscheduled (non-started) pods podIP does NOT exist
118+
if !items['status']['podIP'].nil?
119+
record['PodIp'] =items['status']['podIP']
120+
else
121+
record['PodIp'] = ""
122+
end
123+
#for unscheduled (non-started) pods nodeName does NOT exist
98124
if !items['spec']['nodeName'].nil?
99125
record['Computer'] = items['spec']['nodeName']
100126
else
101-
next
127+
record['Computer'] = ""
102128
end
103129
record['ClusterId'] = KubernetesApiClient.getClusterId
104130
record['ClusterName'] = KubernetesApiClient.getClusterName
@@ -134,15 +160,22 @@ def parse_and_emit_records(podInventory, serviceList)
134160
# "message": "Back-off 5m0s restarting failed container=metrics-server pod=metrics-server-2011498749-3g453_kube-system(5953be5f-fcae-11e7-a356-000d3ae0e432)"
135161
# }
136162
# },
137-
record['ContainerStatus'] = containerStatus.keys[0]
163+
# the below is for accounting 'NodeLost' scenario, where-in the containers in the lost node/pod(s) is still being reported as running
164+
if podReadyCondition == false
165+
record['ContainerStatus'] = "Unknown"
166+
else
167+
record['ContainerStatus'] = containerStatus.keys[0]
168+
end
138169
#TODO : Remove ContainerCreationTimeStamp from here since we are sending it as a metric
139170
#Picking up both container and node start time from cAdvisor to be consistent
140171
if containerStatus.keys[0] == "running"
141172
record['ContainerCreationTimeStamp'] = container['state']['running']['startedAt']
142173
end
143174
podRestartCount += containerRestartCount
144175
records.push(record.dup)
145-
end
176+
end
177+
else # for unscheduled pods there are no status.containerStatuses, in this case we still want the pod
178+
records.push(record)
146179
end #container status block end
147180
records.each do |record|
148181
if !record.nil?
@@ -157,6 +190,9 @@ def parse_and_emit_records(podInventory, serviceList)
157190
end
158191
end #podInventory block end
159192
router.emit_stream(@tag, eventStream) if eventStream
193+
if (ENV['ISTEST'] == true && eventStream.count > 0)
194+
$log.info("in_kube_podinventory::emit-stream : Success @ #{Time.now.utc.iso8601}")
195+
end
160196
rescue => errorStr
161197
$log.warn "Failed in parse_and_emit_record pod inventory: #{errorStr}"
162198
$log.debug_backtrace(errorStr.backtrace)

0 commit comments

Comments
 (0)