diff --git a/fluent-plugin-kubernetes_metadata_filter.gemspec b/fluent-plugin-kubernetes_metadata_filter.gemspec index 569f999..007070a 100644 --- a/fluent-plugin-kubernetes_metadata_filter.gemspec +++ b/fluent-plugin-kubernetes_metadata_filter.gemspec @@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) Gem::Specification.new do |gem| gem.name = "fluent-plugin-kubernetes_metadata_filter" - gem.version = "2.2.0" + gem.version = "2.3.0" gem.authors = ["Jimmi Dyson"] gem.email = ["jimmidyson@gmail.com"] gem.description = %q{Filter plugin to add Kubernetes metadata} @@ -21,7 +21,7 @@ Gem::Specification.new do |gem| gem.add_runtime_dependency 'fluentd', ['>= 0.14.0', '< 2'] gem.add_runtime_dependency "lru_redux" - gem.add_runtime_dependency "kubeclient", "~> 1.1.4" + gem.add_runtime_dependency "kubeclient", '< 5' gem.add_development_dependency "bundler", "~> 1.3" gem.add_development_dependency "rake" diff --git a/lib/fluent/plugin/filter_kubernetes_metadata.rb b/lib/fluent/plugin/filter_kubernetes_metadata.rb index e293521..3cff9e1 100644 --- a/lib/fluent/plugin/filter_kubernetes_metadata.rb +++ b/lib/fluent/plugin/filter_kubernetes_metadata.rb @@ -136,7 +136,7 @@ def fetch_namespace_metadata(namespace_name) metadata = parse_namespace_metadata(metadata) @stats.bump(:namespace_cache_api_updates) log.trace("parsed metadata for #{namespace_name}: #{metadata}") if log.trace? - @namespace_cache[metadata['namespace_id']] = metadata + @namespace_cache[metadata['namespace_id']] = metadata return metadata rescue Exception => e log.debug(e) @@ -164,7 +164,6 @@ def log.trace? end require 'kubeclient' - require 'active_support/core_ext/object/blank' require 'lru_redux' @stats = KubernetesMetadata::Stats.new diff --git a/lib/fluent/plugin/kubernetes_metadata_common.rb b/lib/fluent/plugin/kubernetes_metadata_common.rb index e0f4ba3..496b6ec 100644 --- a/lib/fluent/plugin/kubernetes_metadata_common.rb +++ b/lib/fluent/plugin/kubernetes_metadata_common.rb @@ -111,3 +111,29 @@ def syms_to_strs(hsh) end end + +# copied from activesupport +class Object + # An object is blank if it's false, empty, or a whitespace string. + # For example, +nil+, '', ' ', [], {}, and +false+ are all blank. + # + # This simplifies + # + # !address || address.empty? + # + # to + # + # address.blank? + # + # @return [true, false] + def blank? + respond_to?(:empty?) ? !!empty? : !self + end + + # An object is present if it's not blank. + # + # @return [true, false] + def present? + !blank? + end +end diff --git a/test/cassettes/kubernetes_docker_metadata_annotations.yml b/test/cassettes/kubernetes_docker_metadata_annotations.yml index a54f4f4..a8d0c64 100644 --- a/test/cassettes/kubernetes_docker_metadata_annotations.yml +++ b/test/cassettes/kubernetes_docker_metadata_annotations.yml @@ -18,40 +18,6 @@ # --- http_interactions: -- request: - method: get - uri: https://localhost:8443/api - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Content-Length: - - '67' - body: - encoding: UTF-8 - string: |- - { - "versions": [ - "v1" - ] - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT - request: method: get uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc diff --git a/test/cassettes/kubernetes_docker_metadata_dotted_labels.yml b/test/cassettes/kubernetes_docker_metadata_dotted_labels.yml index 34b6445..1a590cb 100644 --- a/test/cassettes/kubernetes_docker_metadata_dotted_labels.yml +++ b/test/cassettes/kubernetes_docker_metadata_dotted_labels.yml @@ -18,40 +18,6 @@ # --- http_interactions: -- request: - method: get - uri: https://localhost:8443/api - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Content-Length: - - '67' - body: - encoding: UTF-8 - string: |- - { - "versions": [ - "v1" - ] - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT - request: method: get uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc diff --git a/test/cassettes/kubernetes_get_api_v1.yml b/test/cassettes/kubernetes_get_api_v1.yml new file mode 100644 index 0000000..55f640e --- /dev/null +++ b/test/cassettes/kubernetes_get_api_v1.yml @@ -0,0 +1,193 @@ +# +# Fluentd Kubernetes Metadata Filter Plugin - Enrich Fluentd events with +# Kubernetes metadata +# +# Copyright 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--- +http_interactions: +- request: + method: get + uri: https://localhost:8443/api/v1 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json + Date: + - Fri, 08 May 2015 10:35:37 GMT + Transfer-Encoding: + - chunked + body: + encoding: UTF-8 + string: |- + { + "kind": "APIResourceList", + "groupVersion": "v1", + "resources": [ + { + "name": "bindings", + "singularName": "", + "namespaced": true, + "kind": "Binding", + "verbs": [ + "create" + ] + }, + { + "name": "namespaces", + "singularName": "", + "namespaced": false, + "kind": "Namespace", + "verbs": [ + "create", + "delete", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "ns" + ] + }, + { + "name": "namespaces/finalize", + "singularName": "", + "namespaced": false, + "kind": "Namespace", + "verbs": [ + "update" + ] + }, + { + "name": "namespaces/status", + "singularName": "", + "namespaced": false, + "kind": "Namespace", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "pods", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "po" + ], + "categories": [ + "all" + ] + }, + { + "name": "pods/attach", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/binding", + "singularName": "", + "namespaced": true, + "kind": "Binding", + "verbs": [ + "create" + ] + }, + { + "name": "pods/eviction", + "singularName": "", + "namespaced": true, + "group": "policy", + "version": "v1beta1", + "kind": "Eviction", + "verbs": [ + "create" + ] + }, + { + "name": "pods/exec", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/log", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [ + "get" + ] + }, + { + "name": "pods/portforward", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/proxy", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/status", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [ + "get", + "patch", + "update" + ] + } + ] + } + http_version: + recorded_at: Fri, 08 May 2015 10:35:37 GMT +recorded_with: VCR 2.9.3 diff --git a/test/cassettes/kubernetes_get_api_v1_using_token.yml b/test/cassettes/kubernetes_get_api_v1_using_token.yml new file mode 100644 index 0000000..6c2cf9d --- /dev/null +++ b/test/cassettes/kubernetes_get_api_v1_using_token.yml @@ -0,0 +1,195 @@ +# +# Fluentd Kubernetes Metadata Filter Plugin - Enrich Fluentd events with +# Kubernetes metadata +# +# Copyright 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--- +http_interactions: +- request: + method: get + uri: https://localhost:8443/api/v1 + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + Authorization: + - Bearer YzYyYzFlODMtODdhNS00ZTMyLWIzMmItNmY4NDc4OTI1ZWFh + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json + Date: + - Fri, 08 May 2015 10:35:37 GMT + Transfer-Encoding: + - chunked + body: + encoding: UTF-8 + string: |- + { + "kind": "APIResourceList", + "groupVersion": "v1", + "resources": [ + { + "name": "bindings", + "singularName": "", + "namespaced": true, + "kind": "Binding", + "verbs": [ + "create" + ] + }, + { + "name": "namespaces", + "singularName": "", + "namespaced": false, + "kind": "Namespace", + "verbs": [ + "create", + "delete", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "ns" + ] + }, + { + "name": "namespaces/finalize", + "singularName": "", + "namespaced": false, + "kind": "Namespace", + "verbs": [ + "update" + ] + }, + { + "name": "namespaces/status", + "singularName": "", + "namespaced": false, + "kind": "Namespace", + "verbs": [ + "get", + "patch", + "update" + ] + }, + { + "name": "pods", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [ + "create", + "delete", + "deletecollection", + "get", + "list", + "patch", + "update", + "watch" + ], + "shortNames": [ + "po" + ], + "categories": [ + "all" + ] + }, + { + "name": "pods/attach", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/binding", + "singularName": "", + "namespaced": true, + "kind": "Binding", + "verbs": [ + "create" + ] + }, + { + "name": "pods/eviction", + "singularName": "", + "namespaced": true, + "group": "policy", + "version": "v1beta1", + "kind": "Eviction", + "verbs": [ + "create" + ] + }, + { + "name": "pods/exec", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/log", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [ + "get" + ] + }, + { + "name": "pods/portforward", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/proxy", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [] + }, + { + "name": "pods/status", + "singularName": "", + "namespaced": true, + "kind": "Pod", + "verbs": [ + "get", + "patch", + "update" + ] + } + ] + } + http_version: + recorded_at: Fri, 08 May 2015 10:35:37 GMT +recorded_with: VCR 2.9.3 diff --git a/test/cassettes/kubernetes_get_namespace_default.yml b/test/cassettes/kubernetes_get_namespace_default.yml new file mode 100644 index 0000000..619083f --- /dev/null +++ b/test/cassettes/kubernetes_get_namespace_default.yml @@ -0,0 +1,69 @@ +# +# Fluentd Kubernetes Metadata Filter Plugin - Enrich Fluentd events with +# Kubernetes metadata +# +# Copyright 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--- +http_interactions: +- request: + method: get + uri: https://localhost:8443/api/v1/namespaces/default + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json + Date: + - Fri, 08 May 2015 10:35:37 GMT + Transfer-Encoding: + - chunked + body: + encoding: UTF-8 + string: |- + { + "kind": "Namespace", + "apiVersion": "v1", + "metadata": { + "name": "default", + "selfLink": "/api/v1/namespaces/default", + "uid": "898268c8-4a36-11e5-9d81-42010af0194c", + "resourceVersion": "6", + "creationTimestamp": "2015-05-08T09:22:01Z" + }, + "spec": { + "finalizers": [ + "kubernetes" + ] + }, + "status": { + "phase": "Active" + } + } + http_version: + recorded_at: Fri, 08 May 2015 10:35:37 GMT +recorded_with: VCR 2.9.3 diff --git a/test/cassettes/kubernetes_get_namespace_default_using_token.yml b/test/cassettes/kubernetes_get_namespace_default_using_token.yml new file mode 100644 index 0000000..144acc2 --- /dev/null +++ b/test/cassettes/kubernetes_get_namespace_default_using_token.yml @@ -0,0 +1,71 @@ +# +# Fluentd Kubernetes Metadata Filter Plugin - Enrich Fluentd events with +# Kubernetes metadata +# +# Copyright 2015 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +--- +http_interactions: +- request: + method: get + uri: https://localhost:8443/api/v1/namespaces/default + body: + encoding: US-ASCII + string: '' + headers: + Accept: + - "*/*; q=0.5, application/xml" + Accept-Encoding: + - gzip, deflate + User-Agent: + - Ruby + Authorization: + - Bearer YzYyYzFlODMtODdhNS00ZTMyLWIzMmItNmY4NDc4OTI1ZWFh + response: + status: + code: 200 + message: OK + headers: + Content-Type: + - application/json + Date: + - Fri, 08 May 2015 10:35:37 GMT + Transfer-Encoding: + - chunked + body: + encoding: UTF-8 + string: |- + { + "kind": "Namespace", + "apiVersion": "v1", + "metadata": { + "name": "default", + "selfLink": "/api/v1/namespaces/default", + "uid": "898268c8-4a36-11e5-9d81-42010af0194c", + "resourceVersion": "6", + "creationTimestamp": "2015-05-08T09:22:01Z" + }, + "spec": { + "finalizers": [ + "kubernetes" + ] + }, + "status": { + "phase": "Active" + } + } + http_version: + recorded_at: Fri, 08 May 2015 10:35:37 GMT +recorded_with: VCR 2.9.3 diff --git a/test/cassettes/kubernetes_docker_metadata.yml b/test/cassettes/kubernetes_get_pod.yml similarity index 72% rename from test/cassettes/kubernetes_docker_metadata.yml rename to test/cassettes/kubernetes_get_pod.yml index ff5d933..651b0d2 100644 --- a/test/cassettes/kubernetes_docker_metadata.yml +++ b/test/cassettes/kubernetes_get_pod.yml @@ -18,40 +18,6 @@ # --- http_interactions: -- request: - method: get - uri: https://localhost:8443/api - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Content-Length: - - '67' - body: - encoding: UTF-8 - string: |- - { - "versions": [ - "v1" - ] - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT - request: method: get uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc @@ -177,52 +143,4 @@ http_interactions: } http_version: recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT recorded_with: VCR 2.9.3 diff --git a/test/cassettes/kubernetes_docker_metadata_using_bearer_token.yml b/test/cassettes/kubernetes_get_pod_using_token.yml similarity index 62% rename from test/cassettes/kubernetes_docker_metadata_using_bearer_token.yml rename to test/cassettes/kubernetes_get_pod_using_token.yml index d41d64e..31238ad 100644 --- a/test/cassettes/kubernetes_docker_metadata_using_bearer_token.yml +++ b/test/cassettes/kubernetes_get_pod_using_token.yml @@ -18,42 +18,6 @@ # --- http_interactions: -- request: - method: get - uri: https://localhost:8443/api - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - Authorization: - - Bearer YzYyYzFlODMtODdhNS00ZTMyLWIzMmItNmY4NDc4OTI1ZWFh - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Sat, 09 May 2015 13:51:07 GMT - Content-Length: - - '67' - body: - encoding: UTF-8 - string: |- - { - "versions": [ - "v1" - ] - } - http_version: - recorded_at: Sat, 09 May 2015 13:51:07 GMT - request: method: get uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc @@ -77,7 +41,7 @@ http_interactions: Content-Type: - application/json Date: - - Sat, 09 May 2015 13:51:07 GMT + - Fri, 08 May 2015 10:35:37 GMT Transfer-Encoding: - chunked body: @@ -92,7 +56,7 @@ http_interactions: "namespace": "default", "selfLink": "/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc", "uid": "c76927af-f563-11e4-b32d-54ee7527188d", - "resourceVersion": "3556", + "resourceVersion": "122", "creationTimestamp": "2015-05-08T09:22:42Z", "labels": { "component": "fabric8Console" @@ -160,89 +124,25 @@ http_interactions: } ], "hostIP": "172.17.42.1", - "podIP": "172.17.0.4", + "podIP": "172.17.0.8", "containerStatuses": [ { "name": "fabric8-console-container", "state": { "running": { - "startedAt": "2015-05-09T13:33:38Z" + "startedAt": "2015-05-08T09:22:44Z" } }, "lastState": {}, "ready": true, - "restartCount": 2, + "restartCount": 0, "image": "fabric8/hawtio-kubernetes:latest", "imageID": "docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303", "containerID": "docker://49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459" - }, - { - "name": "POD", - "state": { - "termination": { - "exitCode": 0, - "startedAt": "2015-05-09T09:45:08Z", - "finishedAt": "2015-05-09T09:47:00Z" - } - }, - "lastState": {}, - "ready": false, - "restartCount": 1, - "image": "openshift/origin-pod:v0.4.4", - "imageID": "docker://81fa37a83ec46fed9dddf30a9c3c43f54bfe4b65dea74a4c152fd515a0bf92a8", - "containerID": "docker://9c8ed1a9bbb6d9804b12379654461dcd3b447438c02c52ca7f7d2504e14ae96b" } ] } } http_version: - recorded_at: Sat, 09 May 2015 13:51:07 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: recorded_at: Fri, 08 May 2015 10:35:37 GMT recorded_with: VCR 2.9.3 diff --git a/test/cassettes/metadata_from_tag_and_journald_fields.yml b/test/cassettes/metadata_from_tag_and_journald_fields.yml index 926a930..7374233 100644 --- a/test/cassettes/metadata_from_tag_and_journald_fields.yml +++ b/test/cassettes/metadata_from_tag_and_journald_fields.yml @@ -18,261 +18,6 @@ # --- http_interactions: -- request: - method: get - uri: https://localhost:8443/api - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Content-Length: - - '67' - body: - encoding: UTF-8 - string: |- - { - "versions": [ - "v1" - ] - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Pod", - "apiVersion": "v1", - "metadata": { - "name": "fabric8-console-controller-98rqc", - "generateName": "fabric8-console-controller-", - "namespace": "default", - "selfLink": "/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc", - "uid": "c76927af-f563-11e4-b32d-54ee7527188d", - "resourceVersion": "122", - "creationTimestamp": "2015-05-08T09:22:42Z", - "labels": { - "component": "fabric8Console" - } - }, - "spec": { - "volumes": [ - { - "name": "openshift-cert-secrets", - "hostPath": null, - "emptyDir": null, - "gcePersistentDisk": null, - "gitRepo": null, - "secret": { - "secretName": "openshift-cert-secrets" - }, - "nfs": null, - "iscsi": null, - "glusterfs": null - } - ], - "containers": [ - { - "name": "fabric8-console-container", - "image": "fabric8/hawtio-kubernetes:latest", - "ports": [ - { - "containerPort": 9090, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "OAUTH_CLIENT_ID", - "value": "fabric8-console" - }, - { - "name": "OAUTH_AUTHORIZE_URI", - "value": "https://localhost:8443/oauth/authorize" - } - ], - "resources": {}, - "volumeMounts": [ - { - "name": "openshift-cert-secrets", - "readOnly": true, - "mountPath": "/etc/secret-volume" - } - ], - "terminationMessagePath": "/dev/termination-log", - "imagePullPolicy": "IfNotPresent", - "capabilities": {} - } - ], - "restartPolicy": "Always", - "dnsPolicy": "ClusterFirst", - "nodeName": "jimmi-redhat.localnet" - }, - "status": { - "phase": "Running", - "Condition": [ - { - "type": "Ready", - "status": "True" - } - ], - "hostIP": "172.17.42.1", - "podIP": "172.17.0.8", - "containerStatuses": [ - { - "name": "fabric8-console-container", - "state": { - "running": { - "startedAt": "2015-05-08T09:22:44Z" - } - }, - "lastState": {}, - "ready": true, - "restartCount": 0, - "image": "fabric8/hawtio-kubernetes:latest", - "imageID": "docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303", - "containerID": "docker://49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459" - } - ] - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT - request: method: get uri: https://localhost:8443/api/v1/namespaces/journald-namespace-name/pods/journald-pod-name diff --git a/test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml b/test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml index eefadcc..cffddca 100644 --- a/test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml +++ b/test/cassettes/metadata_from_tag_journald_and_kubernetes_fields.yml @@ -18,261 +18,6 @@ # --- http_interactions: -- request: - method: get - uri: https://localhost:8443/api - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Content-Length: - - '67' - body: - encoding: UTF-8 - string: |- - { - "versions": [ - "v1" - ] - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Pod", - "apiVersion": "v1", - "metadata": { - "name": "fabric8-console-controller-98rqc", - "generateName": "fabric8-console-controller-", - "namespace": "default", - "selfLink": "/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc", - "uid": "c76927af-f563-11e4-b32d-54ee7527188d", - "resourceVersion": "122", - "creationTimestamp": "2015-05-08T09:22:42Z", - "labels": { - "component": "fabric8Console" - } - }, - "spec": { - "volumes": [ - { - "name": "openshift-cert-secrets", - "hostPath": null, - "emptyDir": null, - "gcePersistentDisk": null, - "gitRepo": null, - "secret": { - "secretName": "openshift-cert-secrets" - }, - "nfs": null, - "iscsi": null, - "glusterfs": null - } - ], - "containers": [ - { - "name": "fabric8-console-container", - "image": "fabric8/hawtio-kubernetes:latest", - "ports": [ - { - "containerPort": 9090, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "OAUTH_CLIENT_ID", - "value": "fabric8-console" - }, - { - "name": "OAUTH_AUTHORIZE_URI", - "value": "https://localhost:8443/oauth/authorize" - } - ], - "resources": {}, - "volumeMounts": [ - { - "name": "openshift-cert-secrets", - "readOnly": true, - "mountPath": "/etc/secret-volume" - } - ], - "terminationMessagePath": "/dev/termination-log", - "imagePullPolicy": "IfNotPresent", - "capabilities": {} - } - ], - "restartPolicy": "Always", - "dnsPolicy": "ClusterFirst", - "nodeName": "jimmi-redhat.localnet" - }, - "status": { - "phase": "Running", - "Condition": [ - { - "type": "Ready", - "status": "True" - } - ], - "hostIP": "172.17.42.1", - "podIP": "172.17.0.8", - "containerStatuses": [ - { - "name": "fabric8-console-container", - "state": { - "running": { - "startedAt": "2015-05-08T09:22:44Z" - } - }, - "lastState": {}, - "ready": true, - "restartCount": 0, - "image": "fabric8/hawtio-kubernetes:latest", - "imageID": "docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303", - "containerID": "docker://49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459" - } - ] - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT - request: method: get uri: https://localhost:8443/api/v1/namespaces/journald-namespace-name/pods/journald-pod-name diff --git a/test/cassettes/metadata_with_namespace_id.yml b/test/cassettes/metadata_with_namespace_id.yml deleted file mode 100644 index 5edd06b..0000000 --- a/test/cassettes/metadata_with_namespace_id.yml +++ /dev/null @@ -1,276 +0,0 @@ -# -# Fluentd Kubernetes Metadata Filter Plugin - Enrich Fluentd events with -# Kubernetes metadata -# -# Copyright 2015 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# ---- -http_interactions: -- request: - method: get - uri: https://localhost:8443/api - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Content-Length: - - '67' - body: - encoding: UTF-8 - string: |- - { - "versions": [ - "v1" - ] - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Pod", - "apiVersion": "v1", - "metadata": { - "name": "fabric8-console-controller-98rqc", - "generateName": "fabric8-console-controller-", - "namespace": "default", - "selfLink": "/api/v1/namespaces/default/pods/fabric8-console-controller-98rqc", - "uid": "c76927af-f563-11e4-b32d-54ee7527188d", - "resourceVersion": "122", - "creationTimestamp": "2015-05-08T09:22:42Z", - "labels": { - "component": "fabric8Console" - } - }, - "spec": { - "volumes": [ - { - "name": "openshift-cert-secrets", - "hostPath": null, - "emptyDir": null, - "gcePersistentDisk": null, - "gitRepo": null, - "secret": { - "secretName": "openshift-cert-secrets" - }, - "nfs": null, - "iscsi": null, - "glusterfs": null - } - ], - "containers": [ - { - "name": "fabric8-console-container", - "image": "fabric8/hawtio-kubernetes:latest", - "ports": [ - { - "containerPort": 9090, - "protocol": "TCP" - } - ], - "env": [ - { - "name": "OAUTH_CLIENT_ID", - "value": "fabric8-console" - }, - { - "name": "OAUTH_AUTHORIZE_URI", - "value": "https://localhost:8443/oauth/authorize" - } - ], - "resources": {}, - "volumeMounts": [ - { - "name": "openshift-cert-secrets", - "readOnly": true, - "mountPath": "/etc/secret-volume" - } - ], - "terminationMessagePath": "/dev/termination-log", - "imagePullPolicy": "IfNotPresent", - "capabilities": {} - } - ], - "restartPolicy": "Always", - "dnsPolicy": "ClusterFirst", - "nodeName": "jimmi-redhat.localnet" - }, - "status": { - "phase": "Running", - "Condition": [ - { - "type": "Ready", - "status": "True" - } - ], - "hostIP": "172.17.42.1", - "podIP": "172.17.0.8", - "containerStatuses": [ - { - "name": "fabric8-console-container", - "state": { - "running": { - "startedAt": "2015-05-08T09:22:44Z" - } - }, - "lastState": {}, - "ready": true, - "restartCount": 0, - "image": "fabric8/hawtio-kubernetes:latest", - "imageID": "docker://b2bd1a24a68356b2f30128e6e28e672c1ef92df0d9ec01ec0c7faea5d77d2303", - "containerID": "docker://49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459" - } - ] - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Transfer-Encoding: - - chunked - body: - encoding: UTF-8 - string: |- - { - "kind": "Namespace", - "apiVersion": "v1", - "metadata": { - "name": "default", - "selfLink": "/api/v1/namespaces/default", - "uid": "898268c8-4a36-11e5-9d81-42010af0194c", - "resourceVersion": "6", - "creationTimestamp": "2015-05-08T09:22:01Z" - }, - "spec": { - "finalizers": [ - "kubernetes" - ] - }, - "status": { - "phase": "Active" - } - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -recorded_with: VCR 2.9.3 diff --git a/test/cassettes/non_kubernetes_docker_metadata.yml b/test/cassettes/valid_kubernetes_api_server_using_token.yml similarity index 53% rename from test/cassettes/non_kubernetes_docker_metadata.yml rename to test/cassettes/valid_kubernetes_api_server_using_token.yml index 3f4c2d2..ea3efc1 100644 --- a/test/cassettes/non_kubernetes_docker_metadata.yml +++ b/test/cassettes/valid_kubernetes_api_server_using_token.yml @@ -31,6 +31,8 @@ http_interactions: - gzip, deflate User-Agent: - Ruby + Authorization: + - Bearer YzYyYzFlODMtODdhNS00ZTMyLWIzMmItNmY4NDc4OTI1ZWFh response: status: code: 200 @@ -39,7 +41,7 @@ http_interactions: Content-Type: - application/json Date: - - Fri, 08 May 2015 10:35:37 GMT + - Fri, 08 May 2015 10:13:54 GMT Content-Length: - '67' body: @@ -51,47 +53,5 @@ http_interactions: ] } http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT -- request: - method: get - uri: https://localhost:8443/api/v1/namespaces/default/pods/fabric8-forge-controller-ymkew - body: - encoding: US-ASCII - string: '' - headers: - Accept: - - "*/*; q=0.5, application/xml" - Accept-Encoding: - - gzip, deflate - User-Agent: - - Ruby - response: - status: - code: 404 - message: Not Found - headers: - Content-Type: - - application/json - Date: - - Fri, 08 May 2015 10:35:37 GMT - Content-Length: - - '278' - body: - encoding: UTF-8 - string: |- - { - "kind": "Status", - "apiVersion": "v1", - "metadata": {}, - "status": "Failure", - "message": "pods \"fabric8-forge-controller-ymkew\" not found", - "reason": "NotFound", - "details": { - "id": "fabric8-forge-controller-ymkew", - "kind": "pods" - }, - "code": 404 - } - http_version: - recorded_at: Fri, 08 May 2015 10:35:37 GMT + recorded_at: Fri, 08 May 2015 10:13:54 GMT recorded_with: VCR 2.9.3 diff --git a/test/plugin/test_filter_kubernetes_metadata.rb b/test/plugin/test_filter_kubernetes_metadata.rb index 87619b3..6b42ced 100644 --- a/test/plugin/test_filter_kubernetes_metadata.rb +++ b/test/plugin/test_filter_kubernetes_metadata.rb @@ -38,6 +38,7 @@ def create_driver(conf = '') end sub_test_case 'configure' do + test 'check default' do d = create_driver assert_equal(1000, d.instance.cache_size) @@ -168,7 +169,7 @@ def emit_with_tag(tag, msg={}, config=' end test 'inability to connect to the api server handles exception and doensnt block pipeline' do - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}]) do driver = create_driver(' kubernetes_url https://localhost:8443 watch false @@ -195,7 +196,7 @@ def emit_with_tag(tag, msg={}, config=' end test 'with docker & kubernetes metadata where id cache hit and metadata miss' do - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}]) do driver = create_driver(' kubernetes_url https://localhost:8443 watch false @@ -228,7 +229,7 @@ def emit_with_tag(tag, msg={}, config=' end test 'with docker & kubernetes metadata where id cache hit and metadata is reloaded' do - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, {name: 'kubernetes_get_namespace_default'}]) do driver = create_driver(' kubernetes_url https://localhost:8443 watch false @@ -266,7 +267,7 @@ def emit_with_tag(tag, msg={}, config=' end test 'with docker & kubernetes metadata' do - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, {name: 'kubernetes_get_namespace_default'}]) do filtered = emit({'time'=>'2015-05-08T09:22:01Z'}) expected_kube_metadata = { 'time'=>'2015-05-08T09:22:01Z', @@ -294,7 +295,8 @@ def emit_with_tag(tag, msg={}, config=' end test 'with docker & kubernetes metadata & namespace_id enabled' do - VCR.use_cassette('metadata_with_namespace_id') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default', options: {allow_playback_repeats: true}}]) do filtered = emit({}, ' kubernetes_url https://localhost:8443 watch false @@ -324,7 +326,8 @@ def emit_with_tag(tag, msg={}, config=' end test 'with docker & kubernetes metadata using bearer token' do - VCR.use_cassette('kubernetes_docker_metadata_using_bearer_token') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server_using_token'}, {name: 'kubernetes_get_api_v1_using_token'}, + {name: 'kubernetes_get_pod_using_token'}, {name: 'kubernetes_get_namespace_default_using_token'}]) do filtered = emit({}, ' kubernetes_url https://localhost:8443 verify_ssl false @@ -429,7 +432,8 @@ def emit_with_tag(tag, msg={}, config=' end test 'with kubernetes dotted labels, de_dot enabled' do - VCR.use_cassette('kubernetes_docker_metadata_dotted_labels') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_docker_metadata_dotted_labels'}]) do filtered = emit({}, ' kubernetes_url https://localhost:8443 watch false @@ -462,7 +466,8 @@ def emit_with_tag(tag, msg={}, config=' end test 'with kubernetes dotted labels, de_dot disabled' do - VCR.use_cassette('kubernetes_docker_metadata_dotted_labels') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_docker_metadata_dotted_labels'}]) do filtered = emit({}, ' kubernetes_url https://localhost:8443 watch false @@ -511,7 +516,8 @@ def emit_with_tag(tag, msg={}, config=' 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459', 'randomfield' => 'randomvalue' } - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default'}]) do filtered = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -549,7 +555,8 @@ def emit_with_tag(tag, msg={}, config=' 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459', 'randomfield' => 'randomvalue' } - VCR.use_cassette('metadata_with_namespace_id') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default', options: {allow_playback_repeats: true}}]) do filtered = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -593,7 +600,9 @@ def emit_with_tag(tag, msg={}, config=' 'docker' => {'container_id' => 'e463bc0d3ae38f5c89d92dca49b30e049e899799920b79d4d5f705acbe82ba95'}, 'randomfield' => 'randomvalue' } - VCR.use_cassette('metadata_from_tag_journald_and_kubernetes_fields') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default'}, + {name: 'metadata_from_tag_journald_and_kubernetes_fields'}]) do es = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -636,7 +645,9 @@ def emit_with_tag(tag, msg={}, config=' 'docker' => {'container_id' => 'e463bc0d3ae38f5c89d92dca49b30e049e899799920b79d4d5f705acbe82ba95'}, 'randomfield' => 'randomvalue' } - VCR.use_cassette('metadata_from_tag_and_journald_fields') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default', options: {allow_playback_repeats: true}}, + {name: 'metadata_from_tag_and_journald_fields'}]) do es = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -680,7 +691,9 @@ def emit_with_tag(tag, msg={}, config=' 'docker' => {'container_id' => 'e463bc0d3ae38f5c89d92dca49b30e049e899799920b79d4d5f705acbe82ba95'}, 'randomfield' => 'randomvalue' } - VCR.use_cassette('metadata_from_tag_and_journald_fields') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default', options: {allow_playback_repeats: true}}, + {name: 'metadata_from_tag_and_journald_fields'}]) do es = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -712,7 +725,9 @@ def emit_with_tag(tag, msg={}, config=' end test 'with kubernetes annotations' do - VCR.use_cassette('kubernetes_docker_metadata_annotations') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_docker_metadata_annotations'}, + {name: 'kubernetes_get_namespace_default'}]) do filtered = emit({},' kubernetes_url https://localhost:8443 watch false @@ -754,7 +769,9 @@ def emit_with_tag(tag, msg={}, config=' 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459', 'randomfield' => 'randomvalue' } - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default'}, + {name: 'metadata_from_tag_and_journald_fields'}]) do filtered = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -785,7 +802,9 @@ def emit_with_tag(tag, msg={}, config=' end test 'with kubernetes namespace annotations' do - VCR.use_cassette('kubernetes_docker_metadata_annotations') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_docker_metadata_annotations'}, + {name: 'kubernetes_get_namespace_default'}]) do filtered = emit({},' kubernetes_url https://localhost:8443 watch false @@ -823,7 +842,9 @@ def emit_with_tag(tag, msg={}, config=' end test 'with kubernetes namespace annotations no match' do - VCR.use_cassette('kubernetes_docker_metadata_annotations') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_docker_metadata_annotations'}, + {name: 'kubernetes_get_namespace_default'}]) do filtered = emit({},' kubernetes_url https://localhost:8443 watch false @@ -859,7 +880,9 @@ def emit_with_tag(tag, msg={}, config=' 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459', 'randomfield' => 'randomvalue' } - VCR.use_cassette('kubernetes_docker_metadata_annotations') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_docker_metadata_annotations'}, + {name: 'kubernetes_get_namespace_default'}]) do filtered = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -881,7 +904,9 @@ def emit_with_tag(tag, msg={}, config=' 'CONTAINER_ID_FULL' => '49095a2894da899d3b327c5fde1e056a81376cc9a8f8b09a195f2a92bceed459', 'randomfield' => 'randomvalue' } - VCR.use_cassette('kubernetes_docker_metadata_annotations') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_docker_metadata_annotations'}, + {name: 'kubernetes_get_namespace_default'}]) do filtered = emit_with_tag(tag, msg, ' kubernetes_url https://localhost:8443 watch false @@ -898,7 +923,9 @@ def emit_with_tag(tag, msg={}, config=' end test 'processes all events when reading from MessagePackEventStream' do - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, + {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default'}]) do entries = [[@time, {'time'=>'2015-05-08T09:22:01Z'}], [@time, {'time'=>'2015-05-08T09:22:01Z'}]] array_stream = Fluent::ArrayEventStream.new(entries) msgpack_stream = Fluent::MessagePackEventStream.new(array_stream.to_msgpack_stream) @@ -940,7 +967,8 @@ def emit_with_tag(tag, msg={}, config=' end test 'with docker & kubernetes metadata using skip config params' do - VCR.use_cassette('kubernetes_docker_metadata') do + VCR.use_cassettes([{name: 'valid_kubernetes_api_server'}, {name: 'kubernetes_get_api_v1'}, {name: 'kubernetes_get_pod'}, + {name: 'kubernetes_get_namespace_default'}]) do filtered = emit({},' kubernetes_url https://localhost:8443 watch false