k8up icon indicating copy to clipboard operation
k8up copied to clipboard

Remove trailing slashes in s3 endpoint configuration

Open wejdross opened this issue 1 year ago • 1 comments

Description

When defining for example Restore job, if our s3 endpoint contain trailing slashes whole restore fails.

Additional Context

No response

Logs

2025-01-13T09:40:14Z    INFO    k8up    Starting k8up…  {"version": "2.11.3", "date": "2024-12-13T15:23:43Z", "commit": "be9529f1242148b614a3d0911e7c655955b2835e", "go_os": "linux", "go_arch": "amd64", "go_version": "go1.23.4", "uid": 65532, "gid": 0}
2025-01-13T09:40:14Z    INFO    k8up.restic     initializing
2025-01-13T09:40:14Z    INFO    k8up.restic     setting up a signal handler
2025-01-13T09:40:14Z    INFO    k8up.restic.restic      using the following restic options      {"options": [""]}
2025-01-13T09:40:14Z    INFO    k8up.restic.restic.RepoInit.command     restic command  {"path": "/usr/local/bin/restic", "args": ["init", "--option", ""]}
2025-01-13T09:40:14Z    INFO    k8up.restic.restic.RepoInit.command     Defining RESTIC_PROGRESS_FPS    {"frequency": 0.016666666666666666}
2025-01-13T09:40:14Z    INFO    k8up.restic.restic.RepoInit.restic.stderr       Fatal: create repository at s3:http://minio-server.minio.svc:9000//hello-testing1-ppb2w-backup failed: client.BucketExists: Bucket name cannot be empty
2025-01-13T09:40:14Z    INFO    k8up.restic.restic.RepoInit.restic.stderr
2025/01/13 09:40:14 unable to start k8up: failed to initialise the restic repository: cmd.Wait() err: 1


### Expected Behavior

regardless of trailing slashes, jobs are working 

### Steps To Reproduce

apiVersion: k8up.io/v1
kind: Restore
metadata:
  name: nextcloud-restore
  namespace: vshn-nextcloud-hello-testing1-ppb2w
spec:
  restoreMethod:
    folder:
      claimName: hello-testing1-ppb2w-nextcloud-nextcloud
  backend:
    repoPasswordSecretRef:
      name: k8up-repository-password
      key: password
    s3:
      endpoint: http://minio-server.minio.svc:9000/ # <<---- here
      bucket: hello-testing1-ppb2w-backup
      accessKeyIDSecretRef:
        name: backup-bucket-credentials
        key: AWS_ACCESS_KEY_ID
      secretAccessKeySecretRef:
        name: backup-bucket-credentials
        key: AWS_SECRET_ACCESS_KEY

### Version of K8up

ghcr.io/k8up-io/k8up:v2.11.3

### Version of Kubernetes

Server Version: v1.29.7

### Distribution of Kubernetes

kind

wejdross avatar Jan 13 '25 09:01 wejdross

Joining the bucket name to endpoint this way could help: https://pkg.go.dev/net/url#JoinPath

ahyattdev avatar Jan 29 '25 02:01 ahyattdev