feat(cli): add --wait-timeout-sec to configure synchronous poll timeout (#119)#121
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
Fixes #119。同步任务轮询(等待资源到达目标状态,如创建集群/主机)的总超时此前被硬编码为 10 分钟(
pkg/cli/poller.go),无法调整,导致耗时 >10min 的同步创建必然超时。改动
SetDefaultPollTimeout(d)(忽略非正值,规避 SDK waiterTimeout==0直接报错的陷阱);NewPoller读取该默认值。三条 poller 创建路径(ctx.Poller/PollerTo、progress.Sspoll、cmd/api.gorepeats poller)均收敛到包级NewPoller,单点注入即全覆盖。--wait-timeout-sec(单位秒,0=用内置默认 600s),与既有--timeout-sec(单次 HTTP 请求超时)相互独立;启动时注入到 poller。--wait-timeout-sec 1800与--wait-timeout-sec=1800两种写法。兼容性
默认保持 10 分钟不变,未传 flag 时行为完全不变。
测试
pkg/cli:默认值 / 覆盖 / 非正值忽略 单测cmd:--wait-timeout-sec解析 helper 单测(空格 / 等号 / 边界 / 非法值,7 用例)go build/go vet/go test(cmd + pkg/cli)全绿说明
--wait-timeout-sec经applyGlobalOverrideFlags注册,遵循与现有全局 override flag 一致的排除规则(init/gendoc/config/auth)。