devserver: Deprecate --remote_payload and --urlbase --remote_payload flag was used to run a devserver (e.g. locally) and get update payloads from another running devserver (lab). We have deprecated the --remote_payload use case from autotests per crrev.com/c/1692004 and cherry-picked it all the way back to M74 (even passed stable). Now we can deprecate it from devserver too. BUG=chromium:980362 TEST=unittests Change-Id: I040566d769c1a4baa73da770734a98282444ada9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/dev-util/+/1700392 Tested-by: Amin Hassani <ahassani@chromium.org> Reviewed-by: David Haddock <dhaddock@chromium.org> Commit-Queue: Amin Hassani <ahassani@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py index 1f259bf..9187699 100644 --- a/autoupdate.py +++ b/autoupdate.py
@@ -139,7 +139,6 @@ """Class that contains functionality that handles Chrome OS update pings. Members: - urlbase: base URL, other than devserver, for update images. forced_image: path to an image to use for all updates. payload_path: path to pre-generated payload to serve. src_image: if specified, creates a delta payload from this image. @@ -149,7 +148,6 @@ copy_to_static_root: copies images generated from the cache to ~/static. public_key: path to public key in PEM format. critical_update: whether provisioned payload is critical. - remote_payload: whether provisioned payload is remotely staged. max_updates: maximum number of updates we'll try to provision. host_log: record full history of host update events. """ @@ -165,14 +163,13 @@ METADATA_SIZE_ATTR = 'metadata_size' METADATA_HASH_ATTR = 'metadata_hash' - def __init__(self, xbuddy, urlbase=None, forced_image=None, payload_path=None, + def __init__(self, xbuddy, forced_image=None, payload_path=None, proxy_port=None, src_image='', board=None, copy_to_static_root=True, public_key=None, - critical_update=False, remote_payload=False, max_updates=-1, - host_log=False, *args, **kwargs): + critical_update=False, max_updates=-1, host_log=False, + *args, **kwargs): super(Autoupdate, self).__init__(*args, **kwargs) self.xbuddy = xbuddy - self.urlbase = urlbase or None self.forced_image = forced_image self.payload_path = payload_path self.src_image = src_image @@ -181,7 +178,6 @@ self.copy_to_static_root = copy_to_static_root self.public_key = public_key self.critical_update = critical_update - self.remote_payload = remote_payload self.max_updates = max_updates self.host_log = host_log @@ -502,44 +498,6 @@ constants.UPDATE_FILE)) return pregenerated_update - def _GetRemotePayloadAttrs(self, url): - """Returns hashes, size and delta flag of a remote update payload. - - Obtain attributes of a payload file available on a remote devserver. This - is based on the assumption that the payload URL uses the /static prefix. We - need to make sure that both clients (requests) and remote devserver - (provisioning) preserve this invariant. - - Args: - url: URL of statically staged remote file (http://host:port/static/...) - - Returns: - A UpdateMetadata object. - """ - if self._PAYLOAD_URL_PREFIX not in url: - raise AutoupdateError( - 'Payload URL does not have the expected prefix (%s)' % - self._PAYLOAD_URL_PREFIX) - - if self._OLD_PAYLOAD_URL_PREFIX in url: - fileinfo_url = url.replace(self._OLD_PAYLOAD_URL_PREFIX, - self._FILEINFO_URL_PREFIX) - else: - fileinfo_url = url.replace(self._PAYLOAD_URL_PREFIX, - self._FILEINFO_URL_PREFIX) - - _Log('Retrieving file info for remote payload via %s', fileinfo_url) - try: - conn = urllib2.urlopen(fileinfo_url) - metadata_obj = Autoupdate._ReadMetadataFromStream(conn) - # These fields are required for remote calls. - if not metadata_obj: - raise AutoupdateError('Failed to obtain remote payload info') - - return metadata_obj - except IOError as e: - raise AutoupdateError('Failed to obtain remote payload info: %s', e) - @staticmethod def _GetMetadataHash(payload_dir): """Gets the metadata hash, if it exists. @@ -705,11 +663,7 @@ """Returns the static url base that should prefix all payload responses.""" hostname = self.GetDevserverUrl() - if self.urlbase: - static_urlbase = self.urlbase - else: - static_urlbase = '%s/static' % hostname - + static_urlbase = '%s/static' % hostname # If we have a proxy port, adjust the URL we instruct the client to # use to go through the proxy. if self.proxy_port: @@ -874,30 +828,12 @@ metadata_obj = None try: - # Are we provisioning a remote or local payload? - if self.remote_payload: - - self._CheckOmahaRequest(app) - - # If no explicit label was provided, use the value of --payload. - if not label: - label = self.payload_path - - # TODO(sosa): Remove backwards-compatible hack. - if not '.bin' in label: - url = _NonePathJoin(static_urlbase, label, 'update.gz') - else: - url = _NonePathJoin(static_urlbase, label) - - # Get remote payload attributes. - metadata_obj = self._GetRemotePayloadAttrs(url) - else: - path_to_payload = self.GetPathToPayload( - label, request_attrs.client_version, request_attrs.board) - url = _NonePathJoin(static_urlbase, path_to_payload, - constants.UPDATE_FILE) - local_payload_dir = _NonePathJoin(self.static_dir, path_to_payload) - metadata_obj = self.GetLocalPayloadAttrs(local_payload_dir) + path_to_payload = self.GetPathToPayload( + label, request_attrs.client_version, request_attrs.board) + url = _NonePathJoin(static_urlbase, path_to_payload, + constants.UPDATE_FILE) + local_payload_dir = _NonePathJoin(self.static_dir, path_to_payload) + metadata_obj = self.GetLocalPayloadAttrs(local_payload_dir) except AutoupdateError as e: # Raised if we fail to generate an update payload. _Log('Failed to process an update: %r', e)
diff --git a/autoupdate_unittest.py b/autoupdate_unittest.py index 98efbb3..833a174 100755 --- a/autoupdate_unittest.py +++ b/autoupdate_unittest.py
@@ -52,7 +52,6 @@ self.mox.StubOutWithMock(common_util, 'GetFileSha256') self.mox.StubOutWithMock(common_util, 'IsInsideChroot') self.mox.StubOutWithMock(autoupdate_lib, 'GetUpdateResponse') - self.mox.StubOutWithMock(autoupdate.Autoupdate, '_GetRemotePayloadAttrs') self.port = 8080 self.test_board = 'test-board' self.build_root = tempfile.mkdtemp('autoupdate_build_root') @@ -309,32 +308,5 @@ self.assertFalse( au._CanUpdate('1098.0.2011_09_28_1635', '1096.0.2011_09_30_0000')) - def testHandleUpdatePingRemotePayload(self): - remote_urlbase = 'http://remotehost:6666' - remote_payload_path = 'static/path/to/update.gz' - remote_url = '/'.join([remote_urlbase, remote_payload_path, 'update.gz']) - au_mock = self._DummyAutoupdateConstructor(urlbase=remote_urlbase, - payload_path=remote_payload_path, - remote_payload=True) - - incomplete_test_data = _TEST_REQUEST % self.test_dict - complete_test_data = _FULL_TEST_REQUEST % self.test_dict - - au_mock._GetRemotePayloadAttrs(remote_url).AndReturn( - autoupdate.UpdateMetadata(self.sha1, self.sha256, self.size, False, - 0, '')) - autoupdate_lib.GetUpdateResponse( - self.sha1, self.sha256, self.size, remote_url, False, 0, None, None, - u'3.0', '', False).AndReturn(self.payload) - - self.mox.ReplayAll() - # This should fail because of missing fields. - self.assertRaises(common_util.DevServerHTTPError, - au_mock.HandleUpdatePing, incomplete_test_data) - # This should have enough information. - self.assertEqual(au_mock.HandleUpdatePing(complete_test_data), self.payload) - self.mox.VerifyAll() - - if __name__ == '__main__': unittest.main()
diff --git a/devserver.py b/devserver.py index 6d4d7fb..130ce10 100755 --- a/devserver.py +++ b/devserver.py
@@ -1767,17 +1767,6 @@ 'from a different port that will proxy the request back to ' 'the devserver. The proxy must be managed outside the ' 'devserver.') - group.add_option('--remote_payload', - action='store_true', default=False, - help='Payload is being served from a remote machine. With ' - 'this setting enabled, this devserver instance serves as ' - 'just an Omaha server instance. In this mode, the ' - 'devserver enforces a few extra components of the Omaha ' - 'protocol, such as hardware class, being sent.') - group.add_option('-u', '--urlbase', - metavar='URL', - help='base URL for update images, other than the ' - 'devserver. Use in conjunction with remote_payload.') parser.add_option_group(group) @@ -1933,7 +1922,6 @@ updater = autoupdate.Autoupdate( _xbuddy, static_dir=options.static_dir, - urlbase=options.urlbase, forced_image=options.image, payload_path=options.payload, proxy_port=options.proxy_port, @@ -1942,7 +1930,6 @@ copy_to_static_root=not options.exit, public_key=options.public_key, critical_update=options.critical_update, - remote_payload=options.remote_payload, max_updates=options.max_updates, host_log=options.host_log, )