Skip to content

Commit

Permalink
assorted minor
Browse files Browse the repository at this point in the history
* CLI build: actually pass build tags
* Go API head-bucket: err status when response is nil; remove type-cast assert
* aisloader: properly validate '--ip' command line vs 'AIS_ENDPOINT' env var
* touch deploy.sh (local playground)

Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Oct 26, 2023
1 parent 0d1d354 commit a5fc8be
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ cli: ## Build CLI binary. NOTE: 1) a separate go.mod, 2) static linkage with cgo
@echo "Building ais (CLI) => $(BUILD_DEST)/ais [build tags:$(BUILD_TAGS)]"
ifdef CROSS_COMPILE_CLI
cd $(BUILD_DIR)/cli && \
$(CROSS_COMPILE_CLI) go build -o ./ais $(BUILD_FLAGS) $(LDFLAGS) *.go && mv ./ais $(BUILD_DEST)/.
$(CROSS_COMPILE_CLI) go build -o ./ais -tags="$(BUILD_TAGS)" $(BUILD_FLAGS) $(LDFLAGS) *.go && mv ./ais $(BUILD_DEST)/.
else
@cd $(BUILD_DIR)/cli && $(CGO_DISABLE) go build -o $(BUILD_DEST)/ais $(BUILD_FLAGS) $(LDFLAGS) *.go
@cd $(BUILD_DIR)/cli && $(CGO_DISABLE) go build -o $(BUILD_DEST)/ais -tags="$(BUILD_TAGS)" $(BUILD_FLAGS) $(LDFLAGS) *.go
endif
@echo "*** To enable autocompletions in your current shell, run:"
ifeq ($(AISTORE_PATH),$(PWD))
Expand Down
1 change: 0 additions & 1 deletion api/bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ func HeadBucket(bp BaseParams, bck cmn.Bck, dontAddRemote bool) (p *cmn.Bprops,
func hdr2msg(bck cmn.Bck, status int, err error) error {
herr, ok := err.(*cmn.ErrHTTP)
if !ok {
debug.FailTypeCast(err)
return err
}
debug.Assert(herr.Status == status)
Expand Down
11 changes: 7 additions & 4 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,15 @@ func (reqParams *ReqParams) DoRequest() error {
}

// same as above except that it also returns response header
func (reqParams *ReqParams) doReqHdr() (http.Header, int, error) {
func (reqParams *ReqParams) doReqHdr() (_ http.Header, status int, _ error) {
resp, err := reqParams.do()
if err != nil {
return nil, resp.StatusCode, err
if err == nil {
return resp.Header, resp.StatusCode, reqParams.cdc(resp)
}
if resp != nil {
status = resp.StatusCode
}
return resp.Header, resp.StatusCode, reqParams.cdc(resp)
return nil, status, err
}

// Makes request via do(), decodes `resp.Body` into the `out` structure,
Expand Down
9 changes: 6 additions & 3 deletions bench/tools/aisloader/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ const (
wo2FreeDelay = 3*time.Second + time.Millisecond

ua = "aisloader"

defaultClusterIP = "localhost"
defaultClusterIPv4 = "127.0.0.1"
)

type (
Expand Down Expand Up @@ -501,7 +504,7 @@ func addCmdLine(f *flag.FlagSet, p *params) {
f.StringVar(&p.bck.Provider, "provider", apc.AIS,
"ais - for AIS bucket, \"aws\", \"azure\", \"gcp\", \"hdfs\" for Azure, Amazon, Google, and HDFS clouds respectively")

f.StringVar(&ip, "ip", "localhost", "AIS proxy/gateway IP address or hostname")
f.StringVar(&ip, "ip", defaultClusterIP, "AIS proxy/gateway IP address or hostname")
f.StringVar(&port, "port", "8080", "AIS proxy/gateway port")

//
Expand Down Expand Up @@ -676,7 +679,7 @@ func validateCmdLine(p *params) (err error) {
if p.randomProxy {
return errors.New("command line options '-s3endpoint' and '-randomproxy' are mutually exclusive")
}
if ip != "" && ip != "localhost" && ip != "127.0.0.1" { // TODO: hardcoded default
if ip != "" && ip != defaultClusterIP && ip != defaultClusterIPv4 {
return errors.New("command line options '-s3endpoint' and '-ip' are mutually exclusive")
}
if port != "" && port != "8080" { // TODO: ditto
Expand Down Expand Up @@ -858,7 +861,7 @@ func validateCmdLine(p *params) (err error) {
// see also: tlsArgs
envEndpoint = os.Getenv(env.AIS.Endpoint)
if envEndpoint != "" {
if ip != "" {
if ip != "" && ip != defaultClusterIP && ip != defaultClusterIPv4 {
return fmt.Errorf("'%s=%s' environment and '--ip=%s' command-line are mutually exclusive",
env.AIS.Endpoint, envEndpoint, ip)
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/cli/cli/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,10 @@ func propVal(op *cmn.ObjectProps, name string) (v string) {
}
case apc.GetPropsLocation:
v = op.Location
case apc.GetPropsStatus:
// no "object status" in `cmn.ObjectProps` - nothing to do (see also: `cmn.LsoEntry`)
default:
debug.Assert(false, name)
debug.Assert(false, "obj prop name: \""+name+"\"")
}
return
}
Expand Down
5 changes: 4 additions & 1 deletion cmd/cli/cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,10 @@ func headBucket(bck cmn.Bck, dontAddBckMD bool) (p *cmn.Bprops, err error) {
err = fmt.Errorf("failed to HEAD bucket %q: %s", bck, herr.Message)
}
} else {
err = fmt.Errorf("failed to HEAD bucket %q: %v", bck, err)
msg := strings.ToLower(err.Error())
if !strings.HasPrefix(msg, "head \"http") && !strings.HasPrefix(msg, "head http") {
err = fmt.Errorf("failed to HEAD bucket %q: %v", bck, err)
}
}
return
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/cli/cli/xact.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func toShowMsg(c *cli.Context, xjid, prompt string, verbose bool) string {
// Wait for the caller's started xaction to run until finished _or_ idle (NOTE),
// warn if aborted
func waitXact(apiBP api.BaseParams, args xact.ArgsMsg) error {
debug.Assert(xact.IsValidUUID(args.ID))
debug.Assert(args.ID == "" || xact.IsValidUUID(args.ID))
kind, xname := xact.GetKindName(args.Kind)
debug.Assert(kind != "") // relying on it to decide between APIs
if xact.IdlesBeforeFinishing(kind) {
Expand Down
9 changes: 7 additions & 2 deletions cmn/debug/debug_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ package debug
import (
"bytes"
"expvar"
"flag"
"fmt"
"net/http"
"net/http/pprof"
Expand Down Expand Up @@ -55,8 +56,12 @@ func _panic(a ...any) {
fmt.Fprintf(buffer, "%s:%d", f, line)
}
}
nlog.Errorf("%s", buffer.Bytes())
nlog.Flush(true)
if flag.Parsed() {
nlog.Errorln(buffer.String())
nlog.Flush(true)
} else {
fmt.Fprintln(os.Stderr, buffer.String())
}
panic(msg)
}

Expand Down
3 changes: 3 additions & 0 deletions deploy/dev/local/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ if command -v pgrep &> /dev/null; then
run_count=$(pgrep -a aisnode | grep -c "${NEXT_TIER}")
if [[ "${run_count}" -eq $((TARGET_CNT + PROXY_CNT)) ]]; then
echo "${listening_on}"
if [[ -z $DEPLOY_AS_NEXT_TIER ]]; then
echo "Primary endpoint: ${AIS_PRIMARY_URL}"
fi
fi
else
echo "Warning: pgrep not found"
Expand Down

0 comments on commit a5fc8be

Please sign in to comment.