diff --git a/client/witness/consensus_test.go b/client/witness/consensus_test.go index 380e05b..09b1864 100644 --- a/client/witness/consensus_test.go +++ b/client/witness/consensus_test.go @@ -20,10 +20,10 @@ import ( "os" "testing" - "github.com/golang/glog" "github.com/transparency-dev/formats/log" "github.com/transparency-dev/serverless-log/client" "golang.org/x/mod/sumdb/note" + "k8s.io/klog/v2" ) const ( @@ -151,7 +151,7 @@ func TestCheckpointNConsensus(t *testing.T) { t.Errorf("got CP:\n%s\nWant:\n%s", got, want) } }) - glog.Flush() + klog.Flush() } } diff --git a/cmd/client/client.go b/cmd/client/client.go index 1ac8669..3ec87ef 100644 --- a/cmd/client/client.go +++ b/cmd/client/client.go @@ -29,19 +29,19 @@ import ( "strconv" "strings" - "github.com/golang/glog" "github.com/transparency-dev/formats/log" "github.com/transparency-dev/merkle/proof" "github.com/transparency-dev/merkle/rfc6962" "github.com/transparency-dev/serverless-log/client" "github.com/transparency-dev/serverless-log/client/witness" "golang.org/x/mod/sumdb/note" + "k8s.io/klog/v2" ) func defaultCacheLocation() string { hd, err := os.UserCacheDir() if err != nil { - glog.Warningf("Failed to determine user cache dir: %q", err) + klog.Warningf("Failed to determine user cache dir: %q", err) return "" } return fmt.Sprintf("%s/serverless", hd) @@ -95,7 +95,7 @@ func main() { logSigV, _, err := logSigVerifier(*logPubKeyFile) if err != nil { - glog.Exitf("failed to read log public key: %v", err) + klog.Exitf("failed to read log public key: %v", err) } logID := *logID if logID == "" { @@ -104,7 +104,7 @@ func main() { u := *logURL if len(u) == 0 { - glog.Exitf("--log_url must be provided") + klog.Exitf("--log_url must be provided") } // url must reference a directory, by definition if !strings.HasSuffix(u, "/") { @@ -113,27 +113,27 @@ func main() { rootURL, err := url.Parse(u) if err != nil { - glog.Exitf("Invalid log URL: %v", err) + klog.Exitf("Invalid log URL: %v", err) } witnesses, err := witnessSigVerifiers(*witnessPubKeyFiles) if err != nil { - glog.Exitf("Failed to read witness pub keys: %v", err) + klog.Exitf("Failed to read witness pub keys: %v", err) } if want, got := *witnessSigsRequired, len(witnesses); want > got { - glog.Exitf("--witness_sigs_required=%d but only %d witnesses configured", want, got) + klog.Exitf("--witness_sigs_required=%d but only %d witnesses configured", want, got) } distribs, err := distributors() if err != nil { - glog.Exitf("Failed to create distributors list: %v", err) + klog.Exitf("Failed to create distributors list: %v", err) } f := newFetcher(rootURL) lc, err := newLogClientTool(ctx, logID, f, logSigV, witnesses, distribs) if err != nil { - glog.Exitf("Failed to create new client: %v", err) + klog.Exitf("Failed to create new client: %v", err) } args := flag.Args() @@ -151,13 +151,13 @@ func main() { usage() } if err != nil { - glog.Exitf("Command %q failed: %q", args[0], err) + klog.Exitf("Command %q failed: %q", args[0], err) } // Persist new view of log state, if required. if len(*cacheDir) > 0 { if err := storeLocalCheckpoint(logID, lc.Tracker.LatestConsistentRaw); err != nil { - glog.Exitf("Failed to persist local log state: %q", err) + klog.Exitf("Failed to persist local log state: %q", err) } } } @@ -180,16 +180,16 @@ func newLogClientTool(ctx context.Context, logID string, logFetcher client.Fetch return nil, fmt.Errorf("failed to load cached checkpoint: %q", err) } } else { - glog.Info("Local log state cache disabled") + klog.Info("Local log state cache disabled") } hasher := rfc6962.DefaultHasher var cons client.ConsensusCheckpointFunc if *witnessSigsRequired == 0 { - glog.V(1).Infof("witness_sigs_required is 0, using unilateral consensus") + klog.V(1).Infof("witness_sigs_required is 0, using unilateral consensus") cons = client.UnilateralConsensus(logFetcher) } else { - glog.V(1).Infof("witness_sigs_required > 0, using checkpoint.N consensus") + klog.V(1).Infof("witness_sigs_required > 0, using checkpoint.N consensus") cons, err = witness.CheckpointNConsensus(logID, distributors, witnesses, *witnessSigsRequired) if err != nil { return nil, fmt.Errorf("failed to create consensus func: %v", err) @@ -198,7 +198,7 @@ func newLogClientTool(ctx context.Context, logID string, logFetcher client.Fetch tracker, err := client.NewLogStateTracker(ctx, logFetcher, hasher, cpRaw, logSigV, *origin, cons) if err != nil { - glog.Warningf("%s", string(cpRaw)) + klog.Warningf("%s", string(cpRaw)) return nil, fmt.Errorf("failed to create LogStateTracker: %q", err) } @@ -236,7 +236,7 @@ func (l *logClientTool) consistencyProof(ctx context.Context, args []string) err return fmt.Errorf("failed to build consistency proof: %w", err) } - glog.V(1).Infof("Built consistency proof: %#x", p) + klog.V(1).Infof("Built consistency proof: %#x", p) if o := *outputConsistency; len(o) > 0 { if err := os.WriteFile(o, []byte(merkleProof(p).Marshal()), 0644); err != nil { @@ -294,7 +294,7 @@ func (l *logClientTool) inclusionProofArgs(ctx context.Context, args []string) ( if err != nil { return nil, 0, fmt.Errorf("failed to lookup leaf index: %w", err) } - glog.Infof("Leaf %q found at index %d", args[0], idx) + klog.Infof("Leaf %q found at index %d", args[0], idx) } return lh, idx, nil @@ -319,7 +319,7 @@ func (l *logClientTool) inclusionProof(ctx context.Context, args []string) error return fmt.Errorf("failed to get inclusion proof: %w", err) } - glog.V(1).Infof("Built inclusion proof: %#x", p) + klog.V(1).Infof("Built inclusion proof: %#x", p) if err := proof.VerifyInclusion(l.Hasher, idx, cp.Size, lh, p, cp.Hash); err != nil { return fmt.Errorf("failed to verify inclusion proof: %q", err) @@ -328,11 +328,11 @@ func (l *logClientTool) inclusionProof(ctx context.Context, args []string) error if o := *outputInclusion; len(o) > 0 { ps := []byte(merkleProof(p).Marshal()) if err := os.WriteFile(o, ps, 0644); err != nil { - glog.Warningf("Failed to write inclusion proof to %q: %v", o, err) + klog.Warningf("Failed to write inclusion proof to %q: %v", o, err) } } - glog.Infof("Inclusion verified under checkpoint:\n%s", cp.Marshal()) + klog.Infof("Inclusion verified under checkpoint:\n%s", cp.Marshal()) return nil } @@ -341,7 +341,7 @@ func (l *logClientTool) updateCheckpoint(ctx context.Context, args []string) err return fmt.Errorf("usage: update") } - glog.V(1).Infof("Original checkpoint:\n%s", l.Tracker.LatestConsistentRaw) + klog.V(1).Infof("Original checkpoint:\n%s", l.Tracker.LatestConsistentRaw) cp := l.Tracker.LatestConsistent _, p, newCPRaw, err := l.Tracker.Update(ctx) @@ -351,22 +351,22 @@ func (l *logClientTool) updateCheckpoint(ctx context.Context, args []string) err if o := *outputCheckpoint; len(o) > 0 { if err := os.WriteFile(o, newCPRaw, 0644); err != nil { - glog.Warningf("Failed to write latest checkpint to %q: %v", o, err) + klog.Warningf("Failed to write latest checkpint to %q: %v", o, err) } } if lcp := l.Tracker.LatestConsistent; lcp.Size == cp.Size { - glog.Info("Log hasn't grown, nothing to update.") + klog.Info("Log hasn't grown, nothing to update.") return nil } if o := *outputConsistency; len(o) > 0 { if err := os.WriteFile(o, []byte(merkleProof(p).Marshal()), 0644); err != nil { - glog.Warningf("Failed to write consistency proof to %q: %v", o, err) + klog.Warningf("Failed to write consistency proof to %q: %v", o, err) } } - glog.Infof("Updated checkpoint:\n%s", l.Tracker.LatestConsistentRaw) + klog.Infof("Updated checkpoint:\n%s", l.Tracker.LatestConsistentRaw) return nil } @@ -406,7 +406,7 @@ func readHTTP(ctx context.Context, u *url.URL) ([]byte, error) { } switch resp.StatusCode { case 404: - glog.Infof("Not found: %q", u.String()) + klog.Infof("Not found: %q", u.String()) return nil, os.ErrNotExist case 200: break @@ -415,7 +415,7 @@ func readHTTP(ctx context.Context, u *url.URL) ([]byte, error) { } defer func() { if err := resp.Body.Close(); err != nil { - glog.Errorf("resp.Body.Close(): %v", err) + klog.Errorf("resp.Body.Close(): %v", err) } }() return io.ReadAll(resp.Body) @@ -476,10 +476,10 @@ func witnessSigVerifiers(fs []string) ([]note.Verifier, error) { if err != nil { return nil, err } - glog.V(1).Infof("Found witness %q", v.Name()) + klog.V(1).Infof("Found witness %q", v.Name()) vs = append(vs, v) } - glog.V(1).Infof("Found %d witnesses", len(vs)) + klog.V(1).Infof("Found %d witnesses", len(vs)) return vs, nil } diff --git a/cmd/generate_keys/main.go b/cmd/generate_keys/main.go index 9ce1f89..4285413 100644 --- a/cmd/generate_keys/main.go +++ b/cmd/generate_keys/main.go @@ -21,8 +21,8 @@ import ( "fmt" "os" - "github.com/golang/glog" "golang.org/x/mod/sumdb/note" + "k8s.io/klog/v2" ) var ( @@ -36,18 +36,18 @@ func main() { flag.Parse() if len(*keyName) == 0 { - glog.Exit("--key_name required") + klog.Exit("--key_name required") } if !(*print) { if len(*outPriv) == 0 || len(*outPub) == 0 { - glog.Exit("--print and/or --out_priv and --out_pub required.") + klog.Exit("--print and/or --out_priv and --out_pub required.") } } skey, vkey, err := note.GenerateKey(rand.Reader, *keyName) if err != nil { - glog.Exitf("Unable to create key: %q", err) + klog.Exitf("Unable to create key: %q", err) } if *print { @@ -57,10 +57,10 @@ func main() { if len(*outPriv) > 0 && len(*outPub) > 0 { if err := writeFileIfNotExists(*outPriv, skey); err != nil { - glog.Exit(err) + klog.Exit(err) } if err := writeFileIfNotExists(*outPub, vkey); err != nil { - glog.Exit(err) + klog.Exit(err) } } } diff --git a/cmd/integrate/main.go b/cmd/integrate/main.go index 536fd16..c3c59c1 100644 --- a/cmd/integrate/main.go +++ b/cmd/integrate/main.go @@ -22,11 +22,11 @@ import ( "fmt" "os" - "github.com/golang/glog" "github.com/transparency-dev/merkle/rfc6962" "github.com/transparency-dev/serverless-log/internal/storage/fs" "github.com/transparency-dev/serverless-log/pkg/log" "golang.org/x/mod/sumdb/note" + "k8s.io/klog/v2" fmtlog "github.com/transparency-dev/formats/log" ) @@ -44,7 +44,7 @@ func main() { ctx := context.Background() if len(*origin) == 0 { - glog.Exitf("Please set --origin flag to log identifier.") + klog.Exitf("Please set --origin flag to log identifier.") } h := rfc6962.DefaultHasher @@ -54,12 +54,12 @@ func main() { if len(*pubKeyFile) > 0 { pubKey, err = getKeyFile(*pubKeyFile) if err != nil { - glog.Exitf("Unable to get public key: %q", err) + klog.Exitf("Unable to get public key: %q", err) } } else { pubKey = os.Getenv("SERVERLESS_LOG_PUBLIC_KEY") if len(pubKey) == 0 { - glog.Exit("Supply public key file path using --public_key or set SERVERLESS_LOG_PUBLIC_KEY environment variable") + klog.Exit("Supply public key file path using --public_key or set SERVERLESS_LOG_PUBLIC_KEY environment variable") } } // Read log private key from file or environment variable @@ -67,31 +67,31 @@ func main() { if len(*privKeyFile) > 0 { privKey, err = getKeyFile(*privKeyFile) if err != nil { - glog.Exitf("Unable to get private key: %q", err) + klog.Exitf("Unable to get private key: %q", err) } } else { privKey = os.Getenv("SERVERLESS_LOG_PRIVATE_KEY") if len(privKey) == 0 { - glog.Exit("Supply private key file path using --private_key or set SERVERLESS_LOG_PUBLIC_KEY environment variable") + klog.Exit("Supply private key file path using --private_key or set SERVERLESS_LOG_PUBLIC_KEY environment variable") } } var cpNote note.Note s, err := note.NewSigner(privKey) if err != nil { - glog.Exitf("Failed to instantiate signer: %q", err) + klog.Exitf("Failed to instantiate signer: %q", err) } if *initialise { st, err := fs.Create(*storageDir) if err != nil { - glog.Exitf("Failed to create log: %q", err) + klog.Exitf("Failed to create log: %q", err) } cp := fmtlog.Checkpoint{ Hash: h.EmptyRoot(), } if err := signAndWrite(ctx, &cp, cpNote, s, st); err != nil { - glog.Exitf("Failed to sign: %q", err) + klog.Exitf("Failed to sign: %q", err) } os.Exit(0) } @@ -99,35 +99,35 @@ func main() { // init storage cpRaw, err := fs.ReadCheckpoint(*storageDir) if err != nil { - glog.Exitf("Failed to read log checkpoint: %q", err) + klog.Exitf("Failed to read log checkpoint: %q", err) } // Check signatures v, err := note.NewVerifier(pubKey) if err != nil { - glog.Exitf("Failed to instantiate Verifier: %q", err) + klog.Exitf("Failed to instantiate Verifier: %q", err) } cp, _, _, err := fmtlog.ParseCheckpoint(cpRaw, *origin, v) if err != nil { - glog.Exitf("Failed to open Checkpoint: %q", err) + klog.Exitf("Failed to open Checkpoint: %q", err) } st, err := fs.Load(*storageDir, cp.Size) if err != nil { - glog.Exitf("Failed to load storage: %q", err) + klog.Exitf("Failed to load storage: %q", err) } // Integrate new entries newCp, err := log.Integrate(ctx, cp.Size, st, h) if err != nil { - glog.Exitf("Failed to integrate: %q", err) + klog.Exitf("Failed to integrate: %q", err) } if newCp == nil { - glog.Exit("Nothing to integrate") + klog.Exit("Nothing to integrate") } err = signAndWrite(ctx, newCp, cpNote, s, st) if err != nil { - glog.Exitf("Failed to sign: %q", err) + klog.Exitf("Failed to sign: %q", err) } } diff --git a/cmd/sequence/main.go b/cmd/sequence/main.go index b8338a2..78aa043 100644 --- a/cmd/sequence/main.go +++ b/cmd/sequence/main.go @@ -27,9 +27,9 @@ import ( "github.com/transparency-dev/serverless-log/internal/storage/fs" "golang.org/x/mod/sumdb/note" - "github.com/golang/glog" "github.com/transparency-dev/merkle/rfc6962" "github.com/transparency-dev/serverless-log/pkg/log" + "k8s.io/klog/v2" fmtlog "github.com/transparency-dev/formats/log" ) @@ -49,22 +49,22 @@ func main() { if len(*pubKeyFile) > 0 { k, err := os.ReadFile(*pubKeyFile) if err != nil { - glog.Exitf("failed to read public_key file: %q", err) + klog.Exitf("failed to read public_key file: %q", err) } pubKey = string(k) } else { pubKey = os.Getenv("SERVERLESS_LOG_PUBLIC_KEY") if len(pubKey) == 0 { - glog.Exit("supply public key file path using --public_key or set SERVERLESS_LOG_PUBLIC_KEY environment variable") + klog.Exit("supply public key file path using --public_key or set SERVERLESS_LOG_PUBLIC_KEY environment variable") } } toAdd, err := filepath.Glob(*entries) if err != nil { - glog.Exitf("Failed to glob entries %q: %q", *entries, err) + klog.Exitf("Failed to glob entries %q: %q", *entries, err) } if len(toAdd) == 0 { - glog.Exit("Sequence must be run with at least one valid entry") + klog.Exit("Sequence must be run with at least one valid entry") } h := rfc6962.DefaultHasher @@ -72,22 +72,22 @@ func main() { cpRaw, err := fs.ReadCheckpoint(*storageDir) if err != nil { - glog.Exitf("Failed to read log checkpoint: %q", err) + klog.Exitf("Failed to read log checkpoint: %q", err) } // Check signatures v, err := note.NewVerifier(pubKey) if err != nil { - glog.Exitf("Failed to instantiate Verifier: %q", err) + klog.Exitf("Failed to instantiate Verifier: %q", err) } cp, _, _, err := fmtlog.ParseCheckpoint(cpRaw, *origin, v) if err != nil { - glog.Exitf("Failed to parse Checkpoint: %q", err) + klog.Exitf("Failed to parse Checkpoint: %q", err) } st, err := fs.Load(*storageDir, cp.Size) if err != nil { - glog.Exitf("Failed to load storage: %q", err) + klog.Exitf("Failed to load storage: %q", err) } // sequence entries @@ -105,7 +105,7 @@ func main() { for _, fp := range toAdd { b, err := os.ReadFile(fp) if err != nil { - glog.Exitf("Failed to read entry file %q: %q", fp, err) + klog.Exitf("Failed to read entry file %q: %q", fp, err) } entries <- entryInfo{name: fp, b: b} } @@ -121,13 +121,13 @@ func main() { if errors.Is(err, log.ErrDupeLeaf) { dupe = true } else { - glog.Exitf("failed to sequence %q: %q", entry.name, err) + klog.Exitf("failed to sequence %q: %q", entry.name, err) } } l := fmt.Sprintf("%d: %v", seq, entry.name) if dupe { l += " (dupe)" } - glog.Info(l) + klog.Info(l) } } diff --git a/experimental/gcp-log/gcs_uploader/go.sum b/experimental/gcp-log/gcs_uploader/go.sum index ef361e4..ee0a779 100644 --- a/experimental/gcp-log/gcs_uploader/go.sum +++ b/experimental/gcp-log/gcs_uploader/go.sum @@ -30,7 +30,7 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +k8s.io/klog/v2 v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/experimental/gcp-log/go.mod b/experimental/gcp-log/go.mod index 69ca9c8..e3d9aa9 100644 --- a/experimental/gcp-log/go.mod +++ b/experimental/gcp-log/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( cloud.google.com/go/storage v1.33.0 - github.com/golang/glog v1.1.2 + k8s.io/klog/v2 v1.1.2 github.com/transparency-dev/serverless v0.0.0-20230612102034-f5649fd8da9c github.com/transparency-dev/formats v0.0.0-20230607101544-c064fae4cff6 github.com/transparency-dev/merkle v0.0.2 diff --git a/experimental/gcp-log/go.sum b/experimental/gcp-log/go.sum index 3151371..da2f34e 100644 --- a/experimental/gcp-log/go.sum +++ b/experimental/gcp-log/go.sum @@ -19,9 +19,9 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +k8s.io/klog/v2 v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +k8s.io/klog/v2 v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= +k8s.io/klog/v2 v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= diff --git a/experimental/gcp-log/internal/storage/storage.go b/experimental/gcp-log/internal/storage/storage.go index b099d62..1288e41 100644 --- a/experimental/gcp-log/internal/storage/storage.go +++ b/experimental/gcp-log/internal/storage/storage.go @@ -25,12 +25,12 @@ import ( "path/filepath" "strconv" - "github.com/golang/glog" "github.com/transparency-dev/serverless-log/api" "github.com/transparency-dev/serverless-log/api/layout" "github.com/transparency-dev/serverless-log/pkg/log" "google.golang.org/api/googleapi" "google.golang.org/api/iterator" + "k8s.io/klog/v2" gcs "cloud.google.com/go/storage" ) @@ -339,7 +339,7 @@ func (c *Client) Sequence(ctx context.Context, leafhash []byte, leaf []byte) (ui // stored with a .xx suffix where xx is the number of "tile leaves" in hex. func (c *Client) StoreTile(ctx context.Context, level, index uint64, tile *api.Tile) error { tileSize := uint64(tile.NumLeaves) - glog.V(2).Infof("StoreTile: level %d index %x ts: %x", level, index, tileSize) + klog.V(2).Infof("StoreTile: level %d index %x ts: %x", level, index, tileSize) if tileSize == 0 || tileSize > 256 { return fmt.Errorf("tileSize %d must be > 0 and <= 256", tileSize) } diff --git a/go.mod b/go.mod index baeb23d..2fb5270 100644 --- a/go.mod +++ b/go.mod @@ -3,10 +3,12 @@ module github.com/transparency-dev/serverless-log go 1.20 require ( - github.com/golang/glog v1.1.2 github.com/google/go-cmp v0.5.9 github.com/transparency-dev/formats v0.0.0-20230914071414-5732692f1e50 github.com/transparency-dev/merkle v0.0.2 golang.org/x/mod v0.12.0 golang.org/x/sync v0.3.0 + k8s.io/klog/v2 v2.100.1 ) + +require github.com/go-logr/logr v1.2.0 // indirect diff --git a/go.sum b/go.sum index 30c2b93..15f0a19 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/golang/glog v1.1.2 h1:DVjP2PbBOzHyzA+dn3WhHIq4NdVu3Q+pvivFICf/7fo= -github.com/golang/glog v1.1.2/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ= +github.com/go-logr/logr v1.2.0 h1:QK40JKJyMdUDz+h+xvCsru/bJhvG0UxvePV0ufL/AcE= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/transparency-dev/formats v0.0.0-20230914071414-5732692f1e50 h1:FVMl+jA2NBlbUm5XjLJNMrSLqbA/SpeXhKoirj3MMwg= @@ -10,3 +10,5 @@ golang.org/x/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc= golang.org/x/mod v0.12.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E= golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y= +k8s.io/klog/v2 v2.100.1 h1:7WCHKK6K8fNhTqfBhISHQ97KrnJNFZMcQvKp7gP/tmg= +k8s.io/klog/v2 v2.100.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= diff --git a/integration/integration.go b/integration/integration.go index 398e59c..d4e1243 100644 --- a/integration/integration.go +++ b/integration/integration.go @@ -20,13 +20,13 @@ import ( "fmt" "testing" - "github.com/golang/glog" "github.com/transparency-dev/merkle" "github.com/transparency-dev/merkle/proof" "github.com/transparency-dev/merkle/rfc6962" "github.com/transparency-dev/serverless-log/client" "github.com/transparency-dev/serverless-log/pkg/log" "golang.org/x/mod/sumdb/note" + "k8s.io/klog/v2" fmtlog "github.com/transparency-dev/formats/log" ) @@ -50,7 +50,7 @@ func RunIntegration(t *testing.T, s log.Storage, f client.Fetcher, lh *rfc6962.H // Create signature verifier v, err := note.NewVerifier(pubKey) if err != nil { - glog.Exitf("Unable to create new verifier: %q", err) + klog.Exitf("Unable to create new verifier: %q", err) } lst, err := client.NewLogStateTracker(ctx, f, lh, nil, v, integrationOrigin, client.UnilateralConsensus(f)) @@ -59,7 +59,7 @@ func RunIntegration(t *testing.T, s log.Storage, f client.Fetcher, lh *rfc6962.H } for i := 0; i < loops; i++ { - glog.Infof("----------------%d--------------", i) + klog.Infof("----------------%d--------------", i) checkpoint := lst.LatestConsistent // Sequence some leaves: diff --git a/internal/storage/fs/fs.go b/internal/storage/fs/fs.go index 8633e46..1117179 100644 --- a/internal/storage/fs/fs.go +++ b/internal/storage/fs/fs.go @@ -24,10 +24,10 @@ import ( "path/filepath" "strconv" - "github.com/golang/glog" "github.com/transparency-dev/serverless-log/api" "github.com/transparency-dev/serverless-log/api/layout" "github.com/transparency-dev/serverless-log/pkg/log" + "k8s.io/klog/v2" ) const ( @@ -155,7 +155,7 @@ func (fs *Storage) Sequence(ctx context.Context, leafhash []byte, leaf []byte) ( } defer func() { if err := os.Remove(leafTmp); err != nil { - glog.Errorf("os.Remove(): %v", err) + klog.Errorf("os.Remove(): %v", err) } }() // Link the temporary file in place, if it already exists we likely crashed after @@ -186,7 +186,7 @@ func (fs *Storage) Assign(_ context.Context, seq uint64, leaf []byte) error { } defer func() { if err := os.Remove(tmp); err != nil { - glog.Errorf("os.Remove(): %v", err) + klog.Errorf("os.Remove(): %v", err) } }() @@ -270,7 +270,7 @@ func (fs *Storage) GetTile(_ context.Context, level, index, logSize uint64) (*ap // stored with a .xx suffix where xx is the number of "tile leaves" in hex. func (fs *Storage) StoreTile(_ context.Context, level, index uint64, tile *api.Tile) error { tileSize := uint64(tile.NumLeaves) - glog.V(2).Infof("StoreTile: level %d index %x ts: %x", level, index, tileSize) + klog.V(2).Infof("StoreTile: level %d index %x ts: %x", level, index, tileSize) if tileSize == 0 || tileSize > 256 { return fmt.Errorf("tileSize %d must be > 0 and <= 256", tileSize) } @@ -302,7 +302,7 @@ func (fs *Storage) StoreTile(_ context.Context, level, index uint64, tile *api.T } // Clean up old partial tiles by symlinking them to the new full tile. for _, p := range partials { - glog.V(2).Infof("relink partial %s to %s", p, tPath) + klog.V(2).Infof("relink partial %s to %s", p, tPath) // We have to do a little dance here to get POSIX atomicity: // 1. Create a new temporary symlink to the full tile // 2. Rename the temporary symlink over the top of the old partial tile diff --git a/pkg/log/integrate.go b/pkg/log/integrate.go index f224232..dd8485b 100644 --- a/pkg/log/integrate.go +++ b/pkg/log/integrate.go @@ -22,13 +22,13 @@ import ( "fmt" "os" - "github.com/golang/glog" "github.com/transparency-dev/formats/log" "github.com/transparency-dev/merkle" "github.com/transparency-dev/merkle/compact" "github.com/transparency-dev/serverless-log/api" "github.com/transparency-dev/serverless-log/api/layout" "github.com/transparency-dev/serverless-log/client" + "k8s.io/klog/v2" ) // Storage represents the set of functions needed by the log tooling. @@ -91,7 +91,7 @@ func Integrate(ctx context.Context, fromSize uint64, st Storage, h merkle.LogHas return nil, fmt.Errorf("invalid log state, unable to recalculate root: %w", err) } - glog.Infof("Loaded state with roothash %x", r) + klog.Infof("Loaded state with roothash %x", r) // Create a new compact range which represents the update to the tree newRange := rf.NewEmptyRange(fromSize) @@ -110,7 +110,7 @@ func Integrate(ctx context.Context, fromSize uint64, st Storage, h merkle.LogHas return nil, fmt.Errorf("error while integrating: %w", err) } if n == 0 { - glog.Infof("Nothing to do.") + klog.Infof("Nothing to do.") // Nothing to do, nothing done. return nil, nil } @@ -129,7 +129,7 @@ func Integrate(ctx context.Context, fromSize uint64, st Storage, h merkle.LogHas // All calculation is now complete, all that remains is to store the new // tiles and updated log state. - glog.Infof("New log state: size 0x%x hash: %x", baseRange.End(), newRoot) + klog.Infof("New log state: size 0x%x hash: %x", baseRange.End(), newRoot) for k, t := range tc.m { if err := st.StoreTile(ctx, k.level, k.index, t); err != nil { @@ -198,7 +198,7 @@ func (tc tileCache) Visit(id compact.NodeID, hash []byte) { Nodes: make([][]byte, 0, 256*2), } } - glog.V(2).Infof("GetTile: %v new: %v", tileKey, created) + klog.V(2).Infof("GetTile: %v new: %v", tileKey, created) tc.m[tileKey] = tile } // Update the tile with the new node hash. diff --git a/testonly/mem_storage.go b/testonly/mem_storage.go index b21dc56..3c264dc 100644 --- a/testonly/mem_storage.go +++ b/testonly/mem_storage.go @@ -22,7 +22,7 @@ import ( "strconv" "sync" - "github.com/golang/glog" + "k8s.io/klog/v2" "github.com/transparency-dev/serverless-log/api" "github.com/transparency-dev/serverless-log/api/layout" @@ -73,7 +73,7 @@ func (ms *MemStorage) StoreTile(_ context.Context, level, index uint64, tile *ap tileSize := uint64(tile.NumLeaves) d, k := layout.TilePath("", level, index, tileSize%256) - glog.Infof("Store tile %s", filepath.Join(d, k)) + klog.Infof("Store tile %s", filepath.Join(d, k)) ms.fs[filepath.Join(d, k)] = t return nil } @@ -128,7 +128,7 @@ func (ms *MemStorage) Fetcher() client.Fetcher { return func(_ context.Context, path string) ([]byte, error) { ms.Lock() defer ms.Unlock() - glog.Infof("Fetch %s", path) + klog.Infof("Fetch %s", path) r, ok := ms.fs[path] if !ok { return nil, os.ErrNotExist