def _retried_install_impl(package_name, service_name, expected_running_tasks, options={}, package_version=None, timeout_seconds=TIMEOUT_SECONDS): '''Cleaned up version of shakedown's package_install().''' package_manager = dcos.packagemanager.PackageManager( dcos.cosmos.get_cosmos_url()) pkg = package_manager.get_package_version(package_name, package_version) if package_version is None: # Get the resolved version for logging below package_version = 'auto:{}'.format(pkg.version()) log.info( 'Installing package={} service={} with options={} version={}'.format( package_name, service_name, options, package_version)) # Trigger package install, but only if it's not already installed. # We expect upstream to have confirmed that it wasn't already installed beforehand. if sdk_marathon.app_exists(service_name): log.info( 'Marathon app={} exists, skipping package install call'.format( service_name)) else: package_manager.install_app(pkg, options) # Install CLI while package starts to install if pkg.cli_definition(): log.info('Installing CLI for package={}'.format(package_name)) dcos.subcommand.install(pkg) # Wait for expected tasks to come up if expected_running_tasks > 0: shakedown.wait_for_service_tasks_running(service_name, expected_running_tasks, timeout_seconds) # Wait for completed marathon deployment app_id = pkg.marathon_json(options).get('id') # TODO: initial wait time here? jenkins install is usually 90-120s # TODO: randomize the sleep_seconds shakedown.time_wait(lambda: shakedown.deployment_predicate(app_id), timeout_seconds, sleep_seconds=20)
def _retried_install_impl( package_name, service_name, expected_running_tasks, options={}, package_version=None, timeout_seconds=TIMEOUT_SECONDS): '''Cleaned up version of shakedown's package_install().''' package_manager = dcos.packagemanager.PackageManager(dcos.cosmos.get_cosmos_url()) pkg = package_manager.get_package_version(package_name, package_version) if package_version is None: # Get the resolved version for logging below package_version = 'auto:{}'.format(pkg.version()) log.info('Installing package={} service={} with options={} version={}'.format( package_name, service_name, options, package_version)) # Trigger package install, but only if it's not already installed. # We expect upstream to have confirmed that it wasn't already installed beforehand. if sdk_marathon.app_exists(service_name): log.info('Marathon app={} exists, skipping package install call'.format(service_name)) else: package_manager.install_app(pkg, options) # Install CLI while package starts to install if pkg.cli_definition(): log.info('Installing CLI for package={}'.format(package_name)) dcos.subcommand.install(pkg) # Wait for expected tasks to come up if expected_running_tasks > 0: shakedown.wait_for_service_tasks_running( service_name, expected_running_tasks, timeout_seconds) # Wait for completed marathon deployment app_id = pkg.marathon_json(options).get('id') shakedown.deployment_wait(timeout_seconds, app_id)