@@ -82,7 +82,7 @@ func (d *DockerConnector) Start(ctx context.Context, id string, name string) {
8282 d .mu .Unlock ()
8383
8484 privateKey := fmt .Sprintf ("%s/%s.key" , d .privateKeys , id )
85- go initContainerAgent (ctx , Container {
85+ go initContainerAgent (ctx , d . cli , Container {
8686 ID : id ,
8787 Name : name ,
8888 ServerAddress : d .server ,
@@ -155,7 +155,7 @@ func (d *DockerConnector) Listen(ctx context.Context) error {
155155}
156156
157157// initContainerAgent initializes the agent for a container.
158- func initContainerAgent (ctx context.Context , container Container ) {
158+ func initContainerAgent (ctx context.Context , cli * dockerclient. Client , container Container ) {
159159 agent .AgentPlatform = "connector"
160160 agent .AgentVersion = ConnectorVersion
161161
@@ -178,7 +178,20 @@ func initContainerAgent(ctx context.Context, container Container) {
178178 "version" : agent .AgentVersion ,
179179 }).Info ("Connector container started" )
180180
181- ag , err := agent .NewAgentWithConfig (cfg , agent .NewConnectorMode (cfg .PreferredIdentity ))
181+ mode , err := agent .NewConnectorMode (cli , container .ID )
182+ if err != nil {
183+ log .WithError (err ).WithFields (log.Fields {
184+ "id" : container .ID ,
185+ "identity" : cfg .PreferredIdentity ,
186+ "hostname" : cfg .PreferredHostname ,
187+ "tenant_id" : cfg .TenantID ,
188+ "server_address" : cfg .ServerAddress ,
189+ "timestamp" : time .Now (),
190+ "version" : agent .AgentVersion ,
191+ }).Fatal ("Failed to create connector mode" )
192+ }
193+
194+ ag , err := agent .NewAgentWithConfig (cfg , mode )
182195 if err != nil {
183196 log .WithError (err ).WithFields (log.Fields {
184197 "id" : container .ID ,
0 commit comments