@@ -18,6 +18,11 @@ import (
18
18
"k8s.io/client-go/informers"
19
19
"k8s.io/client-go/kubernetes"
20
20
"k8s.io/client-go/tools/cache"
21
+
22
+ // *Never* remove this. Certificates are not bundled as part
23
+ // of the container, so this is necessary for all connections
24
+ // to not be insecure.
25
+ _ "github.com/breml/rootcerts"
21
26
)
22
27
23
28
type podEventLoggerOptions struct {
@@ -137,18 +142,17 @@ func (p *podEventLogger) init() error {
137
142
p .mutex .Lock ()
138
143
defer p .mutex .Unlock ()
139
144
tokens , ok := p .podToAgentTokens [pod .Name ]
145
+ if ! ok {
146
+ return
147
+ }
140
148
delete (p .podToAgentTokens , pod .Name )
141
- if ok {
142
- for _ , token := range tokens {
143
- p .sendLog (pod .Name , token , agentsdk.StartupLog {
144
- CreatedAt : time .Now (),
145
- Output : fmt .Sprintf ("🗑️ %s: %s" , newColor (color .Bold ).Sprint ("Deleted pod" ), pod .Name ),
146
- Level : codersdk .LogLevelError ,
147
- })
148
- }
149
-
149
+ for _ , token := range tokens {
150
+ p .sendLog (pod .Name , token , agentsdk.StartupLog {
151
+ CreatedAt : time .Now (),
152
+ Output : fmt .Sprintf ("🗑️ %s: %s" , newColor (color .Bold ).Sprint ("Deleted pod" ), pod .Name ),
153
+ Level : codersdk .LogLevelError ,
154
+ })
150
155
}
151
-
152
156
p .logger .Info (p .ctx , "unregistered agent pod" , slog .F ("pod" , pod .Name ))
153
157
},
154
158
})
0 commit comments