Skip to content

Commit

Permalink
fix dockerfile and added some log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
dkhachyan committed Aug 13, 2024
1 parent 68eeafa commit 906b73f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ RUN go mod download

COPY . ./

RUN go build -o /etcd-defrag-controller
RUN CGO_ENABLED=0 go build -o /etcd-defrag-controller

## Deploy
FROM gcr.io/distroless/static:nonroot
WORKDIR /

USER 65532:65532

COPY --from=builder /etcd-defrag-controller /etcd-defrag-controller
COPY --from=builder /etcd-defrag-controller .

ENTRYPOINT ["/etcd-defrag-controller"]
5 changes: 4 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/*
Copyright © 2022 Denis Khachyan <[email protected]>
*/
package cmd

Expand Down Expand Up @@ -54,11 +53,15 @@ func StartController() {
for {
c := GetConnOpts()
d := GetDefragOpts()
if c.Endpoints == "" {
log.Fatal("Missing endpoints")
}
ctx, cancel := context.WithTimeout(context.Background(), client.RequestDefaultTimeout)
dc, err := defrag.NewDefragController(ctx, c, d)
if err != nil {
log.Fatal("Failed to start defrag controller")
}
klog.Info("Controller started")
err = dc.RunDefrag()
if err != nil {
klog.Errorf("Defragment error: %v", err)
Expand Down
4 changes: 2 additions & 2 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package client
import (
"crypto/tls"
"crypto/x509"
"io/ioutil"
"log"
"os"
"strings"
"time"

Expand Down Expand Up @@ -59,7 +59,7 @@ func NewTLSConfig(c *ConnOpts) (*tls.Config, error) {
return nil, err
}

cacert, err := ioutil.ReadFile(c.CAfile)
cacert, err := os.ReadFile(c.CAfile)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 906b73f

Please sign in to comment.