Skip to content

Show job GUID in service command progress hints - #3876

Merged
prkalle merged 2 commits into
cloudfoundry:mainfrom
sap-contributions:job-guid-service-hints
Oct 20, 2026
Merged

prkalle merged 2 commits into
cloudfoundry:mainfrom
sap-contributions:job-guid-service-hints

Conversation

@johha

@johha johha commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Note: This PR targets main. Backport for v8: #3877.

Description of the Change

Async service operations (create/update/delete/bind/unbind, and their keys) are carried out by a Cloud Controller job. The CLI has no first-class concept of a job - there is no cf jobs command - so once a command returns on the no-wait path, the user has no handle to the operation that is still running server-side. The job GUID is the only identifier that lets anyone inspect that work (via cf curl v3/jobs/<guid>), and today it is shown only when a job fails or times out (JobFailedError, JobTimeoutError).

This change surfaces the job GUID on the in-progress path as well. When a service command returns while the operation is still running (no --wait), it now prints an extra line after the existing status hint:

Delete in progress. Use 'cf services' or 'cf service my-si' to check operation status.
Job (87154c19-e709-4062-bc84-87f0cd2c3dd3) is being processed.
OK

Implementation:

  • Add a JobGUID field to PollJobEvent at both the ccv3 and v7action layers, mirroring how State/Err/Warnings are already threaded through those two structs. It is populated from the already-existing ccv3.Job.GUID.
  • shared.WaitForResult now returns the observed job GUID: (bool, error) → (bool, string, error) (internal helper, not a user-facing CLI change).
  • Add a small shared.DisplayJobHint(ui, jobGUID) helper that prints Job (<guid>) is being processed. and no-ops on an empty GUID.
  • Call it from the in-progress branch of the 11 service commands: bind-route-service, bind-service, cleanup-outdated-service-bindings, create-service, create-service-key, delete-service, delete-service-key, unbind-route-service, unbind-service, update-service, upgrade-service.

The hint is deliberately emitted per call site rather than centrally inside WaitForResult, because it is interleaved with each command's own command-specific text (e.g. the TIP: ...restage line in bind-service) and because delete/delete-org/delete-space intentionally do not show it. Those three delete commands always wait to completion (no no-wait path), so they only pick up the new return signature (_, _, err) and print nothing new.

No new flags, no reworded or removed existing output, and warning de-duplication behavior is unchanged.

Why Is This PR Valuable?

With recent CF API changes, service deletions and other async operations can take significantly longer depending on the service broker. Users increasingly hit "is it even being processed?", "why is it taking so long?", and "why did it fail?" - and the returned error alone is often not enough. The job GUID is the single traceable key to that information. It also helps operators: when a user reports "a command hangs forever" without -v logs or resource GUIDs, the job GUID is frequently the only thread an operator has to trace the operation in Cloud Controller.

Applicable Issues

How Urgent Is The Change?

Not urgent. Quality-of-life / supportability improvement.

Other Relevant Parties

CF operators who triage long-running or stuck service operations; users of the service lifecycle commands listed above.


Note: this PR was developed with AI assistance, with manual review and testing by the author.

@prkalle prkalle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment thread command/v7/shared/result_waiter.go Outdated
@johha
johha force-pushed the job-guid-service-hints branch from 995e9d6 to 9ff6bc5 Compare October 20, 2026 11:45
When an async service operation returns before completion (no --wait),
print the CC job GUID so users and operators can look it up via
'cf curl /v3/jobs/<guid>'.

The GUID is surfaced on the no-wait in-progress path only; it is
omitted when the operation completes synchronously or when --wait is
used (the command already exits with full status in those cases).
@johha
johha force-pushed the job-guid-service-hints branch 3 times, most recently from 6711c50 to cbdb767 Compare October 20, 2026 12:23
WaitForResult is an exported function; changing its return type from
(bool, error) to (bool, string, error) would break external callers.

Introduce WaitForResultWithJobGUID as the GUID-returning variant and
keep WaitForResult as a thin wrapper that delegates to it, preserving
the original signature. Update the 11 service commands that need the
GUID to call WaitForResultWithJobGUID directly.
@johha
johha force-pushed the job-guid-service-hints branch from cbdb767 to 558ac54 Compare October 20, 2026 12:27
@johha
johha requested a review from prkalle October 20, 2026 12:31

@prkalle prkalle left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for making the changes!

@prkalle
prkalle merged commit 28721d9 into cloudfoundry:main Oct 20, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants