def test_custom_seccomp_profile(): sdk_plan.wait_for_completed_deployment(config.SERVICE_NAME) marathon_config = sdk_marathon.get_config(config.SERVICE_NAME) # uname will now be dissalowed and svc should crashloop marathon_config["env"]["HELLO_SECCOMP_PROFILE_NAME"] = "test_profile.json" sdk_marathon.update_app(marathon_config) sdk_marathon.wait_for_deployment(config.SERVICE_NAME, 60, None)
def _retried_install_impl( package_name: str, service_name: str, expected_running_tasks: int, package_version: Optional[str], options: Dict[str, Any], timeout_seconds: int, wait_for_all_conditions: bool, ) -> None: 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. install_cmd = ["package", "install", package_name, "--yes"] if package_version: install_cmd.append("--package-version={}".format(package_version)) if sdk_marathon.app_exists(service_name): log.info( "Marathon app={} exists, ensuring CLI for package={} is installed". format(service_name, package_name)) install_cmd.append("--cli") elif options: # Write options to a temporary json file to be accessed by the CLI: options_file = tempfile.NamedTemporaryFile("w") json.dump(options, options_file) options_file.flush( ) # ensure content is available for the CLI to read below install_cmd.append("--options={}".format(options_file.name)) sdk_cmd.run_cli(" ".join(install_cmd), check=True) # Wait for expected tasks to come up if expected_running_tasks > 0 and wait_for_all_conditions: sdk_tasks.check_running( service_name=service_name, expected_task_count=expected_running_tasks, timeout_seconds=timeout_seconds, ) # Wait for completed marathon deployment if wait_for_all_conditions: sdk_marathon.wait_for_deployment(service_name, timeout_seconds, None)
def _wait_for_deployment(package_name, service_name, initial_config, task_ids, timeout_seconds): # First we wait for the actual scheduler Marathon task itself to finish any possible # deployments. sdk_marathon.wait_for_deployment(service_name, timeout_seconds, None) updated_config = get_config(package_name, service_name) if updated_config == initial_config: log.info("No config change detected. Tasks should not be restarted") sdk_tasks.check_tasks_not_updated(service_name, "", task_ids) else: log.info("Checking that all tasks have restarted") sdk_tasks.check_tasks_updated(service_name, "", task_ids) # this can take a while, default is 15 minutes. for example with HDFS, we can hit the expected # total task count via ONCE tasks, without actually completing deployment log.info("Waiting for package={} service={} to finish deployment plan...". format(package_name, service_name)) sdk_plan.wait_for_completed_deployment(service_name, timeout_seconds)
def _wait_for_deployment( package_name: str, service_name: str, initial_config: Dict[str, Any], task_ids: List[str], timeout_seconds: int, ) -> None: sdk_marathon.wait_for_deployment(service_name, timeout_seconds, None) updated_config = get_config(package_name, service_name) if updated_config == initial_config: log.info("No config change detected. Tasks should not be restarted") sdk_tasks.check_tasks_not_updated(service_name, "", task_ids) else: log.info("Checking that all tasks have restarted") sdk_tasks.check_tasks_updated(service_name, "", task_ids) # this can take a while, default is 15 minutes. for example with HDFS, we can hit the expected # total task count via ONCE tasks, without actually completing deployment log.info("Waiting for package={} service={} to finish deployment plan...". format(package_name, service_name)) sdk_plan.wait_for_completed_deployment(service_name, timeout_seconds)