Modifications to reputation contract deployment (#384)

This commit is contained in:
Chalith Desaman
2024-05-31 12:13:23 +05:30
committed by GitHub
parent 216cc27584
commit 52b7ac9f1b
23 changed files with 229 additions and 293 deletions

View File

@@ -478,26 +478,18 @@ namespace hp
return -1;
}
LOG_INFO << "Destroying container " << container_name;
if (docker_remove(info.username, container_name) == -1 ||
LOG_INFO << "Deleting instance " << container_name;
if (uninstall_user(info.username, info.assigned_ports, container_name) == -1 ||
// sqlite::update_status_in_container(db, container_name, CONTAINER_STATES[STATES::DESTROYED]) == -1) // Soft Deletion.
sqlite::delete_hp_instance(db, container_name) == -1) // Permanent Deletion.
{
error_msg = CONTAINER_DESTROY_ERROR;
LOG_ERROR << errno << ": Error destroying container " << container_name;
error_msg = USER_UNINSTALL_ERROR;
return -1;
}
// Add the port pair of the destroyed container to the vacant port vector.
if (std::find(vacant_ports.begin(), vacant_ports.end(), info.assigned_ports) == vacant_ports.end())
vacant_ports.push_back(info.assigned_ports);
// Remove user after destroying.
if (uninstall_user(info.username, info.assigned_ports, container_name) == -1)
{
error_msg = USER_UNINSTALL_ERROR;
return -1;
}
return 0;
}