Closed (fixed)
Project:
Hosting
Version:
6.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
22 May 2013 at 18:21 UTC
Updated:
12 Jun 2014 at 08:59 UTC
Jump to comment: Most recent
When trying to allocate IP addresses and to the certificate for each of the servers in a web pack it fails to allocate the address to the masters and slaves. It seems that it is trying to allocate to the "pack" node itself instead of the individual servers. Maybe there's a better way to do this using the contexts properly but the following seems to make it work.
diff --git a/hosting/server/hosting.ip.inc b/hosting/server/hosting.ip.inc
index add247e..2669687 100644
--- a/hosting/server/hosting.ip.inc
+++ b/hosting/server/hosting.ip.inc
@@ -107,13 +107,41 @@ function hosting_ip_allocate($cert, $site) {
db_query("LOCK TABLES {hosting_ssl_cert_ips} WRITE, {hosting_ip_addresses} WRITE");
$platform = node_load($site->platform);
$server = node_load($platform->web_server);
- // guess the next available IP
- $ip = db_result(db_query("SELECT hosting_ip_addresses.id FROM {hosting_ip_addresses}
- LEFT JOIN {hosting_ssl_cert_ips} ON hosting_ip_addresses.id = hosting_ssl_cert_ips.ip_address
- WHERE hosting_ssl_cert_ips.ip_address IS NULL AND nid = %d LIMIT 1;", $server->nid));
- if ($ip) {
- db_query("INSERT INTO {hosting_ssl_cert_ips} (cid, ip_address) VALUES (%d, %d)", $cert->cid, $ip);
+ // guess the next available IPi
+ if ($server->services['http']->type == "pack") {
+ foreach ($server->services['http']->master_servers as $key => $value) {
+ drupal_set_message("master server: " . $value);
+ $pack_node = node_load($value);
+ // guess the next available IP
+ $ip = db_result(db_query("SELECT hosting_ip_addresses.id FROM {hosting_ip_addresses}
+ LEFT JOIN {hosting_ssl_cert_ips} ON hosting_ip_addresses.id = hosting_ssl_cert_ips.ip_address
+ WHERE hosting_ssl_cert_ips.ip_address IS NULL AND nid = %d LIMIT 1;", $pack_node->nid));
+ if ($ip) {
+ db_query("INSERT INTO {hosting_ssl_cert_ips} (cid, ip_address) VALUES (%d, %d)", $cert->cid, $ip);
+ }
+ }
+ foreach ($server->services['http']->slave_servers as $key => $value) {
+ drupal_set_message("slave server: " . $value);
+ $pack_node = node_load($value);
+ // guess the next available IP
+ $ip = db_result(db_query("SELECT hosting_ip_addresses.id FROM {hosting_ip_addresses}
+ LEFT JOIN {hosting_ssl_cert_ips} ON hosting_ip_addresses.id = hosting_ssl_cert_ips.ip_address
+ WHERE hosting_ssl_cert_ips.ip_address IS NULL AND nid = %d LIMIT 1;", $pack_node->nid));
+ if ($ip) {
+ db_query("INSERT INTO {hosting_ssl_cert_ips} (cid, ip_address) VALUES (%d, %d)", $cert->cid, $ip);
+ }
+ }
}
+ else {
+ // guess the next available IP
+ $ip = db_result(db_query("SELECT hosting_ip_addresses.id FROM {hosting_ip_addresses}
+ LEFT JOIN {hosting_ssl_cert_ips} ON hosting_ip_addresses.id = hosting_ssl_cert_ips.ip_address
+ WHERE hosting_ssl_cert_ips.ip_address IS NULL AND nid = %d LIMIT 1;", $server->nid));
+ if ($ip) {
+ db_query("INSERT INTO {hosting_ssl_cert_ips} (cid, ip_address) VALUES (%d, %d)", $cert->cid, $ip);
+ }
+ }
+
db_query("UNLOCK TABLES");
return $ip;
}
Comments
Comment #1
trrroy commentedswitching version
Comment #2
anarcat commentedplease mark issues with a patch as "needs review" when submitting them!
so this is great. i am not sure i want to hardcode the pack module code in there, maybe the ip allocation should be extensible in some way. but this is a good start!
let's review this together on friday or tonight.
Comment #3
anarcat commentedso I am doing this on the development branch dev/2000964-ip-allocation-clusters branch. so far I got one patch in:
http://drupalcode.org/project/hosting.git/commitdiff/129db9e794458415227...
I'd like you to test this since my test environment is quite limited right now.
Note that I suspect our incompatiblility wwith cluster/pack is not limited to just IP allocation, see also #1784108: pack (and cluster?) modules incompatible with SSL.
Comment #4
anarcat commentedip allocation should now be fixed. all commits on the branch dev/2000964-ip-allocation-clusters have been merged, although one I am not sure is necessary...
we still have issues with SSL on clusters, tracked in #1784108: pack (and cluster?) modules incompatible with SSL