这是indexloc提供的服务,不要输入任何密码
Skip to content

Use hostIP for container-freezer #12162

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Oct 22, 2021

Conversation

psschwei
Copy link
Contributor

Proposed Changes

  • adds hostIP as an environmental variable on queue-proxy pod
  • lets concurrency-state-endpoint take a http://$HOST_IP:<port> endpoint value and swap in the actual host IP value

Release Note

Adds hostIP as an environmental variable on the queue-proxy pod. Also lets `concurrency-state-endpoint` take a  `http://$HOST_IP:<port>` endpoint value and swaps in the actual host IP value at runtime.

/assign @julz @markusthoemmes

@google-cla google-cla bot added the cla: yes Indicates the PR's author has signed the CLA. label Oct 21, 2021
@knative-prow-robot knative-prow-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. area/API API objects and controllers area/autoscale area/networking labels Oct 21, 2021
@codecov
Copy link

codecov bot commented Oct 21, 2021

Codecov Report

Merging #12162 (45696dd) into main (8c971a5) will increase coverage by 0.02%.
The diff coverage is 87.50%.

❗ Current head 45696dd differs from pull request most recent head 54bfa49. Consider uploading reports for the commit 54bfa49 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main   #12162      +/-   ##
==========================================
+ Coverage   87.41%   87.44%   +0.02%     
==========================================
  Files         196      196              
  Lines        9601     9615      +14     
==========================================
+ Hits         8393     8408      +15     
  Misses        930      930              
+ Partials      278      277       -1     
Impacted Files Coverage Δ
cmd/queue/main.go 0.50% <0.00%> (ø)
pkg/queue/concurrency_state.go 77.02% <85.71%> (+0.55%) ⬆️
pkg/reconciler/revision/resources/queue.go 98.19% <100.00%> (+0.06%) ⬆️
pkg/reconciler/revision/reconcile_resources.go 83.13% <0.00%> (+2.40%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8c971a5...54bfa49. Read the comment docs.

// setEndpoint swaps $HOST_IP into the user-provided endpoint if necessary,
// otherwise it returns the user-provided endpoint with no changes.
func (c *ConcurrencyEndpoint) setEndpoint(e string) error {
r := regexp.MustCompile("(http://|https://)?\\$HOST_IP:\\d\\d\\d\\d")
Copy link
Member

Choose a reason for hiding this comment

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

os.Expand might be a nicer way of doing this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a LOT nicer :)

@@ -114,7 +114,7 @@ type ConcurrencyEndpoint struct {

func NewConcurrencyEndpoint(e, m string) ConcurrencyEndpoint {
c := ConcurrencyEndpoint{
endpoint: e,
endpoint: os.ExpandEnv(e),
mountPath: m,
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to expand the whole env here, or just HOST_IP? (os.Expand will let us be more specific, I'm being paranoid about security of parroting any env var)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, that's a fair point. let me fix that

func NewConcurrencyEndpoint(e, m string) ConcurrencyEndpoint {
c := ConcurrencyEndpoint{
endpoint: e,
endpoint: os.Expand(e, mapper),
Copy link
Member

Choose a reason for hiding this comment

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

but of a nit but we don't really need the switch so I think this could be:

Suggested change
endpoint: os.Expand(e, mapper),
endpoint: os.Expand(e, func(s string) string {
if s == "HOST_IP" { return os.Getenv("HOST_IP") }
return "$" + s
}),

@psschwei
Copy link
Contributor Author

Prow unit tests passed but GH action one failed (and nothing was changed in pkg/reconciler/route, so think this is a flake)

failed test:
FAIL knative.dev/serving/pkg/reconciler/route 14.546s

Copy link
Member

@julz julz left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 22, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: julz, psschwei

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow-robot knative-prow-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2021
@knative-prow-robot knative-prow-robot merged commit a459514 into knative:main Oct 22, 2021
@psschwei psschwei deleted the add-host-ip-envvar branch October 22, 2021 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/API API objects and controllers area/autoscale area/networking cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants