跳到主內容

修復超過三個運算節點的叢集中的負載平衡器服務錯誤

摘要​

在 CubeCOS 3.0.0 版本中,當叢集擁有超過三個運算節點時,負載平衡即服務(LBaaS)可能錯誤地將其標示為「不健康」。

詳細資訊​

問題描述​

Octavia 工作節點僅設計於前三個運算節點上運行。 然而,健康檢查程式會評估所有運算節點。 當檢查超過前三個的運算節點時,系統會偵測到這些節點上未運行Octavia,並錯誤地將負載平衡即服務 LBaaS 標記為 unhealthy 狀態。

適用版本​

CubeCOS 3.0.0 及以上版本。

本文適用於運行 CubeCOS 3.0.0 或更新版本的環境。

決議​

修補 LBaaS 狀態監控程式​

  1. 開啟一個終端機工作階段。

  2. 請以 root 使用者身分透過 SSH 登入您的叢集管理 VIP。

    ssh root@<your-cluster-vip>
  3. 開啟健康監測設定檔以編輯負載平衡即服務 LBaaS 健康檢測。

    SDK 健康模組為 CubeCOS 服務提供健康檢查與自動化修復動作。 此指令將透過檔案編輯器開啟健康監測器的設定檔。

    vim /usr/lib/hex_sdk/modules/sdk_health.sh
  4. 找到Octavia健康狀態檢測功能

    1. 輸入 /health_octavia_check() 以搜尋 health_octavia_check 函式
    2. 按下 Enter 鍵
    3. 當 health_octavia_check() 函式被標示時,請檢視現有的邏輯。 您將修改此函式以防止虛假的 LBaaS 健康狀態錯誤。
  5. 更新計算節點檢查機制,使其僅驗證前三個計算節點上的 Octavia 服務。

    1. 在 health_octavia_check() 函式中,請將 Octavia 運算節點檢查包裹於以下條件中:

      if remote_run $node hex_sdk is_first_three_compute_node ; then
      ...
      fi
  6. 套用健康檢查的變更

    1. 定位設定錯誤記錄來源的行

      ERR_LOG="ip addr show"
    2. 找到緊接在這一行之後的 for 迴圈

      for node in "${CUBE_NODE_COMPUTE_HOSTNAMES[@]}" ; do
      ...
      done
  7. 請將條件邏輯加入此迴圈內,如下所示的差異:

    health_octavia_check()
    {
    stale_api_check_repair octavia-api 9876 octavia-api python3

    local http_stats=$(influx -host $(shared_id) -database monasca -format json -execute "select last(value) from http_status where service = 'octavia'" | jq .results[0].series[0].values[0][1])
    if [ "$http_stats" != "0" ] ; then
    ERR_CODE=1
    else
    for node in "${CUBE_NODE_CONTROL_HOSTNAMES[@]}" ; do
    if ! is_remote_running $node octavia-api ; then
    ERR_MSG+="octavia-api on $node is not running\n"
    ERR_CODE=3
    ERR_LOG="journalctl -n $ERR_LOGSIZE -u octavia-api"
    elif ! is_remote_running $node octavia-housekeeping ; then
    ERR_MSG+="octavia-housekeeping on $node is not running\n"
    ERR_CODE=4
    ERR_LOG="journalctl -n $ERR_LOGSIZE -u octavia-housekeeping"
    fi
    done
    ERR_LOG="ip addr show"
    for node in "${CUBE_NODE_COMPUTE_HOSTNAMES[@]}" ; do
    + if remote_run $node hex_sdk is_first_three_compute_node ; then
    + if ! remote_run $node ovs-vsctl port-to-br octavia-hm0 >/dev/null 2>&1 ; then
    + ERR_MSG+="no octavia-hm0 ovn port found on $node\n"
    + ERR_CODE=5
    + elif remote_run $node ip link show octavia-hm0 | grep -q DOWN ; then
    + ERR_MSG+="no link octavia-hm0 found on $node\n"
    + ERR_CODE=6
    + elif ! remote_run $node route -n | grep -q octavia-hm0 ; then
    + ERR_MSG+="no route from octavia-hm0 found on $node\n"
    + ERR_CODE=7
    + elif ! is_remote_running $node octavia-worker ; then
    + ERR_MSG+="octavia-worker on $node is not running\n"
    + ERR_CODE=8
    + elif ! is_remote_running $node octavia-health-manager ; then
    + ERR_MSG+="octavia-health-manager on $node is not running\n"
    + ERR_CODE=9
    + fi
    + fi
    - if ! remote_run $node ovs-vsctl port-to-br octavia-hm0 >/dev/null 2>&1 ; then
    - ERR_MSG+="no octavia-hm0 ovn port found on $node\n"
    - ERR_CODE=5
    - elif remote_run $node ip link show octavia-hm0 | grep -q DOWN ; then
    - ERR_MSG+="no link octavia-hm0 found on $node\n"
    - ERR_CODE=6
    - elif ! remote_run $node route -n | grep -q octavia-hm0 ; then
    - ERR_MSG+="no route from octavia-hm0 found on $node\n"
    - ERR_CODE=7
    - elif ! is_remote_running $node octavia-worker ; then
    - ERR_MSG+="octavia-worker on $node is not running\n"
    - ERR_CODE=8
    - elif ! is_remote_running $node octavia-health-manager ; then
    - ERR_MSG+="octavia-health-manager on $node is not running\n"
    - ERR_CODE=9
    - fi
    done
    fi

    _health_fail_log
    }
  8. 同步更新後的設定。

    儲存檔案後,將更新後的健康模組同步至所有運算與控制融合節點:

    cubectl node rsync /usr/lib/hex_sdk/modules/sdk_health.sh -r compute
  9. 驗證健康檢查修復方案。

  10. 手動執行健康檢查:

    hex_sdk health_octavia_check ; echo $?
  11. 若指令返回 0,表示修復已完成。 無需重新啟動服務或重新開機節點。