hmrc / service-manager

A python tool to manage developing and testing with lots of microservices
Apache License 2.0
58 stars 37 forks source link

No url in output when it errors with 404. No "verbose" flag to see more detailed output #79

Closed codesurf42 closed 6 years ago

codesurf42 commented 6 years ago

When SM breaks while trying to download dependency, it does not output the URL used for downloading. It makes impossible to track what was it trying to download and debug issues quicker. There is also no flag to increase verbosity.

A general rule for such download tools is to print full URLs of processed packages (compare maven, sbt, apt)

Example how it is failing:

Starting 'NRS_RETRIEVAL_STUBS' from SNAPSHOT...
Traceback (most recent call last):
  File "/home/ab/.local/bin/sm", line 178, in <module>
    _process_command()
[... trace ....]
urllib2.HTTPError: HTTP Error 404: Not Found

Example how it can be fixed (I am not sure about the logging strategy there):

index 033e842..65b6099 100644
--- a/servicemanager/smbintray.py
+++ b/servicemanager/smbintray.py
@@ -33,6 +33,7 @@ class SmBintray():

     def _get_version_info_from_bintray(self, artifact, repositoryId, groupId):
         url = self.context.config_value("bintray")["protocol"] + "://" + self.context.config_value("bintray")["host"] + "/" + repositoryId + "/" + groupId + artifact + "/maven-metadata.xml"
+        print "Trying request: " + url
         request = urllib2.Request(url)
         response = urllib2.urlopen(request)
         dom = parse(response)
codesurf42 commented 6 years ago

Additional info could be produced in case of this error:

Perhaps your sm service config in services.json should have missing repository dependency
`      "nexus": "/content/repositories/"  `
included?
jakobgrunig commented 6 years ago

I added a new verbose mode (thanks for the suggestion). With the move to artifactory, this is how the output looks like now:

Starting 'NRS_RETRIEVAL_STUBS' from RELEASE...
Downloading metadata from Artifactory at https://somehost/some-repo/uk/gov/hmrc/nrs-retrieval-stubs_2.11/maven-metadata.xml
Attempt number 1 failed. Reason: HTTP Error 404: Not Found
Attempt number 2 failed. Reason: HTTP Error 404: Not Found
Attempt number 3 failed. Reason: HTTP Error 404: Not Found
Attempt number 4 failed. Reason: HTTP Error 404: Not Found
Attempt number 5 failed. Reason: HTTP Error 404: Not Found
Aborting download after 5 attempts

This is available with servicemanager version 1.4.0. Please remember to update your config.