Repository: PrefectHQ/prefect

Issue:
Start a Local Agent without Default Storage Labels
## Current behavior
<!-- Please describe how the feature works today -->
Starting a LocalAgent will add storage labels by default, which can be confusing for new users and cluttered for users with many agents. Typically, starting a LocalAgent will produce the following by default:

`[2020-09-01 15:34:50,612] INFO - agent | Starting LocalAgent with labels ['my-machine.local', 'azure-flow-storage', 'gcs-flow-storage', 's3-flow-storage', 'github-flow-storage', 'webhook-flow-storage']`


## Proposed behavior
<!-- Please describe your proposed change to the current behavior -->
Starting a Local Agent should automatically exclude the following labels: 
'azure-flow-storage', 'gcs-flow-storage', 's3-flow-storage', 'github-flow-storage', 'webhook-flow-storage'

These labels should have some option to turn off by default or be removed by default.

Implemented here: https://github.com/PrefectHQ/prefect/blob/5edb9b39bb53e2cb11d37832f3f3f56bb1a3bc6a/src/prefect/agent/local/agent.py#L97


## Example
<!-- Please give an example of how the enhancement would be useful -->
prefect agent start -t "TOKEN"
Produces:
```
[2020-09-01 17:56:00,216] INFO - agent | Starting LocalAgent with labels ['my-machine.local', 'azure-flow-storage', 'gcs-flow-storage', 's3-flow-storage', 'github-flow-storage', 'webhook-flow-storage']
[2020-09-01 17:56:00,216] INFO - agent | Agent documentation can be found at https://docs.prefect.io/orchestration/
[2020-09-01 17:56:00,216] INFO - agent | Agent connecting to the Prefect API at https://api.prefect.io
[2020-09-01 17:56:00,532] INFO - agent | Waiting for flow runs...
```
But can clutter the UI:
![0](https://user-images.githubusercontent.com/49457507/91889450-b1034680-ec42-11ea-9691-ad0288216016.png)

Potential Results:
Agent management will be decluttered for users with many Agents.
Quality of life change - specifying execution environments via flow affinity is a bit easier to navigate.


Please let me know if there is a current solution or reasoning I'm not aware of!

Discussion:

Patch:
diff --git a/changes/pr3503.yaml b/changes/pr3503.yaml
new file mode 100644
index 0000000000..bde1406631
--- /dev/null
+++ b/changes/pr3503.yaml
@@ -0,0 +1,5 @@
+enhancement:
+  - "Allow disabling default storage labels for the `LocalAgent` - [#3503](https://github.com/PrefectHQ/prefect/pull/3503)"
+
+contributor:
+  - "[Raphael Riel](https://github.com/raphael-riel)"
diff --git a/src/prefect/agent/local/agent.py b/src/prefect/agent/local/agent.py
index a1070b99c5..222fa55ce7 100644
--- a/src/prefect/agent/local/agent.py
+++ b/src/prefect/agent/local/agent.py
@@ -55,6 +55,8 @@ class LocalAgent(Agent):
         - hostname_label (boolean, optional): a boolean specifying whether this agent should
             auto-label itself with the hostname of the machine it is running on.  Useful for
             flows which are stored on the local filesystem.
+        - storage_labels (boolean, optional): a boolean specifying whether this agent should
+            auto-label itself with all of the storage options labels.
     """
 
     def __init__(
@@ -69,6 +71,7 @@ class LocalAgent(Agent):
         max_polls: int = None,
         agent_address: str = None,
         no_cloud_logs: bool = False,
+        storage_labels: bool = True,
     ) -> None:
         self.processes = set()
         self.import_paths = import_paths or []
@@ -92,17 +95,18 @@ class LocalAgent(Agent):
             assert isinstance(self.labels, list)
             self.labels.append(hostname)
 
-        all_storage_labels = [
-            "azure-flow-storage",
-            "gcs-flow-storage",
-            "s3-flow-storage",
-            "github-flow-storage",
-            "webhook-flow-storage",
-            "gitlab-flow-storage",
-        ]
-        for label in all_storage_labels:
-            if label not in self.labels:
-                self.labels.append(label)
+        if storage_labels:
+            all_storage_labels = [
+                "azure-flow-storage",
+                "gcs-flow-storage",
+                "s3-flow-storage",
+                "github-flow-storage",
+                "webhook-flow-storage",
+                "gitlab-flow-storage",
+            ]
+            for label in all_storage_labels:
+                if label not in self.labels:
+                    self.labels.append(label)
 
         self.logger.debug(f"Import paths: {self.import_paths}")
         self.logger.debug(f"Show flow logs: {self.show_flow_logs}")
diff --git a/src/prefect/cli/agent.py b/src/prefect/cli/agent.py
index 6150c7ea62..bd1427410d 100644
--- a/src/prefect/cli/agent.py
+++ b/src/prefect/cli/agent.py
@@ -69,6 +69,18 @@ def agent():
     help="Labels the agent will use to query for flow runs.",
     hidden=True,
 )
+@click.option(
+    "--storage-labels/--no-storage-labels",
+    default=True,
+    help="Add all storage labels to the LocalAgent",
+    hidden=True,
+)
+@click.option(
+    "--hostname-label/--no-hostname-label",
+    default=True,
+    help="Add hostname to the LocalAgent's labels",
+    hidden=True,
+)
 @click.option(
     "--env",
     "-e",
@@ -165,6 +177,8 @@ def start(
     no_docker_interface,
     max_polls,
     agent_address,
+    storage_labels,
+    hostname_label,
 ):
     """
     Start an agent.
@@ -208,6 +222,10 @@ def start(
                                         e.g. `-p /root/my_scripts -p /utilities`
         --show-flow-logs, -f        Display logging output from flows run by the agent
                                     (available for Local and Docker agents only)
+        --hostname-label            Add hostname to the Agent's labels
+                                        (Default to True. Disable with --no-hostname-label option)
+        --storage-labels            Add all storage labels to the Agent
+                                        (Default to True. Disable with --no-storage-labels option)
 
     \b
     Docker Agent:
@@ -273,6 +291,8 @@ def start(
                 import_paths=list(import_path),
                 show_flow_logs=show_flow_logs,
                 no_cloud_logs=no_cloud_logs,
+                hostname_label=hostname_label,
+                storage_labels=storage_labels,
             ).start()
         elif agent_option == "docker":
             from_qualified_name(retrieved_agent)(


Test patch:
diff --git a/tests/agent/test_local_agent.py b/tests/agent/test_local_agent.py
index 3ed2c7db09..3c8fba344a 100644
--- a/tests/agent/test_local_agent.py
+++ b/tests/agent/test_local_agent.py
@@ -70,6 +70,20 @@ def test_local_agent_config_options(cloud_api):
         }
 
 
+def test_local_agent_config_no_storage_labels(cloud_api):
+    with set_temporary_config(
+        {"cloud.agent.auth_token": "TEST_TOKEN", "logging.log_to_cloud": True}
+    ):
+        agent = LocalAgent(
+            labels=["test_label"],
+            storage_labels=False,
+        )
+        assert set(agent.labels) == {
+            socket.gethostname(),
+            "test_label",
+        }
+
+
 @pytest.mark.parametrize("flag", [True, False])
 def test_local_agent_responds_to_logging_config(cloud_api, flag):
     with set_temporary_config({"cloud.agent.auth_token": "TEST_TOKEN"}):