diff --git a/lib/gat/handler.go b/lib/gat/handler.go index 682cf657750c093f7674e8af32fd9ddb0c1a1979..f6519e35385ff8e18f138e0e8d4678e891301aac 100644 --- a/lib/gat/handler.go +++ b/lib/gat/handler.go @@ -10,7 +10,7 @@ import ( type Handler interface { // Handle will attempt to handle the Conn. Return io.EOF for normal disconnection or nil to continue to the next // handle. The error will be relayed to the client so there is no need to send it yourself. - Handle(ctx context.Context, conn *fed.Conn) error + Handle(conn *fed.Conn) error } type CancellableHandler interface { diff --git a/lib/gat/handlers/discovery/discoverers/google_cloud_sql/discoverer.go b/lib/gat/handlers/discovery/discoverers/google_cloud_sql/discoverer.go index fb3a1304065b51c940c47db9d62cff31eefb1304..fa6bd3ea41025c25ab20372160b206e552f03f36 100644 --- a/lib/gat/handlers/discovery/discoverers/google_cloud_sql/discoverer.go +++ b/lib/gat/handlers/discovery/discoverers/google_cloud_sql/discoverer.go @@ -1,6 +1,7 @@ package google_cloud_sql import ( + "context" "crypto/tls" "fmt" "net" @@ -101,7 +102,7 @@ func (T *Discoverer) instanceToCluster(primary *sqladmin.DatabaseInstance, repli var admin *fed.Conn defer func() { if admin != nil { - _ = admin.Close() + _ = admin.Close(context.Background()) } }() @@ -139,22 +140,23 @@ func (T *Discoverer) instanceToCluster(primary *sqladmin.DatabaseInstance, repli var b flip.Bank b.Queue(func() error { - return gsql.ExtendedQuery(inward, &result, "SELECT usename, passwd FROM pg_shadow WHERE usename=$1", user.Name) + return gsql.ExtendedQuery(context.Background(), inward, &result, "SELECT usename, passwd FROM pg_shadow WHERE usename=$1", user.Name) }) b.Queue(func() error { - initialPacket, err := outward.ReadPacket(true) + ctx := context.Background() + initialPacket, err := outward.ReadPacket(ctx, true) if err != nil { return err } - err, err2 := bouncers.Bounce(outward, admin, initialPacket) + err, err2 := bouncers.Bounce(ctx, outward, admin, initialPacket) if err != nil { return err } if err2 != nil { return err2 } - return outward.Close() + return outward.Close(ctx) }) if err = b.Wait(); err != nil { diff --git a/lib/gat/server.go b/lib/gat/server.go index ac87b910f3e1ad4b0e45a367b113e7f0965ad11c..2fe4460d500d712b065cff83e116c536ea6192b1 100644 --- a/lib/gat/server.go +++ b/lib/gat/server.go @@ -116,7 +116,7 @@ func (T *Server) Serve(ctx context.Context, conn *fed.Conn) { if route.handle == nil { continue } - err := route.handle.Handle(ctx,conn) + err := route.handle.Handle(conn) if err != nil { if errors.Is(err, io.EOF) { // normal closure