Skip to content
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

various gcsweb updates #11176

Merged
merged 2 commits into from
Feb 7, 2019
Merged

various gcsweb updates #11176

merged 2 commits into from
Feb 7, 2019

Conversation

ixdy
Copy link
Member

@ixdy ixdy commented Feb 7, 2019

  • Add an option to upgrade connections to HTTPS (tested on http://gcsweb.ixdyland.net)
  • Build with go1.11.5
  • Rebase on gcr.io/distroless/static (instead of alpine)
  • Produce a manifest list for multiarch support

/assign @thockin

@k8s-ci-robot k8s-ci-robot added sig/testing Categorizes an issue or PR as relevant to SIG Testing. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Feb 7, 2019
@@ -111,6 +116,20 @@ func main() {
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *flPort), nil))
}

func upgradeToHTTPS(w http.ResponseWriter, r *http.Request, logger txnLogger) bool {
Copy link
Member

Choose a reason for hiding this comment

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

side note: we should consider putting this in a util or finding one, we have a very similar method in deck

Copy link
Member

Choose a reason for hiding this comment

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

[not blocking for this PR, but something down the line maybe...]

Copy link
Member Author

Choose a reason for hiding this comment

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

wow, no kidding.

// optionally inject http->https redirect handler when behind loadbalancer
if o.redirectHTTPTo != "" {
redirectMux := http.NewServeMux()
redirectMux.Handle("/", func(oldMux *http.ServeMux, host string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
if r.Header.Get("x-forwarded-proto") == "http" {
redirectURL, err := url.Parse(r.URL.String())
if err != nil {
logrus.Errorf("Failed to parse URL: %s.", r.URL.String())
http.Error(w, "Failed to perform https redirect.", http.StatusInternalServerError)
return
}
redirectURL.Scheme = "https"
redirectURL.Host = host
http.Redirect(w, r, redirectURL.String(), http.StatusMovedPermanently)
} else {
oldMux.ServeHTTP(w, r)
}
}
}(mux, o.redirectHTTPTo))
mux = redirectMux
}

I'm kinda impressed how I wrote almost exactly the same thing. (The deck implementation is cleverer by intercepting before any of the handler funcs are run, though. I couldn't quite figure out how to do that.)

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, that one's mine :+)

@@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

FROM ARG_FROM
FROM gcr.io/distroless/static

MAINTAINER Tim Hockin <thockin@google.com>
Copy link
Member

Choose a reason for hiding this comment

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

unrelated but MAINTAINER has long been deprecated, we just dropped these from the rest of our images in favor of OWNERS

Copy link
Member

@BenTheElder BenTheElder 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

@BenTheElder
Copy link
Member

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BenTheElder, ixdy

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

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 7, 2019
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 07f937942896b7711d0ead5f9559b1d4929c41d9

@k8s-ci-robot k8s-ci-robot merged commit 7d1d63c into kubernetes:master Feb 7, 2019
Copy link
Member

@thockin thockin left a comment

Choose a reason for hiding this comment

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

minor points, mostly.

One option for protocol upgrade would be to write a tiny sidecar container that listens on port X, does protocol upgrade if needed, otherwise proxies to localhost port Y. That way, anyone could just throw that into a pod and not change their apps.


all-push: all-push-images push-manifest

push-manifest:
Copy link
Member

Choose a reason for hiding this comment

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

I was (for a while) keeping this in sync with https://github.com/thockin/go-build-template which did a lot of what you have done here, but just epsilon differently. Would be nice to re-converge so fixes can be synced over time.

Copy link
Member Author

Choose a reason for hiding this comment

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

ah, I'd forgotten about that. can update to address.

all-push: all-push-images push-manifest

push-manifest:
docker manifest create --amend $(IMAGE):$(VERSION) $(shell echo $(ALL_ARCH) | sed -e "s~[^ ]*~$(IMAGE)\-&:$(VERSION)~g")
Copy link
Member

Choose a reason for hiding this comment

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

docker manifest has bugs in some versions, which produce invalid manifests. Except docker proper didn;t validate manifests until recently. But containerd does...

Copy link
Member Author

Choose a reason for hiding this comment

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

We've been using this flow in k/k for a while without issue, though we do have guards over there in a few places to ensure that you're using docker 18.06.0 or newer (where the bug was fixed).

Google workstations all have new enough docker that I'm not super worried about this.

@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash
Copy link
Member

Choose a reason for hiding this comment

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

why? does sh not exist? I would only say "bash" if we need bash-isms.

Copy link
Member Author

Choose a reason for hiding this comment

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

The golang image links /bin/sh to dash, which doesn't support things like set -o pipefail (apparently).

@@ -0,0 +1 @@
nobody:x:65534:65534:nobody:/nonexistent:/usr/sbin/nologin
Copy link
Member

Choose a reason for hiding this comment

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

Why not just echo this in Dockerfile - one less file in git? :)

Copy link
Member Author

Choose a reason for hiding this comment

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

The distroless image has no echo command. Also, running commands inside Dockerfiles gets trickier with multiarch (which is why I moved the chmod to the Makefile).

@thockin
Copy link
Member

thockin commented Feb 7, 2019 via email

@ixdy
Copy link
Member Author

ixdy commented Feb 7, 2019

I was considering adding a separate nginx pod which did the upgrade, but I wasn't sure how to get the GCLB to forward to a different pod. I hadn't considered using an nginx container, though that also feels a little heavyweight (GCLB -> nginx -> gcsweb binary).

might be worth looking into, though this approach here also works, so... 🤷

@ixdy
Copy link
Member Author

ixdy commented Feb 7, 2019

the golang:alpine images link /bin/sh to busybox, which apparently supports the bashisms. The non-alpine golang images are based on debian, I believe.

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. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. sig/testing Categorizes an issue or PR as relevant to SIG Testing. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants