mirror of https://github.com/coder/coder.git
fix(cli): remove exp scaletest from slim binary (#9934)
- Removes the `exp scaletest` command from the slim binary - Updates scaletest-runner template to fetch the full binary from the running Coder instance
This commit is contained in:
parent
45b53c285f
commit
9aac15212b
|
@ -1,3 +1,5 @@
|
|||
//go:build !slim
|
||||
|
||||
package cli
|
||||
|
||||
import (
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
//go:build slim
|
||||
|
||||
package cli
|
||||
|
||||
import "github.com/coder/coder/v2/cli/clibase"
|
||||
|
||||
func (r *RootCmd) scaletestCmd() *clibase.Cmd {
|
||||
cmd := &clibase.Cmd{
|
||||
Use: "scaletest",
|
||||
Short: "Run a scale test against the Coder API",
|
||||
Handler: func(inv *clibase.Invocation) error {
|
||||
SlimUnsupported(inv.Stderr, "exp scaletest")
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
return cmd
|
||||
}
|
|
@ -20,7 +20,6 @@ ARCH="$(arch)"
|
|||
if [[ "$ARCH" == "x86_64" ]]; then
|
||||
ARCH="amd64"
|
||||
fi
|
||||
PLATFORM="$(uname | tr '[:upper:]' '[:lower:]')"
|
||||
|
||||
if [[ -f "${CONFIG_DIR}/coder.env" ]]; then
|
||||
echo "Found existing coder.env in ${CONFIG_DIR}!"
|
||||
|
@ -29,8 +28,20 @@ if [[ -f "${CONFIG_DIR}/coder.env" ]]; then
|
|||
fi
|
||||
|
||||
maybedryrun "$DRY_RUN" mkdir -p "${CONFIG_DIR}"
|
||||
echo "Fetching Coder CLI for first-time setup!"
|
||||
maybedryrun "$DRY_RUN" curl -fsSLk "${CODER_URL}/bin/coder-${PLATFORM}-${ARCH}" -o "${CONFIG_DIR}/coder"
|
||||
echo "Fetching Coder for first-time setup!"
|
||||
pod=$(kubectl get pods \
|
||||
--namespace="${NAMESPACE}" \
|
||||
--selector="app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \
|
||||
--output="jsonpath='{.items[0].metadata.name}'")
|
||||
if [[ -z ${pod} ]]; then
|
||||
log "Could not find coder pod!"
|
||||
exit 1
|
||||
fi
|
||||
maybedryrun "$DRY_RUN" kubectl \
|
||||
--namespace="${NAMESPACE}" \
|
||||
cp \
|
||||
--container=coder \
|
||||
"${pod}:/opt/coder" "${CONFIG_DIR}/coder"
|
||||
maybedryrun "$DRY_RUN" chmod +x "${CONFIG_DIR}/coder"
|
||||
|
||||
set +o pipefail
|
||||
|
|
|
@ -20,11 +20,17 @@ SCALETEST_PHASE_FILE="${SCALETEST_STATE_DIR}/phase"
|
|||
# shellcheck disable=SC2034
|
||||
SCALETEST_RESULTS_DIR="${SCALETEST_RUN_DIR}/results"
|
||||
SCALETEST_PPROF_DIR="${SCALETEST_RUN_DIR}/pprof"
|
||||
# https://github.com/kubernetes/kubernetes/issues/72501 :-(
|
||||
SCALETEST_CODER_BINARY="/tmp/coder-full-${SCALETEST_RUN_ID//:/-}"
|
||||
|
||||
mkdir -p "${SCALETEST_STATE_DIR}" "${SCALETEST_RESULTS_DIR}" "${SCALETEST_PPROF_DIR}"
|
||||
|
||||
coder() {
|
||||
maybedryrun "${DRY_RUN}" command coder "${@}"
|
||||
if [[ ! -x "${SCALETEST_CODER_BINARY}" ]]; then
|
||||
log "Fetching full coder binary..."
|
||||
fetch_coder_full
|
||||
fi
|
||||
maybedryrun "${DRY_RUN}" "${SCALETEST_CODER_BINARY}" "${@}"
|
||||
}
|
||||
|
||||
show_json() {
|
||||
|
@ -240,3 +246,36 @@ set_appearance() {
|
|||
--data "${newjson}" \
|
||||
"${CODER_URL}/api/v2/appearance"
|
||||
}
|
||||
|
||||
# fetch_coder_full fetches the full (non-slim) coder binary from one of the coder pods
|
||||
# running in the same namespace as the current pod.
|
||||
fetch_coder_full() {
|
||||
if [[ -x "${SCALETEST_CODER_BINARY}" ]]; then
|
||||
log "Full Coder binary already exists at ${SCALETEST_CODER_BINARY}"
|
||||
return
|
||||
fi
|
||||
local pod
|
||||
local namespace
|
||||
namespace=$(</var/run/secrets/kubernetes.io/serviceaccount/namespace)
|
||||
if [[ -z "${namespace}" ]]; then
|
||||
log "Could not determine namespace!"
|
||||
exit 1
|
||||
fi
|
||||
log "Namespace from serviceaccount token is ${namespace}"
|
||||
pod=$(kubectl get pods \
|
||||
--namespace "${namespace}" \
|
||||
--selector "app.kubernetes.io/name=coder,app.kubernetes.io/part-of=coder" \
|
||||
--output jsonpath='{.items[0].metadata.name}')
|
||||
if [[ -z ${pod} ]]; then
|
||||
log "Could not find coder pod!"
|
||||
exit 1
|
||||
fi
|
||||
log "Fetching full Coder binary from ${pod}"
|
||||
maybedryrun "${DRY_RUN}" kubectl \
|
||||
--namespace "${namespace}" \
|
||||
cp \
|
||||
--container coder \
|
||||
"${pod}:/opt/coder" "${SCALETEST_CODER_BINARY}"
|
||||
maybedryrun "${DRY_RUN}" chmod +x "${SCALETEST_CODER_BINARY}"
|
||||
log "Full Coder binary downloaded to ${SCALETEST_CODER_BINARY}"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue