Skip to content

Commit

Permalink
Installer fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
samisms committed Jan 30, 2018
1 parent e4a0aa7 commit 7d04f1a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
23 changes: 22 additions & 1 deletion installer/datafiles/base_container.data
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ MAINTAINER: 'Microsoft Corporation'
/var/opt/microsoft/docker-cimprov/state; 755; root; root
/var/opt/microsoft/docker-cimprov/state/ContainerInventory; 755; root; root
/var/opt/microsoft/docker-cimprov/state/ImageInventory; 755; root; root
/var/opt/microsoft/docker-cimprov/log; 755; root; root

%Dependencies

Expand All @@ -80,7 +81,8 @@ WriteInstallInfo() {
WriteInstallInfo

#Setup sudo permission for containerlogtailfilereader
if [[ -z $(cat /etc/sudoers.d/omsagent | grep /containerlogtailfilereader.rb) ]]; then
if [ -z $(cat /etc/sudoers.d/omsagent | grep /containerlogtailfilereader.rb) ]
then
chmod +w /etc/sudoers.d/omsagent
echo "#run containerlogtailfilereader.rb for docker-provider" >> /etc/sudoers.d/omsagent
echo "omsagent ALL=(ALL) NOPASSWD: /opt/microsoft/omsagent/ruby/bin/ruby /opt/microsoft/omsagent/plugin/containerlogtailfilereader.rb *" >> /etc/sudoers.d/omsagent
Expand All @@ -100,6 +102,10 @@ touch /var/opt/microsoft/docker-cimprov/state/KubeLogQueryState.yaml
chmod 644 /var/opt/microsoft/docker-cimprov/state/KubeLogQueryState.yaml
chown omsagent:omsagent /var/opt/microsoft/docker-cimprov/state/KubeLogQueryState.yaml

touch /var/opt/microsoft/docker-cimprov/log/kubernetes_client_log.txt
chmod 666 /var/opt/microsoft/docker-cimprov/log/kubernetes_client_log.txt
chown omsagent:omiusers /var/opt/microsoft/docker-cimprov/log/kubernetes_client_log.txt

mv /etc/opt/microsoft/docker-cimprov/container.conf /etc/opt/microsoft/omsagent/sysconf/omsagent.d/container.conf
chown omsagent:omsagent /etc/opt/microsoft/omsagent/sysconf/omsagent.d/container.conf

Expand All @@ -109,11 +115,26 @@ if ${{PERFORMING_UPGRADE_NOT}}; then
# Clean up installinfo.txt file (registered as "conf" file to pass rpmcheck)
rm -f /etc/opt/microsoft/docker-cimprov/conf/installinfo.txt*
rm -f /var/opt/microsoft/docker-cimprov/state/LastEventQueryTime.txt
rm -f /var/opt/microsoft/docker-cimprov/state/KubeEventQueryState.yaml
rm -f /var/opt/microsoft/docker-cimprov/state/KubeLogQueryState.yaml
rm -f /var/opt/microsoft/docker-cimprov/log/kubernetes_client_log.txt
rm -f /etc/opt/microsoft/omsagent/conf/omsagent.d/container.conf
rmdir /var/opt/microsoft/docker-cimprov/log 2> /dev/null
rmdir /var/opt/microsoft/docker-cimprov/state/ContainerInventory 2> /dev/null
rmdir /var/opt/microsoft/docker-cimprov/state/ImageInventory 2> /dev/null
rmdir /var/opt/microsoft/docker-cimprov/state 2> /dev/null
rmdir /var/opt/microsoft/docker-cimprov 2> /dev/null
rmdir /etc/opt/microsoft/docker-cimprov/conf 2> /dev/null
rmdir /etc/opt/microsoft/docker-cimprov 2> /dev/null
rmdir /etc/opt/microsoft 2> /dev/null
rmdir /etc/opt 2> /dev/null
#Remove sudoers file edit
if [ -s /etc/sudoers.d/omsagent ]
then
chmod +w /etc/sudoers.d/omsagent
sed -i '/docker\-provider/,+1 d' /etc/sudoers.d/omsagent
chmod 440 /etc/sudoers.d/omsagent
fi
fi

%Preinstall_0
Expand Down
2 changes: 1 addition & 1 deletion source/code/plugin/KubernetesApiClient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class KubernetesApiClient
@@IsValidRunningNode = nil
@@IsLinuxCluster = nil
@@KubeSystemNamespace = "kube-system"
@LogPath = "/var/opt/microsoft/omsagent/log/kubernetes_client_log.txt"
@LogPath = "/var/opt/microsoft/docker-cimprov/log/kubernetes_client_log.txt"
@Log = Logger.new(@LogPath, 'weekly')
@@TokenFileName = "/var/run/secrets/kubernetes.io/serviceaccount/token"
@@TokenStr = nil
Expand Down
6 changes: 3 additions & 3 deletions source/code/plugin/in_kube_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def enumerate(eventList = nil)
writeEventQueryState(newEventQueryState)
rescue => errorStr
$log.warn line.dump, error: errorStr.to_s
$log.debug_backtrace(e.backtrace)
$log.debug_backtrace(errorStr.backtrace)
end
else
record = {}
Expand Down Expand Up @@ -131,7 +131,7 @@ def getEventQueryState
end
rescue => errorStr
$log.warn $log.warn line.dump, error: errorStr.to_s
$log.debug_backtrace(e.backtrace)
$log.debug_backtrace(errorStr.backtrace)
end
return eventQueryState
end
Expand All @@ -141,7 +141,7 @@ def writeEventQueryState(eventQueryState)
File.write(@@KubeEventsStateFile, eventQueryState.to_yaml)
rescue => errorStr
$log.warn $log.warn line.dump, error: errorStr.to_s
$log.debug_backtrace(e.backtrace)
$log.debug_backtrace(errorStr.backtrace)
end
end

Expand Down
4 changes: 2 additions & 2 deletions source/code/plugin/in_kube_logs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,9 @@ def run_periodic
done = @finished
@mutex.unlock
if !done
$log.info "calling enumerate"
$log.debug "calling enumerate for KubeLogs"
enumerate
$log.info "done with enumerate"
$log.debug "done with enumerate for KubeLogs"
end
@mutex.lock
end
Expand Down

0 comments on commit 7d04f1a

Please sign in to comment.