cloud-sql-proxy icon indicating copy to clipboard operation
cloud-sql-proxy copied to clipboard

Warn users running an old proxy version

Open enocom opened this issue 4 years ago • 2 comments

As we approach https://github.com/GoogleCloudPlatform/cloudsql-proxy/issues/872, we should add a warning message on startup for users who are running a version older than latest.

In terms of implementation, probably the simplest thing to do is add a text file into our GCS bucket that holds release binaries. As part of publishing new versions, we could update this text file.

enocom avatar Oct 25 '21 20:10 enocom

We could write the text file right after this line:

https://github.com/GoogleCloudPlatform/cloudsql-proxy/blob/d0036fe229c9902c0fb2305dcaf9bb1e05b5f2cb/.kokoro/release_artifacts.sh#L46.

enocom avatar Nov 02 '21 05:11 enocom

Another idea. We could just query the bucket, looking for the latest version with something like this:

package main

import (
	"context"
	"fmt"
	"strings"

	"cloud.google.com/go/storage"
	"google.golang.org/api/iterator"
)

func main() {
	ctx := context.Background()
	client, err := storage.NewClient(ctx)
	if err != nil {
		panic(err)
	}
	bkt := client.Bucket("cloudsql-proxy")

	var versions []string
	it := bkt.Objects(ctx, nil)
	for {
		attrs, err := it.Next()
		if err == iterator.Done {
			break
		}
		if err != nil {
			panic(err)
		}
		res := strings.Split(attrs.Name, "/")
		if len(res) != 2 {
			// malformed object key; skip it
			continue
		}
		version := res[0]
		if strings.HasSuffix(version, "-dev") {
			continue
		}
		versions = append(versions, version)

	}
	fmt.Println(versions[len(versions)-1])
}

enocom avatar Nov 03 '21 21:11 enocom

Closing this out as infeasible. We'll add a log message to v1 when we're ready. Otherwise, v2 won't have this feature.

enocom avatar Feb 14 '23 19:02 enocom