Skip to content

Commit

Permalink
1.1.10 (#84)
Browse files Browse the repository at this point in the history
  • Loading branch information
hvaghani221 authored Mar 15, 2022
1 parent e9c2fdf commit 44e3e88
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 35 deletions.
18 changes: 11 additions & 7 deletions .github/workflows/ci_build_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
build:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -35,7 +35,7 @@ jobs:
key: ${{ runner.os }}-build

unit-test:
runs-on: ubuntu-latest
runs-on: ubuntu-20.04
needs:
- build
steps:
Expand Down Expand Up @@ -67,8 +67,9 @@ jobs:
CI_INDEX_EVENTS: ci_events
CI_INDEX_OBJECTS: ci_objects
CI_INDEX_METRICS: ci_metrics
KUBERNETES_VERSION: v1.15.2
MINIKUBE_VERSION: v1.21.0
KUBERNETES_VERSION: v1.23.2
MINIKUBE_VERSION: v1.24.0
MINIKUBE_NODE_COUNTS: 2
GITHUB_ACTIONS: true

steps:
Expand Down Expand Up @@ -121,7 +122,7 @@ jobs:
chmod +x minikube
sudo mv minikube /usr/local/bin/
# Start Minikube and Wait
minikube start --driver=docker --container-runtime=docker --cpus 2 --memory 4096 --kubernetes-version=${KUBERNETES_VERSION} --no-vtx-check
minikube start --driver=docker --container-runtime=docker --cpus 2 --memory 4096 --kubernetes-version=${KUBERNETES_VERSION} --no-vtx-check -n=${MINIKUBE_NODE_COUNTS}
export JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
sleep 1;
Expand All @@ -130,13 +131,15 @@ jobs:
- name: Install Splunk
run: |
# Wait until minikube is ready
kubectl apply -f https://docs.projectcalico.org/v3.14/manifests/calico.yaml
export JSONPATH='{range .items[*]}{@.metadata.name}:{range @.status.conditions[*]}{@.type}={@.status};{end}{end}'
until kubectl get nodes -o jsonpath="$JSONPATH" 2>&1 | grep -q "Ready=True"; do
echo "wait for minikube ready ..."
sleep 1;
done
kubectl get nodes
until kubectl get sa | grep -q 'default'; do
sleep 1;
done
# Install Splunk on minikube
kubectl apply -f ci_scripts/k8s-splunk.yml
# Wait until splunk is ready
Expand Down Expand Up @@ -189,4 +192,5 @@ jobs:
--splunkd-url https://$CI_SPLUNK_HOST:8089 \
--splunk-user admin \
--splunk-password $CI_SPLUNK_PASSWORD \
-p no:warnings -s
--nodes-count $MINIKUBE_NODE_COUNTS\
-p no:warnings -s -n auto
16 changes: 8 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
fluent-plugin-kubernetes-objects (1.1.9)
fluent-plugin-kubernetes-objects (1.1.10)
fluentd (>= 1.9.1)
http_parser.rb (= 0.5.3)
kubeclient (~> 4.6.0)
Expand All @@ -18,14 +18,14 @@ GEM
docile (1.4.0)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
ffi (1.15.4)
ffi (1.15.5)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
fluentd (1.14.2)
fluentd (1.14.4)
bundler
cool.io (>= 1.4.5, < 2.0.0)
http_parser.rb (>= 0.5.1, < 0.8.0)
http_parser.rb (>= 0.5.1, < 0.9.0)
msgpack (>= 1.3.1, < 2.0.0)
serverengine (>= 2.2.2, < 3.0.0)
sigdump (~> 0.2.2)
Expand All @@ -51,11 +51,11 @@ GEM
http (>= 3.0, < 5.0)
recursive-open-struct (~> 1.0, >= 1.0.4)
rest-client (~> 2.0)
mime-types (3.3.1)
mime-types (3.4.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2021.0901)
mime-types-data (3.2022.0105)
minitest (5.14.4)
msgpack (1.4.2)
msgpack (1.4.4)
netrc (0.11.0)
power_assert (2.0.1)
public_suffix (4.0.6)
Expand All @@ -67,7 +67,7 @@ GEM
mime-types (>= 1.16, < 4.0)
netrc (~> 0.8)
rexml (3.2.5)
serverengine (2.2.4)
serverengine (2.2.5)
sigdump (~> 0.2.2)
sigdump (0.2.4)
simplecov (0.21.2)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.9
1.1.10
8 changes: 6 additions & 2 deletions ci_scripts/deploy_connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ helm install ci-sck --set global.splunk.hec.token=$CI_SPLUNK_HEC_TOKEN \
--set splunk-kubernetes-objects.image.pullPolicy=IfNotPresent \
--set splunk-kubernetes-objects.image.tag=recent \
-f ci_scripts/sck_values.yml helm-chart/splunk-connect-for-kubernetes
#wait for deployment to finish
until kubectl get pod | grep Running | [[ $(wc -l) == 4 ]]; do

kubectl get pod
# wait for deployment to finish
# metric and logging deamon set for each node + aggr + object + splunk
PODS=$((MINIKUBE_NODE_COUNTS*2+2+1))
until kubectl get pod | grep Running | [[ $(wc -l) == $PODS ]]; do
sleep 1;
done
5 changes: 5 additions & 0 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,16 @@ COPY --from=builder /app/LICENSE /licenses/LICENSE
RUN dnf install -y jq

COPY --from=builder /app/docker/Gemfile* ./
RUN gem update date cgi
RUN rm -f /usr/share/gems/specifications/default/cgi-0.1.0.gemspec /usr/share/gems/specifications/default/date-3.0.0.gemspec
RUN yum update -y \
&& yum remove -y nodejs npm \
&& gem install bundler \
&& gem uninstall -i /usr/share/gems bundler \
&& gem unpack /tmp/*.gem --target gem \
&& bundle install \
&& bundle update i18n \
&& gem uninstall -i /usr/share/gems i18n --version 1.8.11 \
&& rpm -e --nodeps python3-pip-wheel python3-urllib3-* python3-requests-* python3-libxml2-* python3-dmidecode-* subscription-manager-* libwebp-* libwebp-devel-* glib2-* libjpeg-turbo-devel-* libjpeg-turbo-* mariadb-connector-c-config-* mariadb-connector-c-* mariadb-connector-c-devel-* rsync-* sqlite-libs-* sqlite-devel-* sqlite-* libxml2-* libxml2-devel-* libX11-* libX11-common-* libX11-devel-* libX11-xcb-* nettle-* libsolv-* file-libs-* dbus-daemon-* tar-* qt5-srpm-macros-* perl-parent-* git-* bsdtar-* openssh-clients-* json-c-* binutils-* libtiff-devel-* libtiff-* || true

RUN groupadd -r $FLUENT_USER && \
Expand Down
5 changes: 2 additions & 3 deletions docker/Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: gem
specs:
fluent-plugin-kubernetes-objects (1.1.9)
fluent-plugin-kubernetes-objects (1.1.10)
fluentd (>= 1.9.1)
http_parser.rb (= 0.5.3)
kubeclient (~> 4.6.0)
Expand Down Expand Up @@ -43,7 +43,7 @@ GEM
prometheus-client (>= 2.1.0)
fluent-plugin-record-modifier (2.1.0)
fluentd (>= 1.0, < 2)
fluent-plugin-splunk-hec (1.2.9)
fluent-plugin-splunk-hec (1.2.11)
fluentd (>= 1.4)
multi_json (~> 1.13)
net-http-persistent (~> 3.1)
Expand Down Expand Up @@ -150,7 +150,6 @@ GEM
httpclient (>= 2.4)
webrick (1.7.0)
yajl-ruby (1.4.1)
zeitwerk (2.5.1)

PLATFORMS
ruby
Expand Down
38 changes: 24 additions & 14 deletions lib/fluent/plugin/in_kubernetes_objects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,12 @@ def create_pull_thread(conf)
tag = generate_tag resource_name
while thread_current_running?
log.debug "Going to pull #{resource_name}"
response = @client.public_send "get_#{resource_name}", options
begin
response = @client.public_send "get_#{resource_name}", options
rescue Kubeclient::ResourceNotFoundError, NoMethodError
log.error "resource '#{resource_name}' not found. Stopped pulling it"
break
end
now = Fluent::Engine.now
es = Fluent::MultiEventStream.new

Expand Down Expand Up @@ -243,22 +248,27 @@ def create_watcher_thread(conf)

thread_create :"watch_#{resource_name}" do
while thread_current_running?
@client.public_send("watch_#{resource_name}", options).tap do |watcher|
tag = generate_tag "#{resource_name}"
begin
watcher.each do |entity|
begin
entity = JSON.parse(entity)
router.emit tag, Fluent::Engine.now, entity
options[:resource_version] = entity['object']['metadata']['resourceVersion']
@storage.put resource_name, entity['object']['metadata']['resourceVersion']
rescue => e
log.info "Got exception #{e} parsing entity #{entity}. Resetting watcher."
begin
@client.public_send("watch_#{resource_name}", options).tap do |watcher|
tag = generate_tag "#{resource_name}"
begin
watcher.each do |entity|
begin
entity = JSON.parse(entity)
router.emit tag, Fluent::Engine.now, entity
options[:resource_version] = entity['object']['metadata']['resourceVersion']
@storage.put resource_name, entity['object']['metadata']['resourceVersion']
rescue => e
log.info "Got exception #{e} parsing entity #{entity}. Resetting watcher."
end
end
rescue => e
log.info "Got exception #{e}. Resetting watcher."
end
rescue => e
log.info "Got exception #{e}. Resetting watcher."
end
rescue Kubeclient::ResourceNotFoundError, NoMethodError
log.error "resource '#{resource_name}' not found. Stopped watching it"
break
end
end
end
Expand Down
23 changes: 23 additions & 0 deletions test/fluent/plugin/in_kubernetes_objects_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,5 +144,28 @@
f.unlink
end
end
it "checks for invalid pull request" do
d = create_input_driver(<<~CONF)
kubernetes_url #{k8s_url}
<pull>
resource_name fakeResource
</pull>
CONF

d.run expect_emits: 0, timeout: 3

expect(d.logs.any? { |log| log.include? "resource 'fakeResource' not found." }).must_equal(true)
end
it "checks for invalid watch request" do
d = create_input_driver(<<~CONF)
kubernetes_url #{k8s_url}
<watch>
resource_name fakeResource
</watch>
CONF

d.run expect_emits: 0, timeout: 3
expect(d.logs.any? { |log| log.include? "resource 'fakeResource' not found." }).must_equal(true)
end
end
end

0 comments on commit 44e3e88

Please sign in to comment.