Commit status: opt-in event message as description (spec.commitStatusDescriptionExpr)
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 38/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- github, go
- Lĩnh vực
- backend-api-design, devtools
Hướng nghiên cứu
Start with api/v1/provider_types.go and internal/server/provider_commit_status.go to trace how commitStatusExpr is declared and evaluated. Then follow event_handlers.go into internal/notifier/factory.go and the six commit status notifiers; the issue lists the proposed tests and docs/spec/v1/providers.md. Done means the optional expression is validated, unset or empty values preserve current descriptions, and custom descriptions are normalized and safely truncated to each provider's limit.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Git commit status providers (github, gitlab, gitea, bitbucket, bitbucketserver,
azuredevops) write only the event reason as the status description. For a failed
Kustomization the commit shows:
kustomization/apps — health check failed
while the event that triggered it carries the actual explanation:
health check failed after 5m0s: timeout waiting for: [HelmRelease/apps/podinfo status: 'InProgress': Helm upgrade failed for release apps/podinfo with chart [email protected]: context deadline exceeded]
(The kstatus part after 'InProgress' is proposed in fluxcd/pkg#1379; today the message ends
after the status.)
The description is built from the reason only
(util.go#L50-L56,
used by github.go#L75
and the other five commit status notifiers).
The commit status is often the only Flux output that application developers see. Pipelines
that wait for the commit status after a GitOps change and developers looking at the commit
both learn that the deployment failed, not why. Finding out needs cluster access, a UI or
a second notification channel, which many platform setups don't give to application teams.
spec.commitStatusExpr made the status context configurable. The description still
can't be changed.
Proposal
Add an optional CEL field to Provider (v1), next to commitStatusExpr:
apiVersion: notification.toolkit.fluxcd.io/v1
kind: Provider
metadata:
name: github
namespace: flux-system
spec:
type: github
address: https://github.com/org/repo
secretRef:
name: github-token
commitStatusDescriptionExpr: "event.message"
Semantics:
- Same environment as
commitStatusExpr: variablesevent,alertandprovider; the result
must be a string
(provider_commit_status.go#L34-L40). - The result is collapsed to one line (whitespace runs become a single space) and shortened
in the middle to the provider's description limit, e.g. 140 characters for GitHub (longer
descriptions are rejected with HTTP 422). Flux messages put the generic part first and the
concrete cause last, so keeping both ends keeps both: the 198-character message above
becomes
Truncation is rune-safe. Per-provider limits are constants next to each notifier; GitHub ishealth check failed after 5m0s: timeout waiting for: [HelmRelease/app…ease apps/podinfo with chart [email protected]: context deadline exceeded]
140. The limits of the other providers would be confirmed in the PR. - An empty result falls back to today's reason-based description, so expressions such as
event.severity == 'error' ? event.message : ''change only failures. - If the field is unset, behaviour is unchanged.
- Validation: the same
XValidationrule ascommitStatusExpr(commit status provider types
only,
provider_types.go#L66).
Open question: should an evaluation error drop the event, ascommitStatusExprdoes
today
(event_handlers.go#L462-L466),
or fall back to the default description and log? We would prefer the fallback, because a
status with the plain reason is better than no status at all.
Examples:
| Expression | Description on failure |
|---|---|
event.message |
the full message, shortened in the middle |
event.reason + ': ' + event.message |
reason first, then the message |
event.severity == 'error' ? event.message : '' |
message on failure, today's text on success |
Effect on deduplication and API usage
duplicateGithubStatus skips a write when the latest status with the same context has the
same state and description
(github.go#L111-L133).
Messages vary more than reasons (for example durations such as after 5m0s), so repeated
failures write a new status more often. That's still at most one write per forwarded event,
the same as a provider without deduplication, and the feature is opt-in. Conditional
requests (#977) are complementary.
Implementation sketch
| File | Change |
|---|---|
api/v1/provider_types.go |
CommitStatusDescriptionExpr string \json:"commitStatusDescriptionExpr,omitempty"`; extend the XValidationrule; regenerate CRDs and API docs. v1 only, likechangeRequestComment`, since v1beta3 is deprecated |
internal/server/provider_commit_status.go |
factor the CEL evaluation of newCommitStatus into a shared helper; add newCommitStatusDescription |
internal/server/event_handlers.go |
evaluate the description next to createCommitStatus (L457); pass it in prepareNotifier (L534-L535) |
internal/notifier/factory.go |
CommitStatusDescription field and WithCommitStatusDescription option, next to WithCommitStatus (L165-L170); hand it to the six commit status notifiers |
internal/notifier/util.go |
commitStatusDescription(event, custom string, limit int): default to formatNameAndDescription, else normalize and truncateMiddle |
github.go, gitlab.go, gitea.go, bitbucket.go, bitbucketserver.go, azure_devops.go |
use the helper instead of formatNameAndDescription |
| tests | truncateMiddle (ASCII, multi-byte, limit edges); per-notifier description and dedup; CEL cases in event_handlers_test.go like the existing commitStatusExpr table (L1197ff); API validation in provider_controller_test.go |
docs/spec/v1/providers.md |
new section after "Custom Commit Status Messages" (L2373ff) |
Alternatives considered
- Always send the message. That's a breaking change for existing statuses and
deduplication, so we don't propose it. - A plain switch (
commitStatusDescription: Reason|Message). It's simpler but less
flexible; we'd be fine with it if maintainers prefer. - PR comment providers (
githubpullrequestcommentand similar). They need change request
metadata on the event and cover preview environments, not commits on a deployed branch.
Context
We run Flux for many application teams who don't have cluster access. Today we work around
this with a small in-cluster component that writes the message into extra commit statuses.
We would like to drop it in favour of upstream support. I'll open a PR for this.
Related: #589 (extra information in the GitHub status; a maintainer was open to it), #977
(rate limiting), #1387 (per-context duplicate check, closed unmerged), #1434 (GitHub duplicate
check per context; touches the same notifier, independent of this proposal).
- Ngôn ngữ chính
- Go
- Star
- 182
- Fork
- 183
- Merge trung bình
- 9 giờ 20 phút
- Pull request đã merge (30 ngày)
- 26
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của fluxcd/notification-controller
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
fluxcd/notification-controller#1441 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/alerting area/api enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
fluxcd/notification-controller#1155 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Improve documentation on debugging the controller locallyCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mởarea/docs good first issue help wanted
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
fluxcd/notification-controller#362 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
fluxcd/notification-controller#1386 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 42/100
fluxcd/notification-controller#1371 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của fluxcd/notification-controller
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
OneBusAway/maglev#2145 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
priority/medium status/ready type/chore
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
discobox-ai/discobox#1357 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
TestPseudoLocaleRemote fails now and then: it types the code before the laptop asks for itCó thể đã có người làm @fzn0x đã nhận hôm nay. Đang mởbug priority: low
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
edit_file diff rendering panics on invalid UTF-8 textCó thể đã có người làm @TDnorthgarden đã nhận hôm nay. Đang mởarea/tui
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
docker/docker-agent#4955 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement ui/ux
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
jbigler/railswitch#243 ·
Maintainer thường phản hồi trong vòng 1 ngày