@@ -15,17 +15,19 @@ import (
15
15
"path"
16
16
"sync"
17
17
"syscall"
18
+ "time"
18
19
19
20
"github.com/aws/aws-sdk-go/aws"
20
21
"github.com/aws/aws-sdk-go/aws/endpoints"
21
22
"github.com/aws/aws-sdk-go/aws/session"
22
23
"github.com/hashicorp/go-hclog"
24
+ "github.com/hashicorp/vault/api"
25
+
23
26
"github.com/hashicorp/vault-lambda-extension/internal/config"
24
27
"github.com/hashicorp/vault-lambda-extension/internal/extension"
25
28
"github.com/hashicorp/vault-lambda-extension/internal/proxy"
26
29
"github.com/hashicorp/vault-lambda-extension/internal/runmode"
27
30
"github.com/hashicorp/vault-lambda-extension/internal/vault"
28
- "github.com/hashicorp/vault/api"
29
31
)
30
32
31
33
func main () {
@@ -107,6 +109,7 @@ func (h *handler) handle() error {
107
109
}
108
110
109
111
func (h * handler ) runExtension (ctx context.Context , wg * sync.WaitGroup ) (func (context.Context ) error , error ) {
112
+ start := time .Now ()
110
113
h .logger .Info ("Initialising" )
111
114
112
115
authConfig := config .AuthConfigFromEnv ()
@@ -154,7 +157,7 @@ func (h *handler) runExtension(ctx context.Context, wg *sync.WaitGroup) (func(co
154
157
client .VaultClient = client .VaultClient .WithRequestCallbacks (api .RequireState (newState ), vault .UserAgentRequestCallback (uaFunc )).WithResponseCallbacks ()
155
158
156
159
if h .runMode .HasModeFile () {
157
- if err := writePreconfiguredSecrets (client .VaultClient ); err != nil {
160
+ if err := writePreconfiguredSecrets (h . logger , client .VaultClient ); err != nil {
158
161
return nil , err
159
162
}
160
163
}
@@ -164,6 +167,8 @@ func (h *handler) runExtension(ctx context.Context, wg *sync.WaitGroup) (func(co
164
167
165
168
cleanupFunc := func (context.Context ) error { return nil }
166
169
if h .runMode .HasModeProxy () {
170
+ start := time .Now ()
171
+ h .logger .Debug ("initialising proxy mode" )
167
172
ln , err := net .Listen ("tcp" , "127.0.0.1:8200" )
168
173
if err != nil {
169
174
return nil , fmt .Errorf ("failed to listen on port 8200: %w" , err )
@@ -181,14 +186,17 @@ func (h *handler) runExtension(ctx context.Context, wg *sync.WaitGroup) (func(co
181
186
cleanupFunc = func (ctx context.Context ) error {
182
187
return srv .Shutdown (ctx )
183
188
}
189
+ h .logger .Debug (fmt .Sprintf ("proxy mode initialised in %v" , time .Since (start )))
184
190
}
185
191
186
- h .logger .Info ("Initialised" )
192
+ h .logger .Info (fmt . Sprintf ( "Initialised in %v" , time . Since ( start )) )
187
193
return cleanupFunc , nil
188
194
}
189
195
190
196
// writePreconfiguredSecrets writes secrets to disk.
191
- func writePreconfiguredSecrets (client * api.Client ) error {
197
+ func writePreconfiguredSecrets (logger hclog.Logger , client * api.Client ) error {
198
+ start := time .Now ()
199
+ logger .Debug ("writing secrets to disk" )
192
200
configuredSecrets , err := config .ParseConfiguredSecrets ()
193
201
if err != nil {
194
202
return fmt .Errorf ("failed to parse configured secrets to read: %w" , err )
@@ -218,6 +226,7 @@ func writePreconfiguredSecrets(client *api.Client) error {
218
226
}
219
227
}
220
228
229
+ logger .Debug (fmt .Sprintf ("wrote secrets to disk in %v" , time .Since (start )))
221
230
return nil
222
231
}
223
232
0 commit comments