Skip to content

Commit 27536fd

Browse files
committed
Add ceph config wrapper with existence check (resolves #15)
Fix config sync bug between nodes (fixes #16) Improve workflow messages
1 parent cfe1f73 commit 27536fd

File tree

10 files changed

+51
-35
lines changed

10 files changed

+51
-35
lines changed

.github/workflows/build.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
name: Build CephOS installer
1+
name: Build CephOS Installer
22

3-
run-name: Building CephOS installer ${{ github.ref_name }} (@${{ github.actor }})
3+
run-name: Building CephOS Installer ${{ github.ref_name }} (@${{ github.actor }})
44

55
on:
66
release:
@@ -16,16 +16,16 @@ jobs:
1616
- name: Checkout repository
1717
uses: actions/checkout@v4
1818

19-
- name: Set up docker
19+
- name: Set up Docker
2020
uses: docker/setup-buildx-action@v3
2121

2222
- name: Install dependencies
2323
run: sudo apt-get update && sudo apt-get install -y make
2424

25-
- name: Building CephOS
25+
- name: Build CephOS
2626
run: make build
2727

28-
- name: Rename artifact with release tag
28+
- name: Rename artifacts with release tag
2929
run: |
3030
TAG=${GITHUB_REF_NAME}
3131
echo "Using tag: $TAG"
@@ -34,7 +34,7 @@ jobs:
3434
mv tmp/work/cephos.img "tmp/work/cephos_${TAG}.img"
3535
ls -lh tmp/work/
3636
37-
- name: Get fresh Access Token from Yandex
37+
- name: Get fresh access token from Yandex
3838
id: get_token
3939
run: |
4040
RESPONSE=$(curl -s -X POST https://oauth.yandex.ru/token \
@@ -68,12 +68,12 @@ jobs:
6868
--no-progress-meter \
6969
"$UPLOAD_URL"
7070
done
71-
echo "Uploading artefacts done."
71+
echo "Artifacts upload completed successfully."
7272
73-
- name: Send build complete message to Telegram
73+
- name: Send build completion message to Telegram
7474
run: |
7575
TAG=${GITHUB_REF_NAME}
76-
MESSAGE="💾 Version ${TAG} build and upload to [storage](https://disk.yandex.ru/d/VrbJWGtHjB90QQ) is complete"
76+
MESSAGE="💾 Version ${TAG} build and upload to [storage](https://disk.yandex.ru/d/VrbJWGtHjB90QQ) completed successfully"
7777
curl -s -X POST \
7878
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \
7979
-d chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \

.github/workflows/notify-commits.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Notify on Commit
22

3-
run-name: Commit ${{ github.sha }} notify (@${{ github.actor }})
3+
run-name: Commit ${{ github.sha }} notification (@${{ github.actor }})
44

55
on:
66
push:
@@ -11,10 +11,10 @@ jobs:
1111
notify:
1212
runs-on: ubuntu-latest
1313
steps:
14-
- name: Send commit info to Telegram
14+
- name: Send commit information to Telegram
1515
run: |
1616
COMMIT_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${GITHUB_SHA}"
17-
MESSAGE="📝 New [commit](${COMMIT_URL}) to branch \`${GITHUB_REF_NAME}\` from author ${GITHUB_ACTOR} with message: \`${{ github.event.head_commit.message }}\`"
17+
MESSAGE="✒️ New [commit](${COMMIT_URL}) pushed to branch \`${GITHUB_REF_NAME}\` by ${GITHUB_ACTOR} with message: \`${{ github.event.head_commit.message }}\`"
1818
curl -s -X POST \
1919
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \
2020
-d chat_id="${{ secrets.TELEGRAM_CHAT_ID }}" \

.github/workflows/notify-issues.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Notify on Issue
22

3-
run-name: Issue notify (@${{ github.actor }})
3+
run-name: Issue notification (@${{ github.actor }})
44

55
on:
66
issues:
@@ -10,7 +10,7 @@ jobs:
1010
notify:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Send issue info to Telegram
13+
- name: Send issue information to Telegram
1414
run: |
1515
ISSUE_URL="${{ github.event.issue.html_url }}"
1616
TITLE="${{ github.event.issue.title }}"
@@ -19,7 +19,7 @@ jobs:
1919
2020
if [ "$ACTION" = "opened" ]
2121
then
22-
MESSAGE="🔔 New [Issue](${ISSUE_URL}) from author ${USER} with title: \`${TITLE}\`"
22+
MESSAGE="🔔 New [Issue](${ISSUE_URL}) opened by ${USER} with title: \`${TITLE}\`"
2323
else
2424
MESSAGE="✅ [Issue](${ISSUE_URL}) closed by ${USER} (Title: \`${TITLE}\`)"
2525
fi

.github/workflows/notify-releases.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Notify on Release
22

3-
run-name: Release ${{ github.ref_name }} notify (@${{ github.actor }})
3+
run-name: Release ${{ github.ref_name }} notification (@${{ github.actor }})
44

55
on:
66
release:
@@ -10,13 +10,13 @@ jobs:
1010
notify:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- name: Send release info to Telegram
13+
- name: Send release information to Telegram
1414
run: |
1515
RELEASE_URL="${{ github.event.release.html_url }}"
1616
TAG="${{ github.event.release.tag_name }}"
1717
NAME="${{ github.event.release.name }}"
1818
19-
MESSAGE="🚀 New [Release](${RELEASE_URL}). Version: *${TAG}*, name: ${NAME}"
19+
MESSAGE="🚀 New [Release](${RELEASE_URL}) published. Version: *${TAG}*, Name: ${NAME}"
2020
2121
curl -s -X POST \
2222
"https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage" \

live_build_config/includes.chroot_after_packages/usr/local/bin/cephos-conf-sync

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,19 @@ done
3232

3333
function update_nodes()
3434
{
35-
log_info "Updating /etc/hosts"
36-
while read -r node_name public_ip cluster_ip
35+
log_info "Sync cluster nodes configuration"
36+
mapfile -t ceph_hosts < <(get_ceph_hosts)
37+
for line in "${ceph_hosts[@]}"
3738
do
39+
read -r node_name public_ip cluster_ip <<< "${line}"
3840
if [[ "${node_name}" == "$(hostname -s)" ]]
3941
then
4042
cephos-conf-reconcile $(verbose_flag)
4143
else
4244
spread_ssh_key "${user_home}" "${current_user}" "${public_ip}"
4345
exec_ssh "${public_ip}" "${current_user}" "cephos-conf-reconcile $(verbose_flag)"
4446
fi
45-
done < <(get_ceph_hosts)
47+
done
4648
}
4749

4850
# --- functions ---

live_build_config/includes.chroot_after_packages/usr/local/bin/cephos-init-cluster

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ set_cluster_environment "fsid" "${ceph_fsid}"
3333
log_info "Initializing cluster with [fsid:${ceph_fsid}] and main configuration file ${ceph_main_conf}"
3434
create_directories
3535

36-
log_verbose "Creating keys"
37-
${sudo_ceph} ceph-authtool --create-keyring ${ceph_conf_dir}/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mgr 'allow *' --cap mds 'allow *'
38-
${sudo_ceph} ceph-authtool --create-keyring ${ceph_data_dir}/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd' --cap mgr 'allow r'
39-
4036
log_verbose "Creating configuration ${ceph_main_conf}"
4137

4238
ceph_conf_add_to_list "mon_initial_members" "$(hostname -s)"
@@ -64,6 +60,10 @@ ceph_conf_set "global" "auth_client_required" "cephx"
6460
ceph_conf_set "global" "auth_cluster_required" "cephx"
6561
ceph_conf_set "global" "auth_service_required" "cephx"
6662

63+
log_verbose "Creating keys"
64+
${sudo_ceph} ceph-authtool --create-keyring ${ceph_conf_dir}/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mgr 'allow *' --cap mds 'allow *'
65+
${sudo_ceph} ceph-authtool --create-keyring ${ceph_data_dir}/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd' --cap mgr 'allow r'
66+
6767
set_fs_permissions
6868
ceph_crash_up
6969

live_build_config/includes.chroot_after_packages/usr/local/bin/cephos-init-metrics

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@ manage_service_state "enable" "ceph-exporter"
4242

4343
log_info "Ceph internal metrics port: 9108"
4444
${sudo_ceph} ceph mgr module enable prometheus
45-
${sudo_ceph} ceph config set mgr mgr/prometheus/server_addr "::"
46-
${sudo_ceph} ceph config set mgr mgr/prometheus/server_port 9108
45+
ceph_config_set "mgr" "mgr/prometheus/server_addr" "::"
46+
ceph_config_set "mgr" "mgr/prometheus/server_port" "9108"
4747
sudo systemctl restart ceph-mgr@${mgr_id}.service

live_build_config/includes.chroot_after_packages/usr/local/bin/cephos-init-mgr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,10 @@ then
4848
log_info "Configuration"
4949
${sudo_ceph} ceph mgr module enable dashboard
5050
${sudo_ceph} ceph mgr module enable stats
51-
${sudo_ceph} ceph config set mgr mgr/dashboard/server_port 8080
52-
${sudo_ceph} ceph config set mgr mgr/dashboard/ssl false
53-
${sudo_ceph} ceph config set mon mon_warn_on_insecure_global_id_reclaim_allowed false
54-
# ${sudo_ceph} ceph restful create-self-signed-cert
51+
52+
ceph_config_set "mgr" "mgr/dashboard/server_port" "8080"
53+
ceph_config_set "mgr" "mgr/dashboard/ssl" "false"
54+
ceph_config_set "mon" "mon_warn_on_insecure_global_id_reclaim_allowed" "false"
5555

5656
if ! dashboard_user_exists "cephos"
5757
then

live_build_config/includes.chroot_after_packages/usr/local/lib/cephos/cephos.sh.lib

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function dashboard_user_exists()
6161

6262
function get_ceph_hosts()
6363
{
64-
ceph osd metadata -f json \
64+
${sudo_ceph} ceph osd metadata -f json \
6565
| jq -r '.[] | {host: .hostname, front: .front_addr, back: .back_addr}
6666
| [.host, (.front | capture("v2:(?<ip>[^:]+)") .ip // "-"),
6767
(.back | capture("v2:(?<ip>[^:]+)") .ip // "-")]
@@ -129,7 +129,6 @@ function disk_already_in_ceph()
129129
fi
130130
}
131131

132-
133132
function prepare_ceph_data()
134133
{
135134
log_verbose "Preparing data"
@@ -163,7 +162,6 @@ function prepare_ceph_data()
163162

164163
sudo_ceph="sudo --preserve-env"
165164

166-
# log_info "Main conf file: ${ceph_main_conf}"
167165
log_info "Ceph fsid: ${ceph_fsid}"
168166
log_info "Ceph id: [mon:${mon_id}], [mgr:${mgr_id}], [mds:${mds_id}]"
169167
}

live_build_config/includes.chroot_after_packages/usr/local/lib/cephos/config.sh.lib

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function write_to_ini()
1111

1212
sudo mkdir -p "$(dirname $inifile)"
1313

14-
log_verbose "Write '${section}.${variable} = ${value}' to ${inifile}"
14+
log_verbose "Write '${value}' to '${section}.${variable}' in ${inifile}"
1515
sudo crudini --set ${options} "${inifile}" "${section}" "${variable}" "${value}"
1616

1717
if (( $? ))
@@ -147,13 +147,29 @@ function ceph_conf_get()
147147
read_from_ini "${ceph_main_conf}" "${section}" "${variable}" "none"
148148
}
149149

150+
# Set value to ceph.conf
150151
function ceph_conf_set()
151152
{
152153
local section="$1"
153154
local variable="$2"
154155
local value="$3"
155156
write_to_ini "${ceph_main_conf}" "${section}" "${variable}" "${value}" ""
156157
}
158+
159+
# Set value to ceph distributed configuration
160+
function ceph_config_set()
161+
{
162+
local entity="$1"
163+
local key="$2"
164+
local value="$3"
165+
local force_flag="${4:-}"
166+
167+
if [[ "$force_flag" == "force" ]] || ! ceph config dump | grep -qE "^[[:space:]]*$entity[[:space:]].*[[:space:]]$key[[:space:]]"
168+
then
169+
log_verbose "Applying to [$entity:$key] new value: $value"
170+
ceph config set "$entity" "$key" "$value"
171+
fi
172+
}
157173
# ---=---
158174
function ceph_conf_get_list()
159175
{

0 commit comments

Comments
 (0)