Bug #23311
openCheck error when updating container gateway_address in crunch-run
Description
This code in source:lib/crunchrun/crunchrun.go ensures the container's container_gateway field gets updated when crunch-run (re)connects its tunnel connection to controller.
cr.gateway.ArvadosClient = cr.dispatcherClient
cr.gateway.UpdateTunnelURL = func(url string) {
cr.gateway.Address = "tunnel " + url
cr.DispatcherArvClient.Update("containers", containerUUID,
arvadosclient.Dict{
"select": []string{"uuid"},
"container": arvadosclient.Dict{"gateway_address": cr.gateway.Address},
}, nil)
}
The unstated reason for not checking the error is that the error is harmless if the container state is not "Running". In the "Locked" case, the container will get updated to the correct value when state changes to "Running". In the "Complete" or "Cancelled" case, gateway_address can't actually be used for anything any more anyway so it's OK if it doesn't get updated.
(1) If container state is Complete or Cancelled, we should not do the update at all.
(2) If container state is Locked, we should wait a bit, check for a race between UpdateTunnelURL and UpdateContainerRunning, and retry if needed.
(3) If we try the update and it fails, we should log something for troubleshooting purposes, and retry.