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

Conversation

jajik
Copy link
Collaborator

@jajik jajik commented Oct 21, 2024

Resolves MODCLUSTER-824

Opening as a draft since it's a backport.

Copy link
Member

@rhusar rhusar left a comment

Choose a reason for hiding this comment

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

Please update the commit message so that the Jira ID is the first in the commit message.

@jajik jajik requested a review from rhusar October 21, 2024 09:23
@rhusar rhusar changed the title [1.3.x] Improve handling of overlapping aliases in APP commands [1.3.x] MODCLUSTER-824 Improve handling of overlapping aliases in APP commands Oct 21, 2024
@jajik jajik added the 1.3.x Issues and PRs for the 1.3.x branch label Oct 21, 2024
@jajik
Copy link
Collaborator Author

jajik commented Oct 21, 2024

@jajik jajik added the bug label Oct 21, 2024
@jajik
Copy link
Collaborator Author

jajik commented Oct 24, 2024

Upstream is merged, marking ready for review

@jajik jajik marked this pull request as ready for review October 24, 2024 14:55
Copy link
Member

@rhusar rhusar left a comment

Choose a reason for hiding this comment

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

Can we please validate the removal behavior? Just to make sure there isn't a side-effect that we are missing.

@jajik
Copy link
Collaborator Author

jajik commented Oct 30, 2024

Can we please validate the removal behavior? Just to make sure there isn't a side-effect that we are missing.

Before the patch, two virtual hosts with overlapping aliases are created. When REMOVE-APP is sent to the overlapping alias, only one of the hosts gets removed. (That does no affect the case when the remove command is sent with /* path, then both get removed.)

With this PR, only one virtual hosts is present because in case of an overlap, the two get merged. Then the removal removes the only host as expected.

@jajik jajik requested a review from rhusar December 6, 2024 14:11
@jajik
Copy link
Collaborator Author

jajik commented Dec 12, 2024

@rhusar any updates on this?

Comment on lines +1759 to +1769
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;
}
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

@jajik
Copy link
Collaborator Author

jajik commented Dec 17, 2024

Alright, so it seems we have come to a conclusion that replace is the correct action (instead of the proposed merge). I'll fix this PR once I fix the upstream.

@jajik
Copy link
Collaborator Author

jajik commented Dec 17, 2024

Alright, so it seems we have come to a conclusion that replace is the correct action (instead of the proposed merge). I'll fix this PR once I fix the upstream.

Or maybe not. In case of following configuration of tomcat

      <Host name="localhost" appBase="webapps"
            unpackWARs="true" autoDeploy="true">
            <Alias>default.example.com</Alias>
        </Host>

      
       <Host name="testing"  appBase="webapps-example"
            unpackWARs="true" autoDeploy="true">
            <Alias>default.example.com</Alias>
        </Host>

the merge seems the right way...

@jfclere
Copy link
Member

jfclere commented Dec 17, 2024

in server.xml:

+++
      <Host name="A"    appBase="Aapps" unpackWARs="true" autoDeploy="true">
         <Alias>B</Alias>
      </Host>
      <Host name="B" appBase="Bapps" unpackWARs="true" autoDeploy="true">
         <Alias>C</Alias>
      </Host>
+++

deploy demo-1.0.war in HostA... you have in mod_proxy_cluster Alias a, b.
deploy test.war in HostB... you have in mod_proxy_cluster Alias a, b, c .
The above looks wrong demo-1.0 was never for c and test was never for a.

undeploy test.war in HostB.... you still have Alias a, b, c ... so c still has demo-1.0 which is wrong.

@jajik
Copy link
Collaborator Author

jajik commented Dec 17, 2024

in server.xml:

+++
      <Host name="A"    appBase="Aapps" unpackWARs="true" autoDeploy="true">
         <Alias>B</Alias>
      </Host>
      <Host name="B" appBase="Bapps" unpackWARs="true" autoDeploy="true">
         <Alias>C</Alias>
      </Host>
+++

deploy demo-1.0.war in HostA... you have in mod_proxy_cluster Alias a, b. deploy test.war in HostB... you have in mod_proxy_cluster Alias a, b, c . The above looks wrong demo-1.0 was never for c and test was never for a.

undeploy test.war in HostB.... you still have Alias a, b, c ... so c still has demo-1.0 which is wrong.

Right, so we have multiple levels at which both the current state and the proposed fix are not working. 😄 I'll mark this as draft, we should think it through first.

@jajik jajik marked this pull request as draft December 17, 2024 13:35
@rhusar
Copy link
Member

rhusar commented Dec 17, 2024

Right, so we have multiple levels at which both the current state and the proposed fix are not working. 😄 I'll mark this as draft, we should think it through first.

A partial fix went into upstream/main, so just make sure we don't forget to fix there too. 👍🏼

@jfclere
Copy link
Member

jfclere commented Dec 17, 2024

Another funny thing:

      <Host name="A"    appBase="Aapps" unpackWARs="true" autoDeploy="true">
         <Alias>B</Alias>
      </Host>
      <Host name="B" appBase="Bapps" unpackWARs="true" autoDeploy="true">
         <Alias>A</Alias>
      </Host>

deploy demo-1.0 in Aapps, then in Bapps, wait and later undeploy demo-1.0 in Aapps, the VirtualHost is gone :-(

I don't see how to handle this "configuration error"...

@jfclere
Copy link
Member

jfclere commented Dec 17, 2024

     <Host name="A"    appBase="Aapps" unpackWARs="true" autoDeploy="true">
         <Alias>B</Alias>
      </Host>
      <Host name="A" appBase="Bapps" unpackWARs="true" autoDeploy="true">
         <Alias>A</Alias>
      </Host>

gives an error in tomcat, as expected.

@jfclere jfclere self-requested a review December 17, 2024 15:48
@jajik
Copy link
Collaborator Author

jajik commented Dec 17, 2024

gives an error in tomcat, as expected.

Hm, but it gives an error due to name=A conflict, but having alias/name conflict is not problem. So this should be fixed in the java part as well.

Although thinking about it, maybe this is something to fix in tomcat directly, isn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.3.x Issues and PRs for the 1.3.x branch bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants