Skip to content

Can't delete server from the list #172

@NVitanovic

Description

@NVitanovic

cantdeleteserver
PuppetGUI somehow created a server in database without a role. There is a row in the servers table, but there is not a matching row that references the server in the table roles. Because of that the service is interpreted as a null service resulting in not showing an icon of the role (orange) and you can't seem to be able to delete the service if you press delete.

Solution is to add the needed data to the table roles and reference the server that had no role. After that the server can be deleted by pressing the delete button.

The problem can be solved in file /app/routes/servers.js on delete route.

router.delete('/:hostname', function (req, res, next) {
	var hostname = req.params.hostname;
	database.query('DELETE servers FROM servers JOIN roles ON servers.id = roles.fk_server WHERE servers.hostname = \'' + hostname + '\'', function (err, rows, field) {
		if (err) {
			res.send(JSON.stringify({ error: 'could not delete from database' }));
		}
		res.send(JSON.stringify({ error: 'ok' }));
	});
});

DELETE joins two tables, and if the row does not exist in the roles table then the command fails and delete does not happen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions