Skip to content

add info messages when starting override - #229

Merged
davixcky merged 4 commits into
mainfrom
add-info-message-override-start
Oct 29, 2025
Merged

davixcky merged 4 commits into
mainfrom
add-info-message-override-start

Conversation

@davixcky

@davixcky davixcky commented Oct 22, 2025 •

Copy link
Copy Markdown
Contributor

This resolves #227

@gitar-bot

gitar-bot Bot commented Oct 22, 2025 •

Copy link
Copy Markdown

Gitar analyzes/fixes CI failures, runs prompts as workflows and addresses comments starting with Gitar.

⚙️ Options:

  • Automatically accept changes

📝 Submit Feedback

Comment on lines +152 to +160
// Add policy message
policyMessage := fmt.Sprintf("Policy: HTTP/gRPC responses containing the 'sd-override: true' header will be intercepted by the local process for sandbox <%s>", cfg.Sandbox)
fmt.Fprintf(out, "%s\n", policyMessage)

if len(cfg.ExcludedStatusCodes) > 0 {
codes := strings.Trim(strings.Join(strings.Fields(fmt.Sprint(cfg.ExcludedStatusCodes)), ","), "[]")
excludedStatusCodesMessage := fmt.Sprintf("Override will not apply to responses with status codes: %s", codes)
fmt.Fprintf(out, "%s\n", excludedStatusCodesMessage)
}

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.

The policy explanation from here is not right, in particular check this case:

$ signadot local override --sandbox=test1 --workload=location --port=8081 --to=localhost:8000 --except-status 404
Waiting (up to --wait-timeout=3m0s) for sandbox to be ready...
✓ Sandbox status: Ready: All desired workloads are available.
✓ Override created port 8081 to localhost:8000
Policy: HTTP/gRPC responses containing the 'sd-override: true' header will be intercepted by the local process for sandbox <test1>
Override will not apply to responses with status codes: 404

That's not true, in that case, everything will be overriden, except the 404s (the user doesn't need to insert any sd-override: true in this case).

See the existing help:

By default, overrides apply when the response from the local service
includes the header 'sd-override: true'.

You can use the '--except-status' flag to specify HTTP response codes that
should not be overridden. When set, all other traffic will be overridden
except for the specified status codes

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

addressed in 2ff77a6

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.

Much better, but I don't think the wording is right.
What about something like:

  • Case 1:
    Policy: HTTP/gRPC responses from the local process that include the header sd-override: true will be overridden for sandbox test1.

  • Case 2:
    Policy: All HTTP/gRPC traffic will be overridden by the local process for sandbox test1, except responses with status code 404.

@foxish foxish Oct 24, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we can remove the prefix that says "Policy", but the rest looks good to me from @daniel-de-vera 's text above. Let's call it overridden, not "intercepted" etc.

@foxish foxish Oct 24, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually, something that seems a bit nicer to me is to combine the 2 messages (this one and the one above in https://github.com/signadot/cli/pull/229/files#diff-92d3d1666d17fbbdad2bd9f4ad27307fa016a76dfa83da57494e7b186b803bcaR150. Like:

Case 1: Header-Based Override

override has been set up successfully.
* If localhost:8080 responds with `sd-override: true` header
    -> Final response from: **localhost:8080**
* Default: (All other local responses)
    -> Final response from: **virtual-apiserver:80** (Sandbox)

Case 2: Status-Based Override

override has been set up successfully.
* If localhost:8080 responds with status 404
    -> Final response from: **virtual-apiserver:80** (Sandbox)
* Default: (All other local responses)
    -> Final response from: **localhost:8080**

WDYT @daniel-de-vera @davixcky

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.

Yes, that SGTM.

// Add policy message
if len(cfg.ExcludedStatusCodes) > 0 {
// When except-status is used, everything is overridden by default except specified status codes
policyMessage := fmt.Sprintf("Policy: All traffic will be overridden by the local process for sandbox <%s>", cfg.Sandbox)

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.

I would remove the "<" ">" surrounding the sandbox name.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

+1, please remove that

@daniel-de-vera daniel-de-vera 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

@davixcky
davixcky merged commit f1daa1f into main Oct 29, 2025
@davixcky
davixcky deleted the add-info-message-override-start branch October 29, 2025 19:25
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.

[CLI] override should print details about the override and the policy

3 participants