void docker_scheduler::unschedule( std::shared_ptr<deployment_unit>& unit ) { bool found = false; _lock.lock(); auto it = _deploy_map.find(unit->name); found = (it != _deploy_map.end()); if( found ) { return_machines(unit->name); _machine_map.erase(unit->name); _deploy_map.erase(it); _lock.unlock(); dsn::tasking::enqueue(LPC_DOCKER_DELETE,this, [this, unit]() { delete_containers(unit->name, unit->undeployment_callback, unit->local_package_directory, unit->remote_package_directory); }); } else { _lock.unlock(); unit->undeployment_callback(ERR_DOCKER_UNDEPLOY_FAILED,std::string()); } }
static void delete_target(Target *target) { if(target != NULL) { delete_properties(target->properties); delete_containers(target->containers); g_free(target->system); g_free(target->client_interface); g_free(target->target_property); g_free(target); } }
void docker_scheduler::undeploy_docker_unit(void* context, int argc, const char** argv, dsn_cli_reply* reply) { auto docker = reinterpret_cast<docker_scheduler*>(context); if( argc == 3 ) { std::string name = argv[0]; std::string ldir = argv[1]; std::string rdir = argv[2]; std::function<void(error_code,const std::string&)> cb = [](error_code err,const std::string& err_msg){ dinfo("deploy err %s",err.to_string()); }; docker->delete_containers(name,cb,ldir,rdir); } reply->message = ""; reply->size = 0; reply->context = nullptr; }