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:
https://prefect-community.slack.com/archives/C014Z8DPDSR/p1600439888019800?thread_ts=1600359958.136900&cid=C014Z8DPDSR

This seems to be a common problem. Should we consider adding some specific message for flows registered with the Local Environment and/or Local agents?

```This Flow was registered with the LocalExecutor and has been given the following labels: "dylans-macbook-pro", "github-storage". You'll need an agent with matching labels to connect to Prefect Cloud for it to run```
For example
Or maybe add some information about best practice regarding multiple agents on different hosts working on different runs of the same flow or something like that...
Tangentially related to #2888 I think we can start to relax the hard enforcement of default labels
I perfectly agree with @kmoonwright. Prefect shouldn't force me to use labels and these should be disabled by default (such as how GitLab Runners system is working for example).
There is already a flag (Default=True) to put the Hostname Label. `hostname_label`.
I'm foreseeing something very similar for those storage labels!

Resolving patch:
diff --git a/src/prefect/agent/local/agent.py b/src/prefect/agent/local/agent.py
--- 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 @@ def __init__(
         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 @@ def __init__(
             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
--- 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
--- 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"}):