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

trrroy’s picture

Version: 7.x-2.x-dev » 6.x-2.x-dev

switching version

anarcat’s picture

Status: Active » Needs work

please 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.

anarcat’s picture

Project: Hostmaster (Aegir) » Hosting
Status: Needs work » Needs review

so 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.

anarcat’s picture

Status: Needs review » Fixed

ip 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

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit acab2f5 on 6.x-2.x, 7.x-3.x, dev/2000964-ip-allocation-clusters, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by anarcat:
    allocate IPs properly in clusters, closes #2000964
    

  • Commit acab2f5 on 6.x-2.x, 7.x-3.x, dev/2000964-ip-allocation-clusters, dev-ssl-ip-allocation-refactor, dev-sni, dev-helmo-3.x by anarcat:
    allocate IPs properly in clusters, closes #2000964