Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 378bb17

Browse files
author
Donald Tregonning
authored
Bump release to version 1.1.1 - support watcher fix (#24)
* Backfill develop from master release branch 1.1.0 (#20) * Release Fluent Plugin Kubernetes Objects v1.1.0 (#17) * modified watcher function to fix failure after an hour (#21) * prep for 1.1.1 release (#22)
1 parent 9070d60 commit 378bb17

File tree

9 files changed

+34
-22
lines changed

9 files changed

+34
-22
lines changed

.circleci/build_and_push.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ aws ecr get-login --region $AWS_REGION --no-include-email | bash
44
echo "Building docker image..."
55
cp /tmp/pkg/fluent-plugin-kubernetes-objects-*.gem docker
66
echo "Copy latest fluent-plugin-splunk-hec gem from S3"
7-
docker build --build-arg VERSION=$FLUENT_SPLUNK_HEC_GEM_VERSION --no-cache -t splunk/fluent-plugin-kubernetes-objects:ci ./docker
7+
docker build --build-arg VERSION=$VERSION --build-arg FLUENT_SPLUNK_HEC_GEM_VERSION=$FLUENT_SPLUNK_HEC_GEM_VERSION --no-cache -t splunk/fluent-plugin-kubernetes-objects:ci ./docker
88
docker tag splunk/fluent-plugin-kubernetes-objects:ci $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/k8s-ci-objects:latest
99
echo "Push docker image to ecr..."
1010
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/k8s-ci-objects:latest | awk 'END{print}'

.circleci/build_and_push_to_dockerhub.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ set -e
33
echo "Building docker image..."
44
cp /tmp/pkg/fluent-plugin-kubernetes-objects-*.gem docker
55
VERSION=`cat VERSION`
6-
docker build --build-arg VERSION=$VERSION --no-cache -t splunk/fluent-plugin-kubernetes-objects:ci ./docker
6+
docker build --build-arg VERSION=$VERSION --build-arg FLUENT_SPLUNK_HEC_GEM_VERSION=$FLUENT_SPLUNK_HEC_GEM_VERSION --no-cache -t splunk/fluent-plugin-kubernetes-objects:ci ./docker
77
docker tag splunk/fluent-plugin-kubernetes-objects:ci splunk/${DOCKERHUB_REPO_NAME}:${VERSION}
88
echo "Push docker image to splunk dockerhub..."
99
docker login --username=$DOCKERHUB_ACCOUNT_ID --password=$DOCKERHUB_ACCOUNT_PASS

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
/pkg/
77
/spec/reports/
88
/tmp/
9+
/vendor/
910
*.gem
1011
.DS_Store
1112
*.aes

Gemfile.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: .
33
specs:
4-
fluent-plugin-kubernetes-objects (1.0.0)
5-
fluentd (~> 1.3)
4+
fluent-plugin-kubernetes-objects (1.1.1)
5+
fluentd (~> 1.4)
66
kubeclient (~> 4.2)
77

88
GEM
@@ -17,7 +17,7 @@ GEM
1717
docile (1.3.1)
1818
domain_name (0.5.20180417)
1919
unf (>= 0.0.5, < 1.0.0)
20-
fluentd (1.3.3)
20+
fluentd (1.4.1)
2121
cool.io (>= 1.4.5, < 2.0.0)
2222
dig_rb (~> 1.0.0)
2323
http_parser.rb (>= 0.5.1, < 0.7.0)
@@ -39,15 +39,15 @@ GEM
3939
http-form_data (2.1.1)
4040
http_parser.rb (0.6.0)
4141
json (2.1.0)
42-
kubeclient (4.2.2)
42+
kubeclient (4.3.0)
4343
http (~> 3.0)
4444
recursive-open-struct (~> 1.0, >= 1.0.4)
4545
rest-client (~> 2.0)
4646
mime-types (3.2.2)
4747
mime-types-data (~> 3.2015)
4848
mime-types-data (3.2018.0812)
4949
minitest (5.11.3)
50-
msgpack (1.2.6)
50+
msgpack (1.2.9)
5151
netrc (0.11.0)
5252
power_assert (1.1.3)
5353
public_suffix (3.0.3)
@@ -72,7 +72,7 @@ GEM
7272
thread_safe (0.3.6)
7373
tzinfo (1.2.5)
7474
thread_safe (~> 0.1)
75-
tzinfo-data (1.2018.9)
75+
tzinfo-data (1.2019.1)
7676
tzinfo (>= 1.0.0)
7777
unf (0.1.4)
7878
unf_ext

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.0
1+
1.1.1

docker/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ LABEL maintainer="Splunk Inc. <[email protected]>"
44
LABEL Description="Splunk Connect for Kubernetes docker image" Vendor="Splunk Inc."
55

66
ARG VERSION
7+
ARG FLUENT_SPLUNK_HEC_GEM_VERSION
78
ENV VERSION=${VERSION}
9+
ENV FLUENT_SPLUNK_HEC_GEM_VERSION=${FLUENT_SPLUNK_HEC_GEM_VERSION}
10+
811

912
# skip runtime bundler installation
1013
ENV FLUENTD_DISABLE_BUNDLER_INJECTION 1
@@ -21,7 +24,7 @@ RUN set -e \
2124
&& gem install -N fluent-plugin-prometheus -v "1.3.0" \
2225
&& gem install -N fluent-plugin-jq -v "0.5.1" \
2326
&& gem install -N oj -v "3.7.9" \
24-
&& gem install -N fluent-plugin-splunk-hec:${VERSION} \
27+
&& gem install -N fluent-plugin-splunk-hec:${FLUENT_SPLUNK_HEC_GEM_VERSION} \
2528
&& gem install -N /tmp/*.gem \
2629
&& dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
2730
&& wget -O /usr/bin/dumb-init https://github.com/Yelp/dumb-init/releases/download/v1.2.1/dumb-init_1.2.1_$dpkgArch \

fluent-plugin-kubernetes-objects.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
3232

3333
spec.required_ruby_version = '>= 2.3.0'
3434

35-
spec.add_runtime_dependency 'fluentd', '~> 1.3'
35+
spec.add_runtime_dependency 'fluentd', '~> 1.4'
3636
spec.add_runtime_dependency 'kubeclient', '~> 4.2'
3737

3838
spec.add_development_dependency 'bundler', '~> 2.0'

lib/fluent/plugin/in_kubernetes_objects.rb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
module Fluent::Plugin
77
class KubernetesObjectsInput < Fluent::Plugin::Input
8-
VERSION = '1.1.0'.freeze
8+
VERSION = '1.1.1'.freeze
99

1010
Fluent::Plugin.register_input('kubernetes_objects', self)
1111

@@ -72,6 +72,9 @@ class KubernetesObjectsInput < Fluent::Plugin::Input
7272

7373
desc 'A selector to restrict the list of returned objects by fields.'
7474
config_param :field_selector, :string, default: nil
75+
76+
desc 'The interval at which the objects will be watched.'
77+
config_param :interval, :time, default: 15 * 60
7578
end
7679

7780
config_section :storage do
@@ -140,7 +143,7 @@ def initialize_client
140143
if @bearer_token_file.nil? && File.exist?(secret_token_file)
141144
@bearer_token_file = secret_token_file
142145
end
143-
end
146+
end
144147

145148
ssl_options = {
146149
client_cert: @client_cert && OpenSSL::X509::Certificate.new(File.read(@client_cert)),
@@ -174,10 +177,12 @@ def start_watchers
174177
o = o.to_h.dup
175178
o[:as] = :raw
176179
resource_name = o.delete(:resource_name)
180+
watch_interval = o.delete(:interval)
181+
177182
version = @storage.get(resource_name)
178183
o[:resource_version] = version if version
179184
@client.public_send("watch_#{resource_name}", o).tap do |watcher|
180-
create_watcher_thread resource_name, watcher
185+
create_watcher_thread resource_name, watcher, watch_interval
181186
end
182187
end
183188
end
@@ -209,7 +214,7 @@ def create_pull_thread(conf)
209214
->(item) { item['metadata'].update requestResourceVersion: resource_version }
210215
else
211216
->(item) {}
212-
end
217+
end
213218

214219
# result['items'] might be nil due to https://github.com/kubernetes/kubernetes/issues/13096
215220
items = result['items'].to_a
@@ -222,14 +227,17 @@ def create_pull_thread(conf)
222227
end
223228
end
224229

225-
def create_watcher_thread(object_name, watcher)
230+
def create_watcher_thread(object_name, watcher, interval)
226231
thread_create(:"watch_#{object_name}") do
227232
tag = generate_tag "#{object_name}.watch"
228-
watcher.each do |entity|
229-
log.trace { "Received new object from watching #{object_name}" }
230-
entity = JSON.parse(entity)
231-
router.emit tag, Fluent::Engine.now, entity
232-
@storage.put object_name, entity['object']['metadata']['resourceVersion']
233+
while thread_current_running?
234+
watcher.each do |entity|
235+
log.trace { "Received new object from watching #{object_name}" }
236+
entity = JSON.parse(entity)
237+
router.emit tag, Fluent::Engine.now, entity
238+
@storage.put object_name, entity['object']['metadata']['resourceVersion']
239+
sleep(interval)
240+
end
233241
end
234242
end
235243
end

test/fluent/plugin/in_kubernetes_objects_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
stub_k8s_events params: {resourceVersion: "123456"}
136136

137137
d.run expect_emits: 1, timeout: 3
138-
ensure
138+
ensure
139139
f.unlink
140140
end
141141
end

0 commit comments

Comments
 (0)