Skip to content

Commit

Permalink
download: amend abort notification; CLI: bck.String
Browse files Browse the repository at this point in the history
* previous commits, respectively:
  - 2b1a3c5
  - 8e49066

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Jan 6, 2025
1 parent 2b1a3c5 commit d8ae4af
Show file tree
Hide file tree
Showing 33 changed files with 101 additions and 91 deletions.
4 changes: 2 additions & 2 deletions ais/backend/ht.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Package backend contains implementation of various backend providers.
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package backend

Expand Down Expand Up @@ -99,7 +99,7 @@ func getOriginalURL(ctx context.Context, bck *meta.Bck, objName string) (string,
origURL, ok := ctx.Value(cos.CtxOriginalURL).(string)
if !ok || origURL == "" {
if bck.Props == nil {
return "", fmt.Errorf("failed to HEAD (%s): original_url is empty", bck)
return "", fmt.Errorf("failed to HEAD (%s): original_url is empty", bck.String())
}
origURL = bck.Props.Extra.HTTP.OrigURLBck
debug.Assert(origURL != "")
Expand Down
4 changes: 2 additions & 2 deletions ais/bucketmeta.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ func (m *bucketMD) set(bck *meta.Bck, p *cmn.Bprops) {
debug.Assert(apc.IsProvider(bck.Provider))
prevProps, present := m.Get(bck)
if !present {
debug.Assertf(false, "%s: not present", bck)
debug.Assertf(false, "%s: not present", bck.String())
}
debug.Assert(prevProps.BID != 0)

Expand Down Expand Up @@ -513,7 +513,7 @@ func defaultBckProps(args bckPropsArgs) (props *cmn.Bprops) {
case args.bck.IsAIS():
debug.Assert(args.hdr == nil)
case args.bck.Backend() != nil:
debug.Assertf(args.hdr == nil, "%s, hdr=%+v", args.bck, args.hdr)
debug.Assertf(args.hdr == nil, "%s, hdr=%+v", args.bck.String(), args.hdr)
case args.bck.IsRemote():
debug.Assert(args.hdr != nil)
props.Versioning.Enabled = false
Expand Down
2 changes: 1 addition & 1 deletion ais/plstcx.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ func (c *lstcx) do() (string, error) {
}

nlog.Infoln("'ls --all' to execute [" + c.amsg.Action + " -> " + c.altmsg.Action + "]")
s := fmt.Sprintf("%s[%s] %s => %s", c.altmsg.Action, c.xid, c.bckFrom, c.bckTo)
s := fmt.Sprintf("%s[%s] %s => %s", c.altmsg.Action, c.xid, c.bckFrom.String(), c.bckTo.String())

// 6. more pages, if any
if lst.ContinuationToken != "" {
Expand Down
24 changes: 12 additions & 12 deletions ais/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func (p *proxy) httpbckget(w http.ResponseWriter, r *http.Request, dpq *dpq) {

// (IV) list objects (NOTE -- TODO: currently, always forwarding)
if !qbck.IsBucket() {
p.writeErrf(w, r, "bad list-objects request: %q is not a bucket (is a bucket query?)", qbck)
p.writeErrf(w, r, "bad list-objects request: %q is not a bucket (is a bucket query?)", qbck.String())
return
}
if p.forwardCP(w, r, msg, lsotag+" "+qbck.String()) {
Expand Down Expand Up @@ -1297,15 +1297,15 @@ func (p *proxy) _bckpost(w http.ResponseWriter, r *http.Request, msg *apc.ActMsg
return
}
if !bckFrom.IsAIS() && bckFrom.Backend() == nil {
p.writeErrf(w, r, "can only rename AIS ('ais://') bucket (%q is not)", bckFrom)
p.writeErrf(w, r, "can only rename AIS ('ais://') bucket (%q is not)", bckFrom.Cname(""))
return
}
if bckTo.IsRemote() {
p.writeErrf(w, r, "can only rename to AIS ('ais://') bucket (%q is remote)", bckTo)
p.writeErrf(w, r, "can only rename to AIS ('ais://') bucket (%q is remote)", bckTo.Cname(""))
return
}
if bckFrom.Equal(bckTo, false, false) {
p.writeErrf(w, r, "cannot rename bucket %q to itself (%q)", bckFrom, bckTo)
p.writeErrf(w, r, "cannot rename bucket %q to itself (%q)", bckFrom.Cname(""), bckTo.Cname(""))
return
}
bckFrom.Provider, bckTo.Provider = apc.AIS, apc.AIS
Expand Down Expand Up @@ -1358,7 +1358,7 @@ func (p *proxy) _bckpost(w http.ResponseWriter, r *http.Request, msg *apc.ActMsg
tcbmsg.Prefix = cos.TrimPrefix(tcbmsg.Prefix)
if bckFrom.Equal(bckTo, true, true) {
if !bckFrom.IsRemote() {
p.writeErrf(w, r, "cannot %s bucket %q onto itself", msg.Action, bckFrom)
p.writeErrf(w, r, "cannot %s bucket %q onto itself", msg.Action, bckFrom.Cname(""))
return
}
nlog.Infoln("proceeding to copy remote", bckFrom.String())
Expand Down Expand Up @@ -1432,7 +1432,7 @@ func (p *proxy) _bckpost(w http.ResponseWriter, r *http.Request, msg *apc.ActMsg
nlog.Warningf("multi-object operation %q within the same bucket %q", msg.Action, bck)
}
if bckTo.IsHT() {
p.writeErrf(w, r, "cannot %s to HTTP bucket %q", msg.Action, bckTo)
p.writeErrf(w, r, "cannot %s to HTTP bucket %q", msg.Action, bckTo.Cname(""))
return
}
if !eq {
Expand Down Expand Up @@ -1604,14 +1604,14 @@ func (p *proxy) _bcr(w http.ResponseWriter, r *http.Request, query url.Values, m
bck.Props = nprops
if backend := bck.Backend(); backend != nil {
if err := backend.Validate(); err != nil {
p.writeErrf(w, r, "cannot create %s: invalid backend %s, err: %v", bck, backend, err)
p.writeErrf(w, r, "cannot create %s: invalid backend %s, err: %v", bck.Cname(""), backend.Cname(""), err)
return
}
// Initialize backend bucket.
if err := backend.InitNoBackend(p.owner.bmd); err != nil {
if !cmn.IsErrRemoteBckNotFound(err) {
p.writeErrf(w, r, "cannot create %s: failing to initialize backend %s, err: %v",
bck, backend, err)
bck.Cname(""), backend.Cname(""), err)
return
}
args := bctx{p: p, w: w, r: r, bck: backend, msg: msg, query: query}
Expand Down Expand Up @@ -1912,11 +1912,11 @@ func (p *proxy) httpobjpost(w http.ResponseWriter, r *http.Request, apireq *apiR

func _checkObjMv(bck *meta.Bck, msg *apc.ActMsg, apireq *apiRequest) error {
if bck.IsRemote() {
err := fmt.Errorf("invalid action %q: not supported for remote buckets (%s)", msg.Action, bck)
err := fmt.Errorf("invalid action %q: not supported for remote buckets (%s)", msg.Action, bck.String())
return cmn.NewErrUnsuppErr(err)
}
if bck.Props.EC.Enabled {
err := fmt.Errorf("invalid action %q: not supported for erasure-coded buckets (%s)", msg.Action, bck)
err := fmt.Errorf("invalid action %q: not supported for erasure-coded buckets (%s)", msg.Action, bck.String())
return cmn.NewErrUnsuppErr(err)
}
objName, objNameTo := apireq.items[1], msg.Name
Expand Down Expand Up @@ -3009,11 +3009,11 @@ func (p *proxy) dsortHandler(w http.ResponseWriter, r *http.Request) {
}
if _, err = p.owner.bmd.modify(ctx); err != nil {
debug.AssertNoErr(err)
err = fmt.Errorf(warnfmt+": %w", p, "failed to ", bckTo, bck, err)
err = fmt.Errorf(warnfmt+": %w", p, "failed to ", bckTo.String(), bck.String(), err)
p.writeErr(w, r, err)
return
}
nlog.Warningf(warnfmt, p, "", bckTo, bck)
nlog.Warningf(warnfmt, p, "", bckTo.String(), bck.String())
}
}
dsort.PstartHandler(w, r, parsc)
Expand Down
4 changes: 2 additions & 2 deletions ais/prxbck.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package ais provides core functionality for the AIStore object storage.
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package ais

Expand Down Expand Up @@ -226,7 +226,7 @@ func (bctx *bctx) initAndTry() (bck *meta.Bck, err error) {
return
}
default:
debug.Assertf(false, "%q: unexpected %v(%d)", bctx.bck, err, ecode)
debug.Assertf(false, "%q: unexpected %v(%d)", bctx.bck.String(), err, ecode)
bctx.p.writeErr(bctx.w, bctx.r, err, ecode)
return
}
Expand Down
6 changes: 3 additions & 3 deletions ais/prxdl.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (p *proxy) httpdlpost(w http.ResponseWriter, r *http.Request) {
p.writeErrStatusf(w, r, http.StatusInternalServerError, "failed to receive download request: %v", err)
return
}
_, dlBase, ok := p.validateDownload(w, r, body)
dlb, dlBase, ok := p.validateDownload(w, r, body)
if !ok {
return
}
Expand All @@ -116,8 +116,8 @@ func (p *proxy) httpdlpost(w http.ResponseWriter, r *http.Request) {
// download _job_ vs download xaction, see abortReq() in ais/prxnotif
smap := p.owner.smap.get()
nl := dload.NewDownloadNL(
jobID, // jobID != xid
apc.ActDownload, // xaction kind is always this
jobID, // jobID != xid
string(dlb.Type), // instead of apc.ActDownload xaction kind
&smap.Smap,
progressInterval,
)
Expand Down
6 changes: 3 additions & 3 deletions ais/prxnotif.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package ais provides core functionality for the AIStore object storage.
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package ais

Expand Down Expand Up @@ -329,8 +329,8 @@ func (n *notifs) done(nl nl.Listener) {
}

func abortReq(nl nl.Listener) cmn.HreqArgs {
if nl.Kind() == apc.ActDownload {
// HACK:
if _, ok := nl.(*dload.NotifDownloadListerner); ok {
// HACK
// - download _job_ vs download xaction - see dload.NewDownloadNL()
// - downloader implements abort via http.MethodDelete and uses different messaging
return dload.AbortReq(nl.UUID() /*job ID*/)
Expand Down
9 changes: 8 additions & 1 deletion ais/tgtdl.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package ais provides core functionality for the AIStore object storage.
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package ais

Expand Down Expand Up @@ -176,6 +176,13 @@ func (t *target) downloadHandler(w http.ResponseWriter, r *http.Request) {
} else { // apc.Remove
response, statusCode, respErr = xdl.RemoveJob(payload.ID)
}

// keep it quiet
if statusCode == http.StatusNotFound {
debug.Assert(response == nil)
t.writeErr(w, r, respErr, statusCode, Silent)
return
}
default:
cmn.WriteErr405(w, r, http.MethodDelete, http.MethodGet, http.MethodPost)
return
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/cli/arch_hdlr.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters.
// This file handles CLI commands that pertain to AIS objects.
/*
* Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2021-2025, NVIDIA CORPORATION. All rights reserved.
*/
package cli

Expand Down Expand Up @@ -241,7 +241,7 @@ func archMultiObjHandler(c *cli.Context) error {
if msg.ListRange.IsList() {
what = strings.Join(msg.ListRange.ObjNames, ", ")
}
fmt.Fprintf(c.App.Writer, "archive %s/{%s} as %q\n", a.rsrc.bck, what, a.dest())
fmt.Fprintf(c.App.Writer, "archive %s/{%s} as %q\n", a.rsrc.bck.String(), what, a.dest())
return nil
}
if !flagIsSet(c, dontHeadSrcDstBucketsFlag) {
Expand Down
16 changes: 8 additions & 8 deletions cmd/cli/cli/bucket.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters.
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package cli

Expand All @@ -26,7 +26,7 @@ func createBucket(c *cli.Context, bck cmn.Bck, props *cmn.BpropsToSet, dontHeadR
if err = api.CreateBucket(apiBP, bck, props, dontHeadRemote); err != nil {
if herr, ok := err.(*cmn.ErrHTTP); ok {
if herr.Status == http.StatusConflict {
desc := fmt.Sprintf("Bucket %q already exists", bck)
desc := fmt.Sprintf("Bucket %q already exists", bck.String())
if flagIsSet(c, ignoreErrorFlag) {
fmt.Fprintln(c.App.Writer, desc)
return nil
Expand All @@ -36,9 +36,9 @@ func createBucket(c *cli.Context, bck cmn.Bck, props *cmn.BpropsToSet, dontHeadR
if cliConfVerbose() {
herr.Message = herr.StringEx()
}
return fmt.Errorf("failed to create %q: %w", bck, herr)
return fmt.Errorf("failed to create %q: %w", bck.String(), herr)
}
return fmt.Errorf("failed to create %q: %v", bck, err)
return fmt.Errorf("failed to create %q: %v", bck.String(), err)
}
// NOTE: see docs/bucket.md#default-bucket-properties
fmt.Fprintf(c.App.Writer, "%q created\n", bck.Cname(""))
Expand All @@ -52,7 +52,7 @@ func destroyBuckets(c *cli.Context, buckets []cmn.Bck) (cmn.Bck, error) {
empty, errEmp := isBucketEmpty(bck, true /*cached*/)
if errEmp == nil && !empty {
if !flagIsSet(c, yesFlag) {
if ok := confirm(c, fmt.Sprintf("Proceed to destroy %s?", bck)); !ok {
if ok := confirm(c, fmt.Sprintf("Proceed to destroy %s?", bck.String())); !ok {
continue
}
}
Expand Down Expand Up @@ -88,7 +88,7 @@ func mvBucket(c *cli.Context, bckFrom, bckTo cmn.Bck) error {
return V(err)
}
_, xname := xact.GetKindName(apc.ActMoveBck)
text := fmt.Sprintf("%s %s => %s", xact.Cname(xname, xid), bckFrom, bckTo)
text := fmt.Sprintf("%s %s => %s", xact.Cname(xname, xid), bckFrom.String(), bckTo.String())
if !flagIsSet(c, waitFlag) && !flagIsSet(c, waitJobXactFinishedFlag) {
if flagIsSet(c, nonverboseFlag) {
fmt.Fprintln(c.App.Writer, xid)
Expand All @@ -106,7 +106,7 @@ func mvBucket(c *cli.Context, bckFrom, bckTo cmn.Bck) error {
fmt.Fprintln(c.App.Writer, text+" ...")
xargs := xact.ArgsMsg{ID: xid, Kind: apc.ActMoveBck, Timeout: timeout}
if err := waitXact(&xargs); err != nil {
fmt.Fprintf(c.App.ErrWriter, fmtXactFailed, "rename", bckFrom, bckTo)
fmt.Fprintf(c.App.ErrWriter, fmtXactFailed, "rename", bckFrom.String(), bckTo.String())
return err
}
fmt.Fprint(c.App.Writer, fmtXactSucceeded)
Expand All @@ -127,7 +127,7 @@ func evictBucket(c *cli.Context, bck cmn.Bck) error {
// check presence unless remais (in re: bck/@alias/name vs bck/@uuid/name)
if !bck.IsRemoteAIS() {
if _, present := bmd.Get((*meta.Bck)(&bck)); !present {
return fmt.Errorf("%s does not exist - nothing to do", bck)
return fmt.Errorf("%s does not exist - nothing to do", bck.String())
}
}
return _evictBck(c, bck)
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/cli/bucket_hdlr.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters.
// This file handles CLI commands that pertain to AIS buckets.
/*
* Copyright (c) 2021-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2021-2025, NVIDIA CORPORATION. All rights reserved.
*/
package cli

Expand Down Expand Up @@ -329,7 +329,7 @@ func mvBucketHandler(c *cli.Context) error {
return err
}
if bckFrom.Equal(&bckTo) {
return incorrectUsageMsg(c, errFmtSameBucket, commandRename, bckTo)
return incorrectUsageMsg(c, errFmtSameBucket, commandRename, bckTo.Cname(""))
}
return mvBucket(c, bckFrom, bckTo)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/cli/cpr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters.
/*
* Copyright (c) 2023-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2023-2025, NVIDIA CORPORATION. All rights reserved.
*/
package cli

Expand Down Expand Up @@ -59,7 +59,7 @@ func (cpr *cprCtx) copyBucket(c *cli.Context, bckFrom, bckTo cmn.Bck, msg *apc.C
// 2. got bucket summary(ies)
summaries := ctx.res
for _, res := range summaries {
debug.Assertf(res.Bck.Equal(&bckFrom), "%s != %s", res.Bck, bckFrom)
debug.Assertf(res.Bck.Equal(&bckFrom), "%s != %s", res.Bck.String(), bckFrom.String())
cpr.totals.size += int64(res.TotalSize.PresentObjs + res.TotalSize.RemoteObjs)
cpr.totals.objs += int64(res.ObjCount.Present + res.ObjCount.Remote)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/cli/job_hdlr.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ func startDownloadHandler(c *cli.Context) error {
}
if !p.BackendBck.Equal(&source.backend.bck) {
warn := fmt.Sprintf("%s does not have Cloud bucket %s as its *backend* - proceeding to download anyway.",
basePayload.Bck, source.backend.bck)
basePayload.Bck.String(), source.backend.bck.String())
actionWarn(c, warn)
dlType = dload.TypeSingle
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/cli/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ func listObjects(c *cli.Context, bck cmn.Bck, prefix string, listArch, printEmpt
}
if flagIsSet(c, verChangedFlag) {
if bck.IsAIS() {
return fmt.Errorf("flag %s requires remote bucket (have: %s)", qflprn(verChangedFlag), bck)
return fmt.Errorf("flag %s requires remote bucket (have: %s)", qflprn(verChangedFlag), bck.String())
}
if !bck.HasVersioningMD() {
return fmt.Errorf("flag %s only applies to remote backends that maintain at least some form of versioning information (have: %s)",
qflprn(verChangedFlag), bck)
qflprn(verChangedFlag), bck.String())
}
msg.SetFlag(apc.LsVerChanged)
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/cli/cli/multiobj.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func runTCO(c *cli.Context, bckFrom, bckTo cmn.Bck, listObjs, tmplObjs, etlName
}
xargs := xact.ArgsMsg{ID: xid, Kind: xkind, Timeout: timeout}
if err = waitXact(&xargs); err != nil {
fmt.Fprintf(c.App.ErrWriter, fmtXactFailed, text, bckFrom, bckTo)
fmt.Fprintf(c.App.ErrWriter, fmtXactFailed, text, bckFrom.String(), bckTo.String())
} else {
fmt.Fprint(c.App.Writer, fmtXactSucceeded)
}
Expand Down Expand Up @@ -251,7 +251,7 @@ func _rmOne(c *cli.Context, shift int) error {
case oltp.objName == "": // 2. all objects
if flagIsSet(c, rmrfFlag) {
if !flagIsSet(c, yesFlag) {
warn := fmt.Sprintf("will remove all objects from %s. The operation cannot be undone!", bck)
warn := fmt.Sprintf("will remove all objects from %s. The operation cannot be undone!", bck.String())
if ok := confirm(c, "Proceed?", warn); !ok {
return nil
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/cli/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func rmRfAllObjects(c *cli.Context, bck cmn.Bck) error {
debug.Assert(errCnt64 > 0)
firstErr := <-errCh
warn := fmt.Sprintf("failed to delete %d object%s from %s: (%d deleted, %d error%s)\n", l-cnt, cos.Plural(l-cnt),
bck, cnt, errCnt64, cos.Plural(int(errCnt64)))
bck.String(), cnt, errCnt64, cos.Plural(int(errCnt64)))
actionWarn(c, warn)
return firstErr
}
4 changes: 2 additions & 2 deletions cmd/cli/cli/object_hdlr.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Package cli provides easy-to-use commands to manage, monitor, and utilize AIS clusters.
/*
* Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2025, NVIDIA CORPORATION. All rights reserved.
*/
package cli

Expand Down Expand Up @@ -289,7 +289,7 @@ func mvObjectHandler(c *cli.Context) (err error) {

if bckDst, objDst, err := parseBckObjURI(c, newObj, false); err == nil && bckDst.Name != "" {
if !bckDst.Equal(&bck) {
return incorrectUsageMsg(c, "moving an object to another bucket(%s) is not supported", bckDst)
return incorrectUsageMsg(c, "moving an object to another bucket (%s) is not supported", bckDst.Cname(""))
}
if oldObj == "" {
return missingArgumentsError(c, "no object specified in %q", newObj)
Expand Down
Loading

0 comments on commit d8ae4af

Please sign in to comment.