Repository: DataBiosphere/toil

Issue:
TOIL_OWNER_TAG is being ignored
I ran this:

```
. venv/bin/activate
git checkout 442db8ed60b287eddfccb20c465daed86dd215f5
pip install -e .[all]
TOIL_OWNER_TAG=shared TOIL_APPLIANCE_SELF=quay.io/ucsc_cgl/toil:5.7.0a1-442db8ed60b287eddfccb20c465daed86dd215f5-py3.9 'toil' 'launch-cluster' '-p=aws' '-z' 'us-west-2a' '--keyPairName=anovak@courtyard' '--leaderNodeType=t2.medium' '--logDebug' 'provisioner-test-9ea301d3-e2a4-41c9-abcf-764b8808f59e' '--leaderStorage' '80'
```

But I got an instance created where the Owner tag was `id_rsa` and not `shared` as expected. This I think is causing failures in CI like https://ucsc-ci.com/databiosphere/toil/-/jobs/7702 where the instances that the tests make are being killed for not having appropriate tags. Not every test has this happen because not every test gets its instances caught in time by the deletion policy.

┆Issue is synchronized with this [Jira Task](https://ucsc-cgl.atlassian.net/browse/TOIL-1135)
┆friendlyId: TOIL-1135



Discussion:

Resolving patch:
diff --git a/src/toil/provisioners/aws/awsProvisioner.py b/src/toil/provisioners/aws/awsProvisioner.py
--- a/src/toil/provisioners/aws/awsProvisioner.py
+++ b/src/toil/provisioners/aws/awsProvisioner.py
@@ -340,6 +340,7 @@ def launchCluster(self,
         # Make tags for the leader specifically
         leader_tags = dict(self._tags)
         leader_tags[_TAG_KEY_TOIL_NODE_TYPE] = 'leader'
+        logger.debug('Launching leader with tags: %s', leader_tags)
 
         instances = create_instances(self.aws.resource(self._region, 'ec2'),
                                      image_id=self._discoverAMI(),
@@ -359,6 +360,7 @@ def launchCluster(self,
         leader.wait_until_exists()
 
         # Don't go on until the leader is started
+        logger.info('Waiting for leader instance %s to be running', leader)
         leader.wait_until_running()
 
         # Now reload it to make sure all the IPs are set.
diff --git a/src/toil/server/wes/toil_backend.py b/src/toil/server/wes/toil_backend.py
--- a/src/toil/server/wes/toil_backend.py
+++ b/src/toil/server/wes/toil_backend.py
@@ -196,7 +196,7 @@ def get_service_info(self) -> Dict[str, Any]:
             },
             "supported_wes_versions": ["1.0.0"],
             "supported_filesystem_protocols": ["file", "http", "https"],
-            "workflow_engine_versions": {"toil": [baseVersion, ]},
+            "workflow_engine_versions": {"toil": baseVersion},
             "default_workflow_engine_parameters": [
                 {
                     "name": key,
diff --git a/src/toil/utils/toilLaunchCluster.py b/src/toil/utils/toilLaunchCluster.py
--- a/src/toil/utils/toilLaunchCluster.py
+++ b/src/toil/utils/toilLaunchCluster.py
@@ -44,7 +44,7 @@ def main() -> None:
                         " On Google/GCE, this is the ssh key pair.")
     parser.add_argument("--owner", dest='owner',
                         help="The owner tag for all instances. If not given, the value in"
-                        " --keyPairName will be used if given.")
+                        "TOIL_OWNER_TAG will be used, or else the value of --keyPairName.")
     parser.add_argument("--boto", dest='botoPath',
                         help="The path to the boto credentials directory. This is transferred "
                         "to all nodes in order to access the AWS jobStore from non-AWS instances.")
@@ -140,7 +140,7 @@ def main() -> None:
                     # Provision fixed nodes
                     nodeCounts.append(int(spec))
 
-    owner = options.owner or options.keyPairName or 'toil'
+    owner = options.owner or os.getenv('TOIL_OWNER_TAG') or options.keyPairName or 'toil'
 
     # Check to see if the user specified a zone. If not, see if one is stored in an environment variable.
     options.zone = options.zone or os.environ.get(f'TOIL_{options.provisioner.upper()}_ZONE')


Test patch:
diff --git a/src/toil/test/server/serverTest.py b/src/toil/test/server/serverTest.py
--- a/src/toil/test/server/serverTest.py
+++ b/src/toil/test/server/serverTest.py
@@ -80,6 +80,9 @@ def test_get_service_info(self) -> None:
         self.assertIn("supported_wes_versions", service_info)
         self.assertIn("supported_filesystem_protocols", service_info)
         self.assertIn("workflow_engine_versions", service_info)
+        engine_versions = service_info["workflow_engine_versions"]
+        self.assertIn("toil", engine_versions)
+        self.assertEqual(type(engine_versions["toil"]), str)
         self.assertIn("default_workflow_engine_parameters", service_info)
         self.assertIn("system_state_counts", service_info)
         self.assertIn("tags", service_info)
diff --git a/src/toil/test/utils/utilsTest.py b/src/toil/test/utils/utilsTest.py
--- a/src/toil/test/utils/utilsTest.py
+++ b/src/toil/test/utils/utilsTest.py
@@ -139,6 +139,7 @@ def testAWSProvisionerUtils(self):
         # TODO: Run these for the other clouds.
         clusterName = f'cluster-utils-test{uuid.uuid4()}'
         keyName = os.getenv('TOIL_AWS_KEYNAME').strip() or 'id_rsa'
+        expected_owner = os.getenv('TOIL_OWNER_TAG') or keyName
 
         try:
             from toil.provisioners.aws.awsProvisioner import AWSProvisioner
@@ -155,7 +156,7 @@ def testAWSProvisionerUtils(self):
             leader = cluster.getLeader()
 
             # check that the leader carries the appropriate tags
-            tags = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3', 'Name': clusterName, 'Owner': keyName}
+            tags = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3', 'Name': clusterName, 'Owner': expected_owner}
             for key in tags:
                 self.assertEqual(leader.tags.get(key), tags[key])
         finally: