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

make the check port changes for chef-managed database for automate ha #8613

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion api/config/pg_gateway/config_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func DefaultConfigRequest() *ConfigRequest {
c.V1.Sys.Timeouts.Idle = w.Int32(43200)
c.V1.Sys.Resolvers.EnableSystemNameservers = w.Bool(false)
c.V1.Sys.MaxConnections = w.Int32(350)

c.V1.Sys.AutomateHaChefManagePg = w.Bool(false)
return c
}

Expand Down
181 changes: 98 additions & 83 deletions api/config/pg_gateway/config_request.pb.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions api/config/pg_gateway/config_request.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ message ConfigRequest {
Timeouts timeouts = 5;
Resolvers resolvers = 6;
google.protobuf.Int32Value max_connections = 7;
google.protobuf.BoolValue automate_ha_chef_manage_pg = 8;

message Resolvers {
repeated google.protobuf.StringValue nameservers = 1;
Expand All @@ -42,6 +43,7 @@ message ConfigRequest {
reserved 3;
chef.automate.infra.config.External.Postgresql external_postgresql = 4;
repeated Endpoint parsed_nodes = 5;

}

message Timeouts {
Expand Down
1 change: 1 addition & 0 deletions components/automate-backend-deployment/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ This provides the `automate-backend-deployment` package.
This package will build a package using terraform/a2ha-terraform, inspecs, test, certs and Makefile.

This is the heart of the a2ha because this component will set up a workspace for a2ha and all the a2ha command will get available after installing this package.

4 changes: 1 addition & 3 deletions components/automate-cli/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,4 @@ do_after() {
ln -sv "${pkg_prefix}/bin/${bin}" "${bin_path}"
sha256sum "${bin_path}" | cut -d ' ' -f1 > "${bin_sha_path}"
done
}


}
2 changes: 2 additions & 0 deletions components/automate-deployment/habitat/plan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,5 @@ scaffolding_go_binary_list=(
do_strip() {
return 0
}


4 changes: 2 additions & 2 deletions components/automate-pg-gateway/habitat/config/haproxy.conf
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ backend automate_postgresql
{{~#if ../cfg.resolvers.nameservers }}
server-template {{node.address}} 8 {{node.address}}:{{node.port}} check resolvers pgdns init-addr none resolve-prefer ipv4
{{else}}
server {{node.address}} {{node.address}}:{{node.port}} maxconn {{../cfg.max_connections}} check port 6432
server {{node.address}} {{node.address}}:{{node.port}} maxconn {{../cfg.max_connections}} {{~#if ../cfg.automate_ha_chef_manage_pg }} check port 6432 {{~/if}}
{{~/if}}
{{else}}
server {{node.address}} {{node.address}}:{{node.port}} maxconn {{../cfg.max_connections}} check port 6432
server {{node.address}} {{node.address}}:{{node.port}} maxconn {{../cfg.max_connections}} {{~#if ../cfg.automate_ha_chef_manage_pg }} check port 6432 {{~/if}}
{{~/if}}
{{~/each}}
{{else~}}
Expand Down
2 changes: 1 addition & 1 deletion components/automate-pg-gateway/habitat/default.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
max_connections = 350

automate_ha_chef_manage_pg = false
[service]
host = "0.0.0.0"
port = 10145
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3399,3 +3399,9 @@ rM2p0kk=
base_path = "automate"
<% end %>

<% if services[:postgresql][:setup_managed_services] == false && overrides[:setup_self_managed_services] == false -%>
punitmundra marked this conversation as resolved.
Show resolved Hide resolved
[pg_gateway]
[pg_gateway.v1]
[pg_gateway.v1.sys]
automate_ha_chef_manage_pg = true
<% end %>
Original file line number Diff line number Diff line change
Expand Up @@ -60,36 +60,51 @@ export HAB_SUP_GATEWAY_AUTH_TOKEN=${hab_sup_http_gateway_auth_token}
export isSkipRequired=false
# Below function is calculating the version of the install version and airgap bundle version
# and do comparision in case if both are same it set isSkipRequired=true
semver_version_check() {
installed_version=$1
airgap_bundle_version=$2

IFS='.' read -r major1 minor1 patch1 <<< "$installed_version"
IFS='.' read -r major2 minor2 patch2 <<< "$airgap_bundle_version"

# Compare major versions
if (( major1 > major2 )); then
echo "$installed_version is greater than $airgap_bundle_version"
isSkipRequired=true
elif (( major1 < major2 )); then
echo "$airgap_bundle_version is greater than $installed_version, proceeding for upgrade"
else
# Compare minor versions
if (( minor1 > minor2 )); then
echo "$installed_version is greater than $airgap_bundle_version"
isSkipRequired=true
elif (( minor1 < minor2 )); then
echo "$airgap_bundle_version is greater than $installed_version, proceeding for upgrade"
else
# Compare patch versions
if (( patch1 > patch2 )); then
echo "$installed_version is greater than $airgap_bundle_version"
isSkipRequired=true
elif (( patch1 < patch2 )); then
echo "$airgap_bundle_version is greater than $installed_version, proceeding for upgrade"
else
echo "Both versions are equal"
isSkipRequired=true
fi
fi
fi
}

version_check_for_addnode() {
installed_version=$(chef-automate version 2>/dev/null | grep Server | awk '{print $3}')
airgap_bundle_version=$(chef-automate airgap bundle info ${frontend_aib_file} 2>/dev/null | grep "Version" | awk '{print $2}')

# Uncomment this if you want to override the versions for testing
# installed_version=$1
# airgap_bundle_version=$2

# installed_version=$1 4.12.144
# airgap_bundle_version=$2 4.13.0
echo "Installed Version: $installed_version"
echo "Airgap Bundle Version: $airgap_bundle_version"

# Split the version strings into arrays based on the dot separator
IFS='.' read -ra ver1_arr <<< "$installed_version"
IFS='.' read -ra ver2_arr <<< "$airgap_bundle_version"

# Determine the number of components in the version strings
num_components1=$${#ver1_arr[@]}
num_components2=$${#ver2_arr[@]}

# Compare each component of the version strings
for ((i = 0; i < num_components1 && i < num_components2; i++)); do
if [ "$${ver1_arr[i]}" -lt "$${ver2_arr[i]}" ]; then
echo "Airgap bundle version $airgap_bundle_version is greater than installed version $installed_version"
elif [ "$${ver1_arr[i]}" -gt "$${ver2_arr[i]}" ]; then
echo "Installed version $installed_version is greater than airgap bundle $airgap_bundle_version"
isSkipRequired=true
fi
done

# If we reach this point, the version strings are equal up to the common components.
semver_version_check $installed_version $airgap_bundle_version
# If we reach this point, the version strings are equal up to the common components.
if [ $installed_version = $airgap_bundle_version ]; then
echo "Both version strings are equal."
isSkipRequired=true
Expand Down
Loading