Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.3.x] MODCLUSTER-824 Improve handling of overlapping aliases in APP commands #840

Draft
wants to merge 1 commit into
base: 1.3.x
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 20 additions & 14 deletions native/mod_manager/mod_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ static char * process_appl_cmd(request_rec *r, char **ptr, int status, int *errt

int i = 0;
hostinfo_t hostinfo;
hostinfo_t *host;
hostinfo_t *host = NULL;
char *p_tmp;

memset(&nodeinfo.mess, '\0', sizeof(nodeinfo.mess));
Expand Down Expand Up @@ -1748,23 +1748,29 @@ static char * process_appl_cmd(request_rec *r, char **ptr, int status, int *errt
return (process_node_cmd(r, status, errtype, node));
}

/* Read the ID of the virtual host corresponding to the first Alias */
/* Go through the provided Aliases, the first Alias that matches an existing host gets used
* otherwise, a new host will be created
*/
hostinfo.node = node->mess.id;
hostinfo.id = 0;
if (vhost->host != NULL) {
char *s = hostinfo.host;
int j = 1;
strncpy(hostinfo.host, vhost->host, sizeof(hostinfo.host));
hostinfo.host[sizeof(hostinfo.host)-1] = '\0';
while (*s != ',' && j<sizeof(hostinfo.host)) {
j++;
s++;
}
*s = '\0';
} else
int start = 0;
i = 0;
while (host == NULL && i + start < strlen(vhost->host)) {
while (vhost->host[start+i] != ',' && vhost->host[start+i] != '\0') {
i++;
}

strncpy(hostinfo.host, vhost->host + start, i);
hostinfo.host[i] = '\0';
host = read_host(hoststatsmem, &hostinfo);
start = start + i + 1;
i = 0;
}
Comment on lines +1759 to +1769
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jajik Sorry for delay, but I am under suspicion this is still a little wrong / problematic. While the 'matching' fix is correct and should really result in 1 vhost if any of the aliases are overlapping - the result bit should not be a merge, but a replace.

E.g. an existing vhost with aliases A,B receives update with B,C, the resulting vhost should be B,C rather than a merge of A,B,C.

Let me know if I misunderstood.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jfclere What do you think? May that result in some node infighting?

Copy link
Member

@jfclere jfclere Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhusar hm do we want to merge?... because if the back-end send a ENABLE context/hosts, so you are thinking of:

  • /test A,B
  • /other B, C
    that means you have in the back-end
    VM1 : A, B
    VM2: B, C
    So a request to /test on A should go to test on host1 and a request to /test on C (host2) should give a 404 (well look to find other context/hosts).

so merging looks wrong that way... B, C also looks wrong no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

host1, host2 are jvmroutes and A, B, C aliases in this case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and:
/test A,B (VM1)
/test B,C (VM2)
Should be rejected : we don't know how to route /test B ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But in case of different JVMRoutes the merge does not happen.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jajik correct.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would create

Node host1

  • Contexts
    • /test
  • Aliases
    • A, B

Node host2

  • Contexts
    • /other
  • Aliases
    • B, C

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rhusar @jajik so code is correct.
VM1 /test A, B
some configuration changes
VM1 /test B, C
We should not route A / test there correct?

Copy link
Collaborator Author

@jajik jajik Dec 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the merge would happen only if new ENABLE-APP with /test B, C went from host1, so that it would be like this afterwards

Node host1

  • Contexts
    • /test
  • Aliases
    • A, B, C

Node host2

  • Contexts
    • /other
  • Aliases
    • B, C

instead of the current behaviour

Node host1

  • Context
    • /test
  • Aliases
    • A, B
  • Context
    • /test
  • Aliases
    • B, C

Node host2

  • Contexts
    • /other
  • Aliases
    • B, C

} else {
hostinfo.host[0] = '\0';
}

hostinfo.id = 0;
host = read_host(hoststatsmem, &hostinfo);
if (host == NULL) {
/* If REMOVE ignores it */
if (status == REMOVE)
Expand Down
Loading