File tree Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Expand file tree Collapse file tree 1 file changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -84,6 +84,25 @@ function FetchAndImport-ModuleFromMetadata {
84
84
Import-Module - Force C:\$Filename
85
85
}
86
86
87
+ # Returns true if the ENABLE_STACKDRIVER_WINDOWS or ENABLE_NODE_LOGGING field in kube_env is true.
88
+ # $KubeEnv is a hash table containing the kube-env metadata keys+values.
89
+ # ENABLE_NODE_LOGGING is used for legacy Stackdriver Logging, and will be deprecated (always set to False)
90
+ # soon. ENABLE_STACKDRIVER_WINDOWS is added to indicate whether logging is enabled for windows nodes.
91
+ function IsLoggingEnabled {
92
+ param (
93
+ [parameter (Mandatory = $true )] [hashtable ]$KubeEnv
94
+ )
95
+
96
+ if ($KubeEnv.Contains (' ENABLE_STACKDRIVER_WINDOWS' ) -and `
97
+ ($KubeEnv [' ENABLE_STACKDRIVER_WINDOWS' ] -eq ' true' )) {
98
+ return $true
99
+ } elseif ($KubeEnv.Contains (' ENABLE_NODE_LOGGING' ) -and `
100
+ ($KubeEnv [' ENABLE_NODE_LOGGING' ] -eq ' true' )) {
101
+ return $true
102
+ }
103
+ return $false
104
+ }
105
+
87
106
try {
88
107
# Don't use FetchAndImport-ModuleFromMetadata for common.psm1 - the common
89
108
# module includes variables and functions that any other function may depend
@@ -112,9 +131,12 @@ try {
112
131
Create- Directories
113
132
Download- HelperScripts
114
133
115
- Install-LoggingAgent
116
- Configure- LoggingAgent
117
- Restart-LoggingAgent
134
+ # Even if Stackdriver is already installed, the function will still [re]start the service.
135
+ if (IsLoggingEnabled $kube_env ) {
136
+ Install-LoggingAgent
137
+ Configure- LoggingAgent
138
+ Restart-LoggingAgent
139
+ }
118
140
119
141
Create- DockerRegistryKey
120
142
Configure- Dockerd
You can’t perform that action at this time.
0 commit comments