Pricing guide documents a custom file path that the loader ignores

未關閉 適合新手
#2,225 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
1/5
預估耗時
1-3 小時
新手友好度
88/100
Issue 類型
文件
描述清晰度
描述清楚
活躍度
活躍
領域
documentation

研究方向

開啟 docs/compute/pricing.rst,檢視 issue 中提到的「Using a custom pricing file」和「Updating pricing」章節。修正自訂價格檔案的路徑,使其與載入器一致,並將下載來源的說明與 issue 中註明的目前預設值保持一致。完成標準是,所有三處路徑參照和過時的下載來源說明都準確反映這些預設值。

由索引模型根據 Issue 內容生成。

描述

Summary

The pricing guide tells users to put custom pricing in ~/.libcloud.pricing.json, but Libcloud reads ~/.libcloud/pricing.json. Following the documented setup leaves the custom data unused.

At current trunk 8a0ef6260680625d54fce5093d2315e0926a7dc9, the incorrect path appears twice under Using a custom pricing file and once under Updating pricing in docs/compute/pricing.rst.

Detailed Information

Reproduced with Python 3.12 on Linux using unchanged Libcloud 4.0.0.dev0. This uses temporary directories and fresh subprocesses, so an existing home-directory file or in-memory pricing cache does not affect the result. No cloud service or pricing-data download is involved.

import json
import os
import subprocess
import sys
import tempfile
from pathlib import Path

probe = '''
from libcloud import pricing
path = pricing.get_pricing_file_path()
print("selected", "custom" if path == pricing.CUSTOM_PRICING_FILE_PATH else "bundled")
try:
    print("price", pricing.get_size_price("compute", "local_probe", "small"))
except KeyError:
    print("custom driver unavailable")
'''

with tempfile.TemporaryDirectory() as tmp:
    home = Path(tmp)
    content = json.dumps({"compute": {"local_probe": {"small": 0.125}}, "storage": {}})
    (home / ".libcloud.pricing.json").write_text(content)
    env = dict(os.environ, HOME=tmp)
    subprocess.run([sys.executable, "-c", probe], env=env, check=True)
    # selected bundled
    # custom driver unavailable

    (home / ".libcloud").mkdir()
    (home / ".libcloud" / "pricing.json").write_text(content)
    subprocess.run([sys.executable, "-c", probe], env=env, check=True)
    # selected custom
    # price 0.125

The expected documentation path is ~/.libcloud/pricing.json, matching CUSTOM_PRICING_FILE_PATH, get_pricing_file_path() and the existing upgrade notes. With the documented dot-separated path, the loader silently falls back to bundled data; for this synthetic custom-only driver the lookup then raises KeyError.

The Updating pricing paragraph also says the default download source is the git repository, while the function currently defaults to DEFAULT_FILE_URL_S3_BUCKET; the preceding section already describes that S3 service. It would be useful to bring that paragraph into line with the current defaults at the same time.

This is a documentation report, not a change to actual prices or a claim about provider billing. No full test suite or live download was run.

主要語言
Python
星號
2.1k
分支
935
平均合併
5 天 3 小時
30 天內合併 PR
15

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

apache/libcloud 的其他 Issue

查看 apache/libcloud 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。