Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
Signed-off-by: jason yang <jasonyangshadow@gmail.com>
  • Loading branch information
JasonYangShadow committed Sep 21, 2023
1 parent d43278a commit 627288d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
29 changes: 29 additions & 0 deletions internal/pkg/metric/pushgateway.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package metric

import (
"net"
"path/filepath"

"github.com/apptainer/apptainer/pkg/syfs"
"github.com/apptainer/apptainer/pkg/util/apptainerconf"
)

const protocol = "unix"

type Pushgateway struct {
net.Conn
}

func New() (*Pushgateway, error) {
var socketPath string
socketPath = apptainerconf.GetCurrentConfig().PushgatewaySocketPath
if socketPath == "" {
socketPath = filepath.Join(syfs.ConfigDir(), "pushgateway.socket")
}
conn, err := net.Dial(protocol, socketPath)
if err != nil {
return nil, err
}

return &Pushgateway{conn}, nil
}
8 changes: 8 additions & 0 deletions pkg/util/apptainerconf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,8 @@ type File struct {
DownloadPartSize uint `default:"5242880" directive:"download part size"`
DownloadBufferSize uint `default:"32768" directive:"download buffer size"`
SystemdCgroups bool `default:"yes" authorized:"yes,no" directive:"systemd cgroups"`
// pushgateway unix socket
PushgatewaySocketPath string `directive:"pushgateway communication socket path"`
}

// NOTE: if you think that we may want to change the default for any
Expand Down Expand Up @@ -530,4 +532,10 @@ download buffer size = {{ .DownloadBufferSize }}
# Whether to use systemd to manage container cgroups. Required for rootless cgroups
# functionality. 'no' will manage cgroups directly via cgroupfs.
systemd cgroups = {{ if eq .SystemdCgroups true }}yes{{ else }}no{{ end }}
# PUSHGATEWAY SOCKET PATH: [STRING]
# DEFAULT: Undefined
# Defines pushgateway socket path
#pushgateway socket path=
{{ if ne .PushgatewaySocketPath "" }}pushgateway socket path = {{ .PushgatewaySocketPath}}{{ end }}
`

0 comments on commit 627288d

Please sign in to comment.