Etcd: module declares its path as: go.etcd.io/bbolt,but was required as: github.com/coreos/bbolt

Created on 5 Apr 2020  ·  18Comments  ·  Source: etcd-io/etcd

my code:

package main

import (
    "context"
    "encoding/json"
    "fmt"
    "log"
    "os"
    "os/signal"
    "syscall"
    "time"

    "go.etcd.io/etcd/v3/clientv3"
)

var endPoints = []string{
    "192.168.0.11:2379",
    //  "192.168.0.12:2379",
    //   "192.168.0.13:2379",
}

var wait = 3 * time.Second

func main() {
    log.Println("test etcd")
    cli, err := clientv3.New(clientv3.Config{
        Endpoints:   endPoints,
        DialTimeout: 5 * time.Second,
    })

    if err != nil {
        // handle error
        log.Fatalln("etcd connection error: ", err)
    }

    defer cli.Close()

    // 设置超时
    ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
    _, err = cli.Put(ctx, "name", "Jaye")
    defer cancel()
    if err != nil {
        log.Println("cli.Put", err.Error())
    }

    // 取值
    ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
    res, err := cli.Get(ctx, "/test/ok")
    if err != nil {
        log.Println("cli.Get", err.Error())
    }

    for k, v := range res.Kvs {
        fmt.Println("查询结果", k, string(v.Key), string(v.Value))
    }

    // watch
    // for {
    //  rch := cli.Watch(context.Background(), "home")
    //  for resp := range rch {
    //      for k, v := range resp.Events {
    //          fmt.Println(k, v.Type, string(v.Kv.Key), string(v.Kv.Value))
    //      }
    //  }
    // }

    watchConfig(cli, "config_key", &appConfig)

    //平滑重启
    ch := make(chan os.Signal, 1)
    // We'll accept graceful shutdowns when quit via SIGINT (Ctrl+C)
    // recivie signal to exit main goroutine
    // window signal
    signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, os.Interrupt, syscall.SIGHUP)

    // linux signal if you use linux on production,please use this code.
    // signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM, syscall.SIGUSR2, os.Interrupt, syscall.SIGHUP)

    // Block until we receive our signal.
    sig := <-ch

    log.Println("exit signal: ", sig.String())
    // Create a deadline to wait for.
    ctx, cancel = context.WithTimeout(context.Background(), wait)
    defer cancel()

    <-ctx.Done()

    log.Println("shutting down")
}

// AppConfig 应用config
type AppConfig struct {
    AppID   string `json:"app_id"`
    AppName string `json:"app_name`
}

var appConfig AppConfig

// watchConfig 监听配置变化
func watchConfig(clt *clientv3.Client, key string, ss interface{}) {
    watchCh := clt.Watch(context.TODO(), key)
    go func() {
        for res := range watchCh {
            value := res.Events[0].Kv.Value
            if err := json.Unmarshal(value, ss); err != nil {
                fmt.Println("now", time.Now(), "watchConfig err", err)
                continue
            }
            fmt.Println("now", time.Now(), "watchConfig", ss)
        }
    }()
}

$ go mod tidy
go.etcd.io/etcd/clientv3 tested by
go.etcd.io/etcd/clientv3.test imports
github.com/coreos/etcd/auth imports
github.com/coreos/etcd/mvcc/backend imports
github.com/coreos/bbolt: github.com/coreos/[email protected]: parsing go.mod:
module declares its path as: go.etcd.io/bbolt
but was required as: github.com/coreos/bbolt

Most helpful comment

The etcd project should search and replace github.com/coreos/ with go.etcd.io/ in their source (why, why did you change it?!)

Meanwhile, add this to go.mod to get the code to compile:

replace github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5

All 18 comments

$ go run app.go

github.com/coreos/etcd/clientv3/balancer/picker

/mygo/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/err.go:37:44: undefined: balancer.PickOptions
/mygo/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/picker/roundrobin_balanced.go:55:54: undefined: balancer.PickOptions

github.com/coreos/etcd/clientv3/balancer/resolver/endpoint

/mygo/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:114:78: undefined: resolver.BuildOption
/mygo/pkg/mod/github.com/coreos/[email protected]+incompatible/clientv3/balancer/resolver/endpoint/endpoint.go:182:31: undefined: resolver.ResolveNowOption

all the undefined errors are happening because of #11721

@philips Is something similar to #11823 needed to fix this too?

I don’t quite understand what is the problem in this setup.

Can someone please retry using:

go get go.etcd.io/etcd/v3/clientv3@master

thanks

Ran the above, but i think i may be hitting this because of an indirect dependency on github.com/coreos/etcd.

[I] go mod tidy
go: finding module for package github.com/coreos/bbolt
go: found github.com/coreos/bbolt in github.com/coreos/bbolt v1.3.4
go: github.com/talos-systems/talos/internal/app/machined/pkg/system/services imports
    go.etcd.io/etcd/clientv3 tested by
    go.etcd.io/etcd/clientv3.test imports
    github.com/coreos/etcd/auth imports
    github.com/coreos/etcd/mvcc/backend imports
    github.com/coreos/bbolt: github.com/coreos/[email protected]: parsing go.mod:
    module declares its path as: go.etcd.io/bbolt
            but was required as: github.com/coreos/bbolt

Hrm, I don't know where github.com/coreos/bbolt could be coming from. But,
it doesn't appear anywhere except CHANGELOGs in this repo's master.

On Tue, Apr 28, 2020 at 4:05 PM Andrew Rynhard notifications@github.com
wrote:

Ran the above, but i think i may be hitting this because of an indirect
dependency on github.com/coreos/etcd.

[I] go mod tidy
go: finding module for package github.com/coreos/bbolt
go: found github.com/coreos/bbolt in github.com/coreos/bbolt v1.3.4
go: github.com/talos-systems/talos/internal/app/machined/pkg/system/services imports
go.etcd.io/etcd/clientv3 tested by
go.etcd.io/etcd/clientv3.test imports
github.com/coreos/etcd/auth imports
github.com/coreos/etcd/mvcc/backend imports
github.com/coreos/bbolt: github.com/coreos/[email protected]: parsing go.mod:
module declares its path as: go.etcd.io/bbolt
but was required as: github.com/coreos/bbolt


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/etcd-io/etcd/issues/11749#issuecomment-620900332, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AAAIGCBAG7B4IBKFY4ACRDDRO5OMDANCNFSM4MASKARQ
.

[I] go mod tidy -v
go: finding module for package github.com/coreos/bbolt
go: found github.com/coreos/bbolt in github.com/coreos/bbolt v1.3.4
go: github.com/talos-systems/talos/internal/app/machined/pkg/system/services imports
    go.etcd.io/etcd/clientv3 tested by
    go.etcd.io/etcd/clientv3.test imports
    github.com/coreos/etcd/auth imports
    github.com/coreos/etcd/mvcc/backend imports
    github.com/coreos/bbolt: github.com/coreos/[email protected]: parsing go.mod:
    module declares its path as: go.etcd.io/bbolt
            but was required as: github.com/coreos/bbolt

maybe because of viper?

[I] go mod graph | grep coreos/etcd
github.com/spf13/[email protected] github.com/coreos/[email protected]+incompatible

go modules hurt my brain sometimes

I don’t know how we can fix this without going back in time. Master of viper seems to have dropped this: https://github.com/spf13/viper/blob/master/go.mod

Is there any workaround that those of us who require go mod can use? I tried to go back a few minor versions but found that this issue happens with each one.

@shnish you can try this fork https://github.com/etcd-io/etcd/issues/11721#issuecomment-620581898 while maintainers are fixing the problem. It should work just fine

why did bbolt switch to using go.etcd.io/bbolt in the first place?

as opposed to using the more obvious github.com/etcd-io/etcd or github.com/coreos/bbolt ?

The etcd project should search and replace github.com/coreos/ with go.etcd.io/ in their source (why, why did you change it?!)

Meanwhile, add this to go.mod to get the code to compile:

replace github.com/coreos/bbolt => go.etcd.io/bbolt v1.3.5

try downgrade the version in go.mod

github.com/coreos/bbolt v1.3.4  => github.com/coreos/bbolt v1.3.3

@2build my go mod file doesn't include bbolt. It only has github.com/coreos/etcd v3.3.20+incompatible. Any suggested workarounds apart from using the fork?

@mohdahmad17
Maybe, you can downgrade etcd version and add bbolt manually.
I'm new to golang, here is my full gomod file, it worked in my test project.

go 1.15

require (
    github.com/coreos/bbolt v1.3.3 // indirect
    github.com/coreos/etcd v3.3.13+incompatible
    github.com/coreos/go-semver v0.3.0 // indirect
    github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
    github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
    github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
    github.com/gogo/protobuf v1.3.1 // indirect
    github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
    github.com/google/btree v1.0.0 // indirect
    github.com/google/go-cmp v0.5.1 // indirect
    github.com/gorilla/websocket v1.4.2 // indirect
    github.com/grpc-ecosystem/go-grpc-middleware v1.2.0 // indirect
    github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
    github.com/grpc-ecosystem/grpc-gateway v1.11.3 // indirect
    github.com/jonboulle/clockwork v0.2.1 // indirect
    github.com/prometheus/client_golang v1.7.1 // indirect
    github.com/soheilhy/cmux v0.1.4 // indirect
    github.com/tmc/grpc-websocket-proxy v0.0.0-20200427203606-3cfed13b9966 // indirect
    github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
    go.etcd.io/bbolt v1.3.3 // indirect
    go.uber.org/zap v1.16.0 // indirect
    golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
    golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
    golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 // indirect
    golang.org/x/text v0.3.3 // indirect
    golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
    golang.org/x/tools v0.0.0-20200806022845-90696ccdc692 // indirect
    golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
    google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1 // indirect
    google.golang.org/grpc v1.22.0 // indirect
    honnef.co/go/tools v0.0.1-2020.1.4 // indirect
)

Mr Tabor pointed me to this posting -- Thank you Mr. Tabor !

I used the earlier go.mods contents posted, but also modifed the following
files in the latests etcd module in ~/go/pkg/mod/go.etcd.io/[email protected]+incompatible
to address go.etcd.io/bbolt instead:

bill-of-materials.json: "project": "github.com/coreos/bbolt",
clientv3/snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"
etcdctl/ctlv2/command/backup_command.go: bolt "github.com/coreos/bbolt"
etcdctl/ctlv3/command/snapshot_command.go: bolt "github.com/coreos/bbolt"
glide.lock:- name: github.com/coreos/bbolt
glide.yaml:- package: github.com/coreos/bbolt
mvcc/backend/backend.go: bolt "github.com/coreos/bbolt"
mvcc/backend/config_windows.go:import bolt "github.com/coreos/bbolt"
mvcc/backend/batch_tx_test.go: bolt "github.com/coreos/bbolt"
mvcc/backend/backend_test.go: bolt "github.com/coreos/bbolt"
mvcc/backend/batch_tx.go: bolt "github.com/coreos/bbolt"
mvcc/backend/read_tx.go: bolt "github.com/coreos/bbolt"
mvcc/backend/config_default.go:import bolt "github.com/coreos/bbolt"
mvcc/backend/config_linux.go: bolt "github.com/coreos/bbolt"
snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"

When this correction was made the call to 'go build' for my program it corrected the go.mod file to the
most current version of go.etcd.io/etcd and go.etcd.io/bbolt.

While not an optimal solution , it worked. Now running the latest etcd and bbolt module libs.

Thanks for the support!

Thank you,i try it again.

发自我的iPhone

------------------ Original ------------------
From: billiamx33 <[email protected]>
Date: Fri,Oct 23,2020 2:19 AM
To: etcd-io/etcd <[email protected]>
Cc: heige <[email protected]>, Author <[email protected]>
Subject: Re: [etcd-io/etcd] module declares its path as: go.etcd.io/bbolt,but was required as: github.com/coreos/bbolt (#11749)

Mr Tabor pointed me to this posting -- Thank you Mr. Tabor !

I used the earlier go.mods contents posted, but also modifed the following
files in the latests etcd module in ~/go/pkg/mod/go.etcd.io/[email protected]+incompatible
to address go.etcd.io/bbolt instead:

bill-of-materials.json: "project": "github.com/coreos/bbolt",
clientv3/snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"
etcdctl/ctlv2/command/backup_command.go: bolt "github.com/coreos/bbolt"
etcdctl/ctlv3/command/snapshot_command.go: bolt "github.com/coreos/bbolt"
glide.lock:- name: github.com/coreos/bbolt
glide.yaml:- package: github.com/coreos/bbolt
mvcc/backend/backend.go: bolt "github.com/coreos/bbolt"
mvcc/backend/config_windows.go:import bolt "github.com/coreos/bbolt"
mvcc/backend/batch_tx_test.go: bolt "github.com/coreos/bbolt"
mvcc/backend/backend_test.go: bolt "github.com/coreos/bbolt"
mvcc/backend/batch_tx.go: bolt "github.com/coreos/bbolt"
mvcc/backend/read_tx.go: bolt "github.com/coreos/bbolt"
mvcc/backend/config_default.go:import bolt "github.com/coreos/bbolt"
mvcc/backend/config_linux.go: bolt "github.com/coreos/bbolt"
snapshot/v3_snapshot.go: bolt "github.com/coreos/bbolt"

When this correction was made the call to 'go build' for my program it corrected the go.mod file to the
most current version of go.etcd.io/etcd and go.etcd.io/bbolt.

While not an optimal solution , it worked. Now running the latest etcd and bbolt module libs.

Thanks for the support!


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Was this page helpful?
0 / 5 - 0 ratings