Skip to content

Commit

Permalink
chore(CSI-161): opentelemetry schema fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyberezansky committed Sep 11, 2023
1 parent 3448f04 commit 5b8d421
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
7 changes: 0 additions & 7 deletions pkg/wekafs/nodeserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package wekafs
import (
"context"
"fmt"
"github.com/Djarvur/go-lsmod"
"github.com/container-storage-interface/spec/lib/go/csi"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
Expand Down Expand Up @@ -110,12 +109,6 @@ func NewNodeServer(nodeId string, maxVolumesPerNode int64, api *ApiStore, mounte
}
}

func isWekaInstalled() bool {
log.Info().Msg("Checking if wekafs is installed on host")
ok, err := lsmod.IsLoaded(WekaKernelModuleName)
return err != nil && ok
}

func (ns *NodeServer) acquireSemaphore(ctx context.Context, op string) (error, releaseSempahore) {
logger := log.Ctx(ctx)
ns.initializeSemaphore(ctx, op)
Expand Down
2 changes: 1 addition & 1 deletion pkg/wekafs/otel.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"go.opentelemetry.io/otel/exporters/jaeger"
"go.opentelemetry.io/otel/sdk/resource"
sdktrace "go.opentelemetry.io/otel/sdk/trace"
semconv "go.opentelemetry.io/otel/semconv/v1.17.0"
semconv "go.opentelemetry.io/otel/semconv/v1.21.0"
"os"
)

Expand Down
20 changes: 20 additions & 0 deletions pkg/wekafs/utilities.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package wekafs

import (
"bufio"
"context"
"crypto/sha1"
"encoding/base32"
Expand Down Expand Up @@ -469,3 +470,22 @@ func volumeExistsAndMatchesCapacity(ctx context.Context, v *Volume, capacity int
matches := reportedCapacity == capacity
return exists, matches, err
}

func isWekaInstalled() bool {
log.Info().Msg("Checking if wekafs is installed on host")
file, err := os.Open("/proc/modules")
if err != nil {
log.Err(err).Msg("Failed to check for existence of Weka kernel module")
return false
}
defer func() { _ = file.Close() }()
scanner := bufio.NewScanner(file)
for scanner.Scan() {
s := strings.Split(scanner.Text(), " ")
name := s[0]
if name == WekaKernelModuleName {
return true
}
}
return false
}

0 comments on commit 5b8d421

Please sign in to comment.