Skip to content

Commit

Permalink
[config & API change] mountpath labels
Browse files Browse the repository at this point in the history
* part five, prev. commit: b3efa66

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Mar 22, 2024
1 parent 6f092c0 commit 96ef5a1
Show file tree
Hide file tree
Showing 19 changed files with 186 additions and 137 deletions.
3 changes: 2 additions & 1 deletion ais/fspathrgrp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"github.com/NVIDIA/aistore/core"
"github.com/NVIDIA/aistore/ext/dsort"
"github.com/NVIDIA/aistore/fs"
"github.com/NVIDIA/aistore/ios"
"github.com/NVIDIA/aistore/res"
"github.com/NVIDIA/aistore/stats"
"github.com/NVIDIA/aistore/volume"
Expand Down Expand Up @@ -50,7 +51,7 @@ func (g *fsprungroup) enableMpath(mpath string) (enabledMi *fs.Mountpath, err er

// attachMpath adds mountpath and notifies necessary runners about the change
// if the mountpath was actually added.
func (g *fsprungroup) attachMpath(mpath, label string) (addedMi *fs.Mountpath, err error) {
func (g *fsprungroup) attachMpath(mpath string, label ios.Label) (addedMi *fs.Mountpath, err error) {
addedMi, err = fs.AddMpath(g.t.SID(), mpath, label, g.redistributeMD)
if err != nil || addedMi == nil {
return
Expand Down
10 changes: 3 additions & 7 deletions ais/test/regression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,15 +608,11 @@ func TestGetClusterStats(t *testing.T) {
if len(vCDF.Mountpaths) != len(tCDF.Mountpaths) {
t.Errorf("%s: num mountpaths is different: [%+v] vs [%+v]\n", tname, vCDF, tCDF)
}
var printed bool
for mpath := range vCDF.Mountpaths {
vcdf, tcdf := vCDF.Mountpaths[mpath], tCDF.Mountpaths[mpath]
tcdf := tCDF.Mountpaths[mpath]
s := tname + mpath
if vcdf.Capacity.PctUsed != tcdf.Capacity.PctUsed {
t.Errorf("%-30s capacity is different: [%+v] vs [%+v]\n", s, vcdf, tcdf)
} else if !printed {
tlog.Logf("%-30s %+v(%+v), %s\n", s, vcdf.Disks, tcdf.Disks, tcdf.FS)
printed = true
if tcdf.Capacity.Used != 0 {
tlog.Logf("%-30s %+v %+v\n", s, tcdf.Disks, tcdf.Capacity)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion ais/tgtcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ func (t *target) enableMpath(w http.ResponseWriter, r *http.Request, mpath strin
}

func (t *target) attachMpath(w http.ResponseWriter, r *http.Request, mpath string) {
label := r.URL.Query().Get(apc.QparamDiskLabel)
q := r.URL.Query()
label := ios.Label(q.Get(apc.QparamMpathLabel))
addedMi, err := t.fsprg.attachMpath(mpath, label)
if err != nil {
t.writeErr(w, r, err)
Expand Down
2 changes: 1 addition & 1 deletion api/apc/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const (
QparamSilent = "sln"

// (see api.AttachMountpath vs. LocalConfig.FSP)
QparamDiskLabel = "disk_label"
QparamMpathLabel = "mountpath_label"
)

// QparamFltPresence enum.
Expand Down
6 changes: 4 additions & 2 deletions api/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func GetMountpaths(bp BaseParams, node *meta.Snode) (mpl *apc.MountpathList, err
return mpl, err
}

func AttachMountpath(bp BaseParams, node *meta.Snode, mountpath string, label ...string) error {
func AttachMountpath(bp BaseParams, node *meta.Snode, mountpath string, label ...ios.Label) error {
bp.Method = http.MethodPut
reqParams := AllocRp()
{
Expand All @@ -56,7 +56,9 @@ func AttachMountpath(bp BaseParams, node *meta.Snode, mountpath string, label ..
cos.HdrContentType: []string{cos.ContentJSON},
}
if len(label) > 0 {
reqParams.Query = url.Values{apc.QparamDiskLabel: []string{label[0]}}
if lb := string(label[0]); lb != "" {
reqParams.Query = url.Values{apc.QparamMpathLabel: []string{lb}}
}
}
}
err := reqParams.DoRequest()
Expand Down
15 changes: 10 additions & 5 deletions cmd/cli/cli/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ const (

var (
indent2 = strings.Repeat(indent1, 2)
indent3 = strings.Repeat(indent1, 3)
indent4 = strings.Repeat(indent1, 4)

archFormats = ".tar, .tgz or .tar.gz, .zip, .tar.lz4" // namely, archive.FileExtensions
Expand Down Expand Up @@ -937,12 +938,16 @@ var (
Name: "no-rebalance",
Usage: "do _not_ run global rebalance after putting node in maintenance (caution: advanced usage only!)",
}
diskLabelFlag = cli.StringFlag{
mountpathLabelFlag = cli.StringFlag{
Name: "label",
Usage: "optional _disk label_ that can be associated with the mountpath that's being attached\n" +
indent2 + "to further assist in:\n" +
indent4 + "- mapping the mountpath to its underlying disk(s), if any\n" +
indent4 + "- aggregating target mountpaths across non-overlapping storage capacities",
Usage: "optional _mountpath label_ that can be used to deliver extended functionality,\n" +
indent1 + " including:\n" +
indent3 + "- mapping of the mountpath to its underlying disk(s), if any\n" +
indent3 + " (potentially useful in highly virtualized/containerized environments);\n" +
indent3 + "- disk sharing between multiple mountpaths;\n" +
indent3 + "- storage classes (as in: \"different storages - for different buckets\");\n" +
indent3 + "- user-defined grouping of the mountpaths;\n" +
indent3 + " (e.g. to reflect different non-overlapping storage capacities and/or storage classes)",
}
noResilverFlag = cli.BoolFlag{
Name: "no-resilver",
Expand Down
10 changes: 4 additions & 6 deletions cmd/cli/cli/storage_hdlr.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/NVIDIA/aistore/cmn/debug"
"github.com/NVIDIA/aistore/cmn/mono"
"github.com/NVIDIA/aistore/core/meta"
"github.com/NVIDIA/aistore/ios"
"github.com/NVIDIA/aistore/sys"
"github.com/NVIDIA/aistore/xact"
"github.com/urfave/cli"
Expand All @@ -46,7 +47,7 @@ type bsummCtx struct {
var (
mpathCmdsFlags = map[string][]cli.Flag{
cmdMpathAttach: {
diskLabelFlag,
mountpathLabelFlag,
},
cmdMpathEnable: {},
cmdMpathDetach: {
Expand Down Expand Up @@ -628,11 +629,8 @@ func mpathAction(c *cli.Context, action string) error {
switch action {
case apc.ActMountpathAttach:
acted = "attached"
if label := parseStrFlag(c, diskLabelFlag); label == "" {
err = api.AttachMountpath(apiBP, si, mountpath)
} else {
err = api.AttachMountpath(apiBP, si, mountpath, label)
}
label := parseStrFlag(c, mountpathLabelFlag)
err = api.AttachMountpath(apiBP, si, mountpath, ios.Label(label))
case apc.ActMountpathEnable:
acted = "enabled"
err = api.EnableMountpath(apiBP, si, mountpath)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/NVIDIA/aistore/cmd/cli
go 1.22

require (
github.com/NVIDIA/aistore v1.3.23-0.20240320191605-e7eb9beaa8a8
github.com/NVIDIA/aistore v1.3.23-0.20240322161524-26c70c657244
github.com/fatih/color v1.16.0
github.com/json-iterator/go v1.1.12
github.com/onsi/ginkgo v1.16.5
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
code.cloudfoundry.org/bytefmt v0.0.0-20190710193110-1eb035ffe2b6/go.mod h1:wN/zk7mhREp/oviagqUXY3EwuHhWyOvAdsn5Y4CzOrc=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/NVIDIA/aistore v1.3.23-0.20240320191605-e7eb9beaa8a8 h1:MTquczSOxvMVjjcIaje6sRPjQOHbpu+nxbisV5bWXpY=
github.com/NVIDIA/aistore v1.3.23-0.20240320191605-e7eb9beaa8a8/go.mod h1:3UqMJIK/9VMRalJNIRvz7amtXLLOmIGWy5mV8l5tbiE=
github.com/NVIDIA/aistore v1.3.23-0.20240322161524-26c70c657244 h1:QsDtnm7HgZ9z0Smc5KUMUFT/weIPIxelJ3SKx3oM/34=
github.com/NVIDIA/aistore v1.3.23-0.20240322161524-26c70c657244/go.mod h1:3UqMJIK/9VMRalJNIRvz7amtXLLOmIGWy5mV8l5tbiE=
github.com/OneOfOne/xxhash v1.2.8 h1:31czK/TI9sNkxIKfaUfGlU47BAxQ0ztGgd9vPyqimf8=
github.com/OneOfOne/xxhash v1.2.8/go.mod h1:eZbhyaAYD41SGSSsnmcpxVoRiQ/MPUTjUdIIOT9Um7Q=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/teb/mountpath.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func mpathRow(c *PerfTabCtx, cols []*header, mpath string, cdf *fs.CDF, row []st
}
}
if _idx(cols, colFS) >= 0 {
row = append(row, cdf.FS)
row = append(row, cdf.FS.String())
}
return row
}
Expand Down Expand Up @@ -192,7 +192,7 @@ func _fmtMpathDisks(cdfs map[string]*fs.CDF, idx int) (s string) {
if next {
s += "\n" + strings.Repeat("\t", idx) + " "
}
s += cdf.FS
s += cdf.FS.String()
next = true
}
return
Expand Down
8 changes: 4 additions & 4 deletions core/mock/iostat_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func NewIOS() *IOS { return &IOS{} }
func (m *IOS) GetAllMpathUtils() *ios.MpathUtil { return &m.Utils }
func (m *IOS) GetMpathUtil(mpath string) int64 { return m.Utils.Get(mpath) }

func (*IOS) AddMpath(string, string, string, *cmn.Config) (ios.FsDisks, error) { return nil, nil }
func (*IOS) RemoveMpath(string, bool) {}
func (*IOS) LogAppend(l []string) []string { return l }
func (*IOS) FillDiskStats(ios.AllDiskStats) {}
func (*IOS) AddMpath(string, string, ios.Label, *cmn.Config) (ios.FsDisks, error) { return nil, nil }
func (*IOS) RemoveMpath(string, bool) {}
func (*IOS) LogAppend(l []string) []string { return l }
func (*IOS) FillDiskStats(ios.AllDiskStats) {}
13 changes: 9 additions & 4 deletions fs/api.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
// Package fs provides mountpath and FQN abstractions and methods to resolve/map stored content
/*
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
*/
package fs

import (
"github.com/NVIDIA/aistore/cmn/cos"
"github.com/NVIDIA/aistore/ios"
)

type (
Capacity struct {
Used uint64 `json:"used,string"` // bytes
Avail uint64 `json:"avail,string"` // ditto
PctUsed int32 `json:"pct_used"` // %% used (redundant ok)
}
// Capacity, Disks, Filesystem (CDF)
// (not to be confused with Cumulative Distribution Function)
CDF struct {
Capacity
Disks []string `json:"disks"` // owned disks (ios.FsDisks map => slice)
FS string `json:"fs"` // cos.Fs + cos.FsID
Disks []string `json:"disks"` // owned or shared disks (ios.FsDisks map => slice)
Label ios.Label `json:"mountpath_label"`
FS cos.FS `json:"fs"`
}
// Target (cumulative) CDF
TargetCDF struct {
Expand Down
Loading

0 comments on commit 96ef5a1

Please sign in to comment.