MXS-2121: Allow destruction of static listeners
If a listener is defined in a static configuration file, it can now be destroyed at runtime. If MaxScale is restarted, the listener will be created again unless the configuration file is modified.
This commit is contained in:
@ -137,7 +137,7 @@ describe("Create/Destroy Commands", function() {
|
|||||||
|
|
||||||
it('will not destroy static listener', function() {
|
it('will not destroy static listener', function() {
|
||||||
return doCommand('destroy listener RW-Split-Router RW-Split-Listener')
|
return doCommand('destroy listener RW-Split-Router RW-Split-Listener')
|
||||||
.should.be.rejected
|
.should.be.fulfilled
|
||||||
})
|
})
|
||||||
|
|
||||||
it('create user', function() {
|
it('create user', function() {
|
||||||
|
|||||||
@ -1032,7 +1032,6 @@ bool runtime_create_listener(Service* service,
|
|||||||
|
|
||||||
bool runtime_destroy_listener(Service* service, const char* name)
|
bool runtime_destroy_listener(Service* service, const char* name)
|
||||||
{
|
{
|
||||||
bool rval = false;
|
|
||||||
char filename[PATH_MAX];
|
char filename[PATH_MAX];
|
||||||
snprintf(filename, sizeof(filename), "%s/%s.cnf", get_config_persistdir(), name);
|
snprintf(filename, sizeof(filename), "%s/%s.cnf", get_config_persistdir(), name);
|
||||||
|
|
||||||
@ -1043,20 +1042,20 @@ bool runtime_destroy_listener(Service* service, const char* name)
|
|||||||
if (errno != ENOENT)
|
if (errno != ENOENT)
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to remove persisted listener configuration '%s': %d, %s",
|
MXS_ERROR("Failed to remove persisted listener configuration '%s': %d, %s",
|
||||||
filename,
|
filename, errno, mxs_strerror(errno));
|
||||||
errno,
|
return false;
|
||||||
mxs_strerror(errno));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
config_runtime_error("Persisted configuration file for listener '%s' was not "
|
MXS_WARNING("Persisted configuration file for listener '%s' was not found. This means that the "
|
||||||
"found. This means that the listener was not created at "
|
"listener was not created at runtime. Remove the listener manually from the correct "
|
||||||
"runtime. Remove the listener manually from the correct "
|
"configuration file to permanently destroy the listener.", name);
|
||||||
"configuration file.",
|
|
||||||
name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (!service_remove_listener(service, name))
|
|
||||||
|
bool rval = false;
|
||||||
|
|
||||||
|
if (!service_remove_listener(service, name))
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to destroy listener '%s' for service '%s'", name, service->name);
|
MXS_ERROR("Failed to destroy listener '%s' for service '%s'", name, service->name);
|
||||||
config_runtime_error("Failed to destroy listener '%s' for service '%s'", name, service->name);
|
config_runtime_error("Failed to destroy listener '%s' for service '%s'", name, service->name);
|
||||||
|
|||||||
@ -165,7 +165,7 @@ describe("Service", function() {
|
|||||||
|
|
||||||
it("destroy a static listener", function() {
|
it("destroy a static listener", function() {
|
||||||
return request.delete(base_url + "/services/RW-Split-Router/listeners/RW-Split-Listener")
|
return request.delete(base_url + "/services/RW-Split-Router/listeners/RW-Split-Listener")
|
||||||
.should.be.rejected
|
.should.be.fulfilled
|
||||||
});
|
});
|
||||||
|
|
||||||
after(stopMaxScale)
|
after(stopMaxScale)
|
||||||
|
|||||||
Reference in New Issue
Block a user