Package: openstack-cluster-installer
Version: 42.3.0~bpo12+1
Severity: minor
Tags: patch
When adding a new node to the OpenStack cluster there are a number of
PHP warnings which appear in the apache error log, which can potentially
be misleading when diagnosing problems.
I've attached a couple of patches:
* api.php_fix_var_names.patch
Corrects variable names which don't exist with the right ones
* slave_actions.php_mkdir_if_not_exists.patch
Check if a directory already exists before creating it
* slave_actions.php_no_append_to_nil_string.patch
The key $json["data"] does not exist so appending to it generates a
warning
--
Regards
Jim
diff --git a/src/api.php b/src/api.php
index 5d0a921a..5d5938be 100644
--- a/src/api.php
+++ b/src/api.php
@@ -544,7 +544,7 @@ function api_actions($con,$conf){
// Time server host
if(isset($_REQUEST["time_server_host"])){
$safe_time_server_host = safe_fqdn("time_server_host");
- if($safe_swift_part_power === FALSE){
+ if($safe_time_server_host === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid time server host.";
return $json;
@@ -611,7 +611,7 @@ function api_actions($con,$conf){
// VIP hostname (ie: api hostname)
if(isset($_REQUEST["vip_hostname"])){
$safe_vip_hostname = safe_fqdn("vip_hostname");
- if($safe_swift_part_power === FALSE){
+ if($safe_vip_hostname === FALSE){
$json["status"] = "error";
$json["message"] = "Error: not valid time server host.";
return $json;
diff --git a/src/inc/slave_actions.php b/src/inc/slave_actions.php
index 910f503f..415f15a0 100644
--- a/src/inc/slave_actions.php
+++ b/src/inc/slave_actions.php
@@ -1,5 +1,11 @@
<?php
+function mkdir_if_not_exists($dir, $perms = 0777){
+ if (! file_exists($dir)) {
+ mkdir($dir, $perms);
+ }
+}
+
function cluster_register_vip($con, $conf, $cluster_id, $role_name){
$json["status"] = "success";
$json["message"] = "Successfuly queried API.";
@@ -584,7 +590,7 @@ function new_cluster($con, $conf, $cluster_name, $cluster_domain){
insert_cluster_pass($con, $conf, $cluster_id, 'rally', 'db');
$dir = "/var/lib/oci/clusters/$cluster_name";
- mkdir($dir, 0700);
+ mkdir_if_not_exists($dir, 0700);
// Provision an API SSL certificate
$api_hostname = $cluster_name . "-api." . $cluster_domain;
@@ -597,7 +603,7 @@ function new_cluster($con, $conf, $cluster_name, $cluster_domain){
### Create an ssh key for this cluster ###
##########################################
$ssh_key_dir = "/var/lib/oci/clusters/$cluster_name/ssh";
- mkdir($ssh_key_dir, 0700);
+ mkdir_if_not_exists($ssh_key_dir, 0700);
$cmd = "ssh-keygen -P '' -f $ssh_key_dir/id_rsa";
$output = array();
$return_var = 0;
@@ -1715,18 +1721,11 @@ function build_swift_ring($con, $conf, $cluster_id, $verbose="no", $initial_acco
# First, we check if there's some swiftstore machines in the cluster, in which case
# we do need a swift ring.
- if(!is_dir("/var/lib/oci/clusters")){
- mkdir("/var/lib/oci/clusters", 0755);
- }
- if(!is_dir("/var/lib/oci/clusters/$cluster_name")){
- mkdir("/var/lib/oci/clusters/$cluster_name", 0755);
- }
-
+ mkdir_if_not_exists("/var/lib/oci/clusters", 0755);
+ mkdir_if_not_exists("/var/lib/oci/clusters/$cluster_name", 0755);
$swift_ring_path = "/var/lib/oci/clusters/$cluster_name/swift-ring";
- if(!is_dir($swift_ring_path)){
- mkdir($swift_ring_path, 0755);
- }
+ mkdir_if_not_exists($swift_ring_path, 0755);
if($ec_only == "no"){
# Account
@@ -2218,15 +2217,9 @@ function slave_install_os($con, $conf, $machine_id, $install_cmd){
### Create a folder for filesystem template of host ###
#######################################################
$template_path = "/var/lib/oci/clusters/$cluster_name/$machine_hostname";
- if(!is_dir("/var/lib/oci/clusters")){
- mkdir("/var/lib/oci/clusters", 0755);
- }
- if(!is_dir("/var/lib/oci/clusters/$cluster_name")){
- mkdir("/var/lib/oci/clusters/$cluster_name", 0755);
- }
- if(!is_dir("/var/lib/oci/clusters/$cluster_name/$machine_hostname")){
- mkdir("/var/lib/oci/clusters/$cluster_name/$machine_hostname", 0755);
- }
+ mkdir_if_not_exists("/var/lib/oci/clusters", 0755);
+ mkdir_if_not_exists("/var/lib/oci/clusters/$cluster_name", 0755);
+ mkdir_if_not_exists("/var/lib/oci/clusters/$cluster_name/$machine_hostname", 0755);
#########################
### Manage /etc/hosts ###
@@ -2372,19 +2365,19 @@ function slave_install_os($con, $conf, $machine_id, $install_cmd){
}
}
- mkdir("$template_path/oci-in-target");
- mkdir("$template_path/oci-in-target/etc");
- mkdir("$template_path/oci-in-target/etc/oci");
+ mkdir_if_not_exists("$template_path/oci-in-target");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc/oci");
##############################
### Copy the root CA files ###
##############################
# Note that later on, the openstack-debian-images script will run update-ca-certificates
# We also transport these through puppet, but it's nicer to have them at setup time.
- mkdir("$template_path/oci-in-target/usr");
- mkdir("$template_path/oci-in-target/usr/share");
- mkdir("$template_path/oci-in-target/usr/share/ca-certificates");
- mkdir("$template_path/oci-in-target/usr/share/ca-certificates/oci");
+ mkdir_if_not_exists("$template_path/oci-in-target/usr");
+ mkdir_if_not_exists("$template_path/oci-in-target/usr/share");
+ mkdir_if_not_exists("$template_path/oci-in-target/usr/share/ca-certificates");
+ mkdir_if_not_exists("$template_path/oci-in-target/usr/share/ca-certificates/oci");
copy("$ca_pem_dir/oci-pki-root-ca.pem", "$template_path/oci-in-target/usr/share/ca-certificates/oci/OCI_1_selfsigned-root-ca.crt");
copy("$ca_pem_dir/oci-pki-oci-ca.pem", "$template_path/oci-in-target/usr/share/ca-certificates/oci/OCI_2_oci-ca.crt");
@@ -2420,7 +2413,7 @@ function slave_install_os($con, $conf, $machine_id, $install_cmd){
}
if($machine_role == "swiftstore" || $machine_role == "swiftproxy"){
- mkdir("$template_path/oci-in-target/etc/swift");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc/swift");
copy("$swift_ring_path/account.ring.gz", "$template_path/oci-in-target/etc/swift/account.ring.gz");
copy("$swift_ring_path/container.ring.gz", "$template_path/oci-in-target/etc/swift/container.ring.gz");
copy("$swift_ring_path/object.ring.gz", "$template_path/oci-in-target/etc/swift/object.ring.gz");
@@ -2484,8 +2477,8 @@ https://salsa.debian.org/openstack-team/debian/openstack-cluster-installer
############################
$ret = get_machine_management_network_ip($con, $conf, $machine_id);
$ip = $ret["data"];
- mkdir("$template_path/oci-in-target/etc");
- mkdir("$template_path/oci-in-target/etc/oci");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc/oci");
file_put_contents("$template_path/oci-in-target/etc/oci/my-ip", $ip);
file_put_contents("$template_path/oci-in-target/etc/oci/my-role", $machine_role);
@@ -2525,7 +2518,7 @@ https://salsa.debian.org/openstack-team/debian/openstack-cluster-installer
}
if($machine_role == "compute"){
- mkdir("$template_path/oci-in-target/etc/modprobe.d");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc/modprobe.d");
if(($machine["nested_virt"] == "yes") || ($machine["nested_virt"] == "cluster_value" && $cluster["nested_virt"] == "yes")){
file_put_contents("$template_path/oci-in-target/etc/modprobe.d/kvm.conf", "options kvm_intel nested=1");
file_put_contents("$template_path/oci-in-target/etc/modprobe.d/kvm_amd.conf", "options kvm_amd nested=1");
@@ -2557,8 +2550,8 @@ https://salsa.debian.org/openstack-team/debian/openstack-cluster-installer
if($machine_role == "controller"){
$ssh_key_dir = "/var/lib/oci/clusters/$cluster_name/ssh";
if(file_exists("$ssh_key_dir/id_rsa")){
- mkdir("$template_path/oci-in-target/root");
- mkdir("$template_path/oci-in-target/root/.ssh", 0700);
+ mkdir_if_not_exists("$template_path/oci-in-target/root");
+ mkdir_if_not_exists("$template_path/oci-in-target/root/.ssh", 0700);
copy("$ssh_key_dir/id_rsa", "$template_path/oci-in-target/root/.ssh/id_rsa");
chmod("$template_path/oci-in-target/root/.ssh/id_rsa", 0600);
if(file_exists("$ssh_key_dir/id_rsa.pub")){
@@ -2573,8 +2566,8 @@ https://salsa.debian.org/openstack-team/debian/openstack-cluster-installer
# Please note that what's below is also maintained with puppet
# in puppet/manifests/generic.pp. Make sure to modify both here
# and there if you're adding stuff.
- mkdir("$template_path/oci-in-target/etc/facter");
- mkdir("$template_path/oci-in-target/etc/facter/facts.d");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc/facter");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc/facter/facts.d");
$ret = gen_oci_facts($con, $conf, $machine_id);
if($ret["status"] != "success"){
@@ -2604,8 +2597,8 @@ https://salsa.debian.org/openstack-team/debian/openstack-cluster-installer
### Create signed SSH host keys for this machine ###
### and copy the CA, so we can auth all servers ###
####################################################
- mkdir("$template_path/oci-in-target/etc");
- mkdir("$template_path/oci-in-target/etc/ssh");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc");
+ mkdir_if_not_exists("$template_path/oci-in-target/etc/ssh");
# Copy the CA
copy("/var/lib/oci/clusters/$cluster_name/ssh/ca.pub", "$template_path/oci-in-target/etc/ssh/ca.pub");
diff --git a/src/inc/slave_actions.php b/src/inc/slave_actions.php
index 910f503f..762b3a05 100644
--- a/src/inc/slave_actions.php
+++ b/src/inc/slave_actions.php
@@ -2731,7 +2731,7 @@ function oci_install_machine($con, $conf, $machine_id){
$json["message"] = "Error while calculating installation command line for host $safe_machine_serial: ".$slave_install_return["message"];
return $json;
}
- $json["data"] .= "Running: ". $slave_install_return["cmd"];
+ $json["data"] = "Running: ". $slave_install_return["cmd"];
slave_install_os($con, $conf, $machine_id, $slave_install_return["cmd"]);
return $json;