Skip to content

Commit

Permalink
Merge pull request #542 from ipfs/release-v0.17.0
Browse files Browse the repository at this point in the history
Release v0.17.0
  • Loading branch information
hacdias committed Jan 10, 2024
2 parents 709c7c6 + ad4e2b2 commit 8530184
Show file tree
Hide file tree
Showing 72 changed files with 889 additions and 1,259 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ The following emojis are used to highlight certain changes:

### Security

## [v0.17.0]

### Added

* 🛠 `pinning/pinner`: you can now give a custom name when pinning a CID. To reflect this, the `Pinner` has been adjusted. Note that calling `Pin` for the same CID with a different name will replace its current name by the newly given name.

### Removed

- 🛠 `tracing` `jaeger` exporter has been removed due to it's deprecation and removal from upstream, you should use `otlp` exporter instead. See the [docs](./docs/tracing.md) for an example.

## [v0.16.0]

### Changed
Expand Down
5 changes: 3 additions & 2 deletions bitswap/bitswap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package bitswap_test
import (
"bytes"
"context"
"errors"
"fmt"
"os"
"sync"
Expand Down Expand Up @@ -432,10 +433,10 @@ func TestBasicBitswap(t *testing.T) {
// peer should no longer keep second peer's want
if err = tu.WaitFor(ctx, func() error {
if len(instances[2].Exchange.WantlistForPeer(instances[1].Peer)) != 0 {
return fmt.Errorf("should have no items in other peers wantlist")
return errors.New("should have no items in other peers wantlist")
}
if len(instances[1].Exchange.GetWantlist()) != 0 {
return fmt.Errorf("shouldnt have anything in wantlist")
return errors.New("shouldnt have anything in wantlist")
}
return nil
}); err != nil {
Expand Down
3 changes: 2 additions & 1 deletion bitswap/client/bitswap_with_sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package client_test

import (
"context"
"errors"
"fmt"
"testing"
"time"
Expand Down Expand Up @@ -489,7 +490,7 @@ func TestWantlistClearsOnCancel(t *testing.T) {

if err := tu.WaitFor(ctx, func() error {
if len(a.Exchange.GetWantlist()) > 0 {
return fmt.Errorf("expected empty wantlist")
return errors.New("expected empty wantlist")
}
return nil
}); err != nil {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package messagequeue

import (
"context"
"fmt"
"errors"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -342,7 +342,7 @@ func TestDontHaveTimeoutMgrUsesDefaultTimeoutIfPingError(t *testing.T) {
tr := timeoutRecorder{}
clock := clock.NewMock()
pinged := make(chan struct{})
pc := &mockPeerConn{latency: latency, clock: clock, pinged: pinged, err: fmt.Errorf("ping error")}
pc := &mockPeerConn{latency: latency, clock: clock, pinged: pinged, err: errors.New("ping error")}
timeoutsTriggered := make(chan struct{})

dhtm := newDontHaveTimeoutMgrWithParams(pc, tr.onTimeout,
Expand Down
4 changes: 2 additions & 2 deletions bitswap/client/internal/messagequeue/messagequeue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package messagequeue

import (
"context"
"fmt"
"errors"
"math"
"math/rand"
"sync"
Expand Down Expand Up @@ -40,7 +40,7 @@ func (fmn *fakeMessageNetwork) NewMessageSender(context.Context, peer.ID, *bsnet
func (fms *fakeMessageNetwork) Self() peer.ID { return "" }
func (fms *fakeMessageNetwork) Latency(peer.ID) time.Duration { return 0 }
func (fms *fakeMessageNetwork) Ping(context.Context, peer.ID) ping.Result {
return ping.Result{Error: fmt.Errorf("ping error")}
return ping.Result{Error: errors.New("ping error")}
}

type fakeDontHaveTimeoutMgr struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (rpm *receivedProviderMessage) handle(pqm *ProviderQueryManager) {
}

func (fpqm *finishedProviderQueryMessage) debugMessage() string {
return fmt.Sprintf("Finished Provider Query on cid: %s", fpqm.k.String())
return "Finished Provider Query on cid: " + fpqm.k.String()
}

func (fpqm *finishedProviderQueryMessage) handle(pqm *ProviderQueryManager) {
Expand All @@ -372,7 +372,7 @@ func (fpqm *finishedProviderQueryMessage) handle(pqm *ProviderQueryManager) {
}

func (npqm *newProvideQueryMessage) debugMessage() string {
return fmt.Sprintf("New Provider Query on cid: %s", npqm.k.String())
return "New Provider Query on cid: " + npqm.k.String()
}

func (npqm *newProvideQueryMessage) handle(pqm *ProviderQueryManager) {
Expand Down Expand Up @@ -407,7 +407,7 @@ func (npqm *newProvideQueryMessage) handle(pqm *ProviderQueryManager) {
}

func (crm *cancelRequestMessage) debugMessage() string {
return fmt.Sprintf("Cancel provider query on cid: %s", crm.k.String())
return "Cancel provider query on cid: " + crm.k.String()
}

func (crm *cancelRequestMessage) handle(pqm *ProviderQueryManager) {
Expand Down
10 changes: 5 additions & 5 deletions bitswap/client/internal/sessionmanager/sessionmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package sessionmanager

import (
"context"
"fmt"
"strconv"
"sync"
"testing"
"time"
Expand Down Expand Up @@ -122,7 +122,7 @@ func TestReceiveFrom(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(fmt.Sprint(123))
p := peer.ID(strconv.Itoa(123))
block := blocks.NewBlock([]byte("block"))

firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestReceiveBlocksWhenManagerShutdown(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(fmt.Sprint(123))
p := peer.ID(strconv.Itoa(123))
block := blocks.NewBlock([]byte("block"))

firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down Expand Up @@ -203,7 +203,7 @@ func TestReceiveBlocksWhenSessionContextCancelled(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(fmt.Sprint(123))
p := peer.ID(strconv.Itoa(123))
block := blocks.NewBlock([]byte("block"))

firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down Expand Up @@ -239,7 +239,7 @@ func TestShutdown(t *testing.T) {
pm := &fakePeerManager{}
sm := New(ctx, sessionFactory, sim, peerManagerFactory, bpm, pm, notif, "")

p := peer.ID(fmt.Sprint(123))
p := peer.ID(strconv.Itoa(123))
block := blocks.NewBlock([]byte("block"))
cids := []cid.Cid{block.Cid()}
firstSession := sm.NewSession(ctx, time.Second, delay.Fixed(time.Minute)).(*fakeSession)
Expand Down
8 changes: 6 additions & 2 deletions bitswap/client/internal/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package internal

import (
"context"
"fmt"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
return otel.Tracer("go-bitswap").Start(ctx, fmt.Sprintf("Bitswap.%s", name), opts...)
return startSpan(ctx, "Bitswap.Client."+name, opts...)
}

// outline logic so the string concatenation can be inlined and executed at compile time
func startSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
return otel.Tracer("go-bitswap").Start(ctx, name, opts...)
}
4 changes: 2 additions & 2 deletions bitswap/internal/testutil/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package testutil

import (
"crypto/rand"
"fmt"
"strconv"

"github.com/ipfs/boxo/bitswap/client/wantlist"
bsmsg "github.com/ipfs/boxo/bitswap/message"
Expand Down Expand Up @@ -62,7 +62,7 @@ func GeneratePeers(n int) []peer.ID {
peerIds := make([]peer.ID, 0, n)
for i := 0; i < n; i++ {
peerSeq++
p := peer.ID(fmt.Sprint(peerSeq))
p := peer.ID(strconv.Itoa(peerSeq))
peerIds = append(peerIds, p)
}
return peerIds
Expand Down
8 changes: 6 additions & 2 deletions bitswap/internal/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package internal

import (
"context"
"fmt"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
return otel.Tracer("go-bitswap").Start(ctx, fmt.Sprintf("Bitswap.%s", name), opts...)
return startSpan(ctx, "Bitswap."+name, opts...)
}

// outline logic so the string concatenation can be inlined and executed at compile time
func startSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
return otel.Tracer("go-bitswap").Start(ctx, name, opts...)
}
3 changes: 2 additions & 1 deletion bitswap/network/ipfs_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package network_test

import (
"context"
"errors"
"fmt"
"sync"
"testing"
Expand Down Expand Up @@ -69,7 +70,7 @@ func (r *receiver) PeerDisconnected(p peer.ID) {
r.connectionEvent <- false
}

var errMockNetErr = fmt.Errorf("network err")
var errMockNetErr = errors.New("network err")

type ErrStream struct {
network.Stream
Expand Down
4 changes: 2 additions & 2 deletions bitswap/server/internal/decision/blockstoremanager.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package decision

import (
"context"
"fmt"
"errors"
"sync"

bstore "github.com/ipfs/boxo/blockstore"
Expand Down Expand Up @@ -77,7 +77,7 @@ func (bsm *blockstoreManager) addJob(ctx context.Context, job func()) error {
case <-ctx.Done():
return ctx.Err()
case <-bsm.stopChan:
return fmt.Errorf("shutting down")
return errors.New("shutting down")
case bsm.jobs <- job:
bsm.pendingGauge.Inc()
return nil
Expand Down
3 changes: 2 additions & 1 deletion bitswap/server/internal/decision/engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"encoding/binary"
"errors"
"fmt"
"strconv"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -1647,7 +1648,7 @@ func TestWantlistGrowsToLimit(t *testing.T) {
// Send in two messages to test reslicing.
m := message.New(false)
for j := limit; j != 0; j-- {
m.AddEntry(blocks.NewBlock([]byte(fmt.Sprint(j))).Cid(), 0, pb.Message_Wantlist_Block, true)
m.AddEntry(blocks.NewBlock([]byte(strconv.Itoa(j))).Cid(), 0, pb.Message_Wantlist_Block, true)
}
warsaw.Engine.MessageReceived(ctx, riga.Peer, m)

Expand Down
3 changes: 3 additions & 0 deletions blockservice/blockservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,9 @@ func (s *blockService) DeleteBlock(ctx context.Context, c cid.Cid) error {

func (s *blockService) Close() error {
logger.Debug("blockservice is shutting down...")
if s.exchange == nil {
return nil
}

Check warning on line 427 in blockservice/blockservice.go

View check run for this annotation

Codecov / codecov/patch

blockservice/blockservice.go#L426-L427

Added lines #L426 - L427 were not covered by tests
return s.exchange.Close()
}

Expand Down
8 changes: 6 additions & 2 deletions blockservice/internal/tracing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ package internal

import (
"context"
"fmt"

"go.opentelemetry.io/otel"
"go.opentelemetry.io/otel/trace"
)

func StartSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
return otel.Tracer("go-blockservice").Start(ctx, fmt.Sprintf("Blockservice.%s", name), opts...)
return startSpan(ctx, "Blockservice."+name, opts...)
}

// outline logic so the string concatenation can be inlined and executed at compile time
func startSpan(ctx context.Context, name string, opts ...trace.SpanStartOption) (context.Context, trace.Span) {
return otel.Tracer("go-blockservice").Start(ctx, name, opts...)
}
39 changes: 18 additions & 21 deletions docs/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tracing across the stack follows, as much as possible, the [Open Telemetry]
specifications. Configuration environment variables are specified in the
[OpenTelemetry Environment Variable Specification].

We use the [opentelemtry-go] package, which currently does not have default support
We use the [opentelemetry-go] package, which currently does not have default support
for the `OTEL_TRACES_EXPORTER` environment variables. Therefore, we provide some
helper functions under [`boxo/tracing`](../tracing/) to support these.

Expand All @@ -15,7 +15,6 @@ to use the Jaeger UI. The [Gateway examples](../examples/gateway/) fully support
- [Environment Variables](#environment-variables)
- [`OTEL_TRACES_EXPORTER`](#otel_traces_exporter)
- [`OTLP Exporter`](#otlp-exporter)
- [`Jaeger Exporter`](#jaeger-exporter)
- [`Zipkin Exporter`](#zipkin-exporter)
- [`File Exporter`](#file-exporter)
- [`OTEL_PROPAGATORS`](#otel_propagators)
Expand All @@ -34,7 +33,6 @@ set of additional environment variables used to configure it. The following valu
are supported:

- `otlp`
- `jaeger`
- `zipkin`
- `stdout`
- `file` -- appends traces to a JSON file on the filesystem
Expand All @@ -54,10 +52,6 @@ Specifies the OTLP protocol to use, which is one of:

Default: `"grpc"`

### `Jaeger Exporter`

See [Jaeger Exporter](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#jaeger-exporter).

### `Zipkin Exporter`

See [Zipkin Exporter](https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/sdk-environment-variables.md#zipkin-exporter).
Expand All @@ -81,24 +75,27 @@ and configure the Kubo daemon, or gateway examples, to publish traces to it. Her
ephemeral container:

```console
$ docker run --rm -it --name jaeger \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14268:14268 \
-p 14269:14269 \
-p 14250:14250 \
-p 9411:9411 \
jaegertracing/all-in-one
$ docker run -d --rm --name jaeger \
-e COLLECTOR_OTLP_ENABLED=true \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 5775:5775/udp \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 14250:14250 \
-p 14268:14268 \
-p 14269:14269 \
-p 4317:4317 \
-p 4318:4318 \
-p 9411:9411 \
jaegertracing/all-in-one
```

Then, in other terminal, start the app that uses `boxo/tracing` internally (e.g., a Kubo daemon), with Jaeger exporter enabled:

```
$ OTEL_TRACES_EXPORTER=jaeger ipfs daemon
```console
$ OTEL_EXPORTER_OTLP_INSECURE=true OTEL_TRACES_EXPORTER=otlp ipfs daemon --init
```

Finally, the [Jaeger UI] is available at http://localhost:16686.
Expand Down
Loading

0 comments on commit 8530184

Please sign in to comment.