Azure / iotedge

The IoT Edge OSS project
MIT License
1.46k stars 459 forks source link

EdgeAgent does not report environment vars (Proxy Settings, create options) back to IoT hub on first connect #5421

Open derSchtefan opened 3 years ago

derSchtefan commented 3 years ago

Background

In an environment with a proxy required to gain outside access, the config.yaml (IoT 1.1) is modified by the person installing the edge device so that the initial edgeAgent docker module creation sets the environment variables https_proxy and UpstreamProtocol: AmqpWs.

This allows the edgeAgent to connect to IoT Hub initially, and report a 417 - Configuration not set. Any subsequent deployment will need to specify these settings from the cloud side again, making it required to also store the device's proxy settings there.

Expected Behavior

After the initial connection, we expect that the edge agent reports the http_proxy / https_proxy variables that have been set to him in the "reported properties". This way the settings can be retained or honoured when deploying a solution.

Current Behavior

The edge agent logs that it detected the proxy setting, uses the proxy, but does not report those environment variables to the cloud. Any deployment performed subsequently without those exact proxy settings will brick the device, because the edge agent will be overwritten with missing/wrong proxy settings.

Steps to Reproduce

Provide a detailed set of steps to reproduce the bug.

  1. Setup an edge device in a network configuration that requires a proxy
  2. Setup the proxy like specified here https://docs.microsoft.com/en-us/azure/iot-edge/how-to-configure-proxy-support?view=iotedge-2018-06&preserve-view=true
  3. Let the edge Agent connect to IoT hub
  4. Observe that the edge agent logs the proxy to the log file, but does not report the environment variable as being set

Context (Environment)

Device Information

Runtime Versions

ZacMelendez commented 3 years ago

I have the same error, running IoTEdge 1.0.9, edgeAgent 1.0 & edgeHub 1.0.

edgeAgent does not report any proxy values (https or http), but edgeHub does report them in the IoT Hub.

micahl commented 3 years ago

@derSchtefan thank you for the feedback. Restating your expectation to confirm my understanding... proxy settings specified in the config file should always apply to the running edgeAgent. I.e. setting the proxy environment variables in every subsequent deployment manifest shouldn't be necessary. And, those persistent proxy settings should be reported in the portal. Is that correct?

derSchtefan commented 3 years ago

Yes, that would be perfect. But already simply reporting the value back to the iot hub at the initial startup (when the system enters a 417 - deployment not set) would be an advantage.

Of course, in general, the person installing the edge device will have had to set the proxy in the config files anyway, and unless it is overridden from the cloud, this should always be the proxy used.

Currently it is easy to brick an edge device by deploying an iot solution that has not had the edgeagent properties correctly individualized. The edge agent will lose connection, and will never be able to get the correct manifest.