@@ -18,6 +18,11 @@ import (
1818 "k8s.io/client-go/informers"
1919 "k8s.io/client-go/kubernetes"
2020 "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"
2126)
2227
2328type podEventLoggerOptions struct {
@@ -137,18 +142,17 @@ func (p *podEventLogger) init() error {
137142 p .mutex .Lock ()
138143 defer p .mutex .Unlock ()
139144 tokens , ok := p .podToAgentTokens [pod .Name ]
145+ if ! ok {
146+ return
147+ }
140148 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+ })
150155 }
151-
152156 p .logger .Info (p .ctx , "unregistered agent pod" , slog .F ("pod" , pod .Name ))
153157 },
154158 })
0 commit comments