Skip to content

Commit

Permalink
chore: remove old mutagen sync method coda paths (#6637)
Browse files Browse the repository at this point in the history
* chore: remove old mutagen sync method coda paths

* chore: fix build and lint errors

* docs: update code syncing guide

* chore(docs): fix the version number

---------

Co-authored-by: Vladimir Vagaytsev <[email protected]>
  • Loading branch information
10ko and vvagaytsev authored Nov 19, 2024
1 parent 7f94571 commit 578abfd
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 213 deletions.
1 change: 0 additions & 1 deletion core/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ export const gardenEnv = {
.required(false)
.default("https://get.garden.io/releases")
.asUrlString(),
GARDEN_ENABLE_NEW_SYNC: env.get("GARDEN_ENABLE_NEW_SYNC").required(false).default("true").asBool(),
// GARDEN_CLOUD_BUILDER will always override the config; That's why it doesn't have a default.
// FIXME: If the environment variable is not set, asBool returns undefined, unlike the type suggests. That's why we cast to `boolean | undefined`.
GARDEN_CLOUD_BUILDER: env.get("GARDEN_CLOUD_BUILDER").required(false).asBool() as boolean | undefined,
Expand Down
202 changes: 58 additions & 144 deletions core/src/mutagen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import pRetry, { type FailedAttemptError } from "p-retry"
import { join } from "path"
import respawn from "respawn"
import split2 from "split2"
import { GARDEN_GLOBAL_PATH, gardenEnv, MUTAGEN_DIR_NAME } from "./constants.js"
import { GARDEN_GLOBAL_PATH, MUTAGEN_DIR_NAME } from "./constants.js"
import { ChildProcessError, GardenError } from "./exceptions.js"
import pMemoize from "./lib/p-memoize.js"
import type { Log } from "./logger/log-entry.js"
Expand All @@ -31,7 +31,6 @@ import { styles } from "./logger/styles.js"
import { dirname } from "node:path"
import { makeDocsLinkStyled } from "./docs/common.js"
import { syncGuideRelPath } from "./plugins/kubernetes/constants.js"
import { emitNonRepeatableWarning } from "./warnings.js"

const { mkdirp, pathExists } = fsExtra

Expand Down Expand Up @@ -325,8 +324,8 @@ class _MutagenMonitor extends TypedEventEmitter<MonitorEvents> {
}

function logMutagenDaemonWarning(log: Log) {
const daemonStopCommand = `GARDEN_ENABLE_NEW_SYNC=${!gardenEnv.GARDEN_ENABLE_NEW_SYNC} garden util mutagen daemon stop`
const redeploySyncCommand = `GARDEN_ENABLE_NEW_SYNC=${gardenEnv.GARDEN_ENABLE_NEW_SYNC} garden deploy --sync`
const daemonStopCommand = `garden util mutagen daemon stop`
const redeploySyncCommand = `garden deploy --sync`

log.warn(
deline`
Expand Down Expand Up @@ -369,17 +368,6 @@ export class Mutagen {
this.activeSyncs = {}
this.monitoring = false

emitNonRepeatableWarning(
this.log,
deline`
Warning!\n
Starting from 0.13.34, Garden uses the new sync daemon.
Thus, the default value of the \`GARDEN_ENABLE_NEW_SYNC\` environment variable is \`true\` now.\n
Please make sure you have tested the new sync daemon. See the troubleshooting docs for more details: ${makeDocsLinkStyled("guides/code-synchronization", "#restarting-sync-daemon")}\n`
)

// TODO: This is a little noisy atm. We could be a bit smarter and filter some superfluous messages out.
this.monitorHandler = (session) => {
const key = session.name
Expand Down Expand Up @@ -940,137 +928,68 @@ export function parseSyncListResult(res: ExecaReturnValue): SyncSession[] {
return parsed
}

const mutagenVersionLegacy = "0.15.0"
const mutagenVersionNative = "0.17.6"

export const mutagenVersion = gardenEnv.GARDEN_ENABLE_NEW_SYNC ? mutagenVersionNative : mutagenVersionLegacy

export function mutagenCliSpecLegacy(): PluginToolSpec {
return {
name: "mutagen",
version: mutagenVersionLegacy,
description: `The mutagen synchronization tool, v${mutagenVersionLegacy}`,
type: "binary",
_includeInGardenImage: false,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: `https://github.com/garden-io/mutagen/releases/download/v${mutagenVersionLegacy}-garden-1/mutagen_darwin_amd64_v${mutagenVersionLegacy}.tar.gz`,
sha256: "370bf71e28f94002453921fda83282280162df7192bd07042bf622bf54507e3f",
extract: {
format: "tar",
targetPath: "mutagen",
},
},
{
platform: "darwin",
architecture: "arm64",
url: `https://github.com/garden-io/mutagen/releases/download/v${mutagenVersionLegacy}-garden-1/mutagen_darwin_arm64_v${mutagenVersionLegacy}.tar.gz`,
sha256: "a0a7be8bb37266ea184cb580004e1741a17c8165b2032ce4b191f23fead821a0",
extract: {
format: "tar",
targetPath: "mutagen",
},
},
{
platform: "linux",
architecture: "amd64",
url: `https://github.com/garden-io/mutagen/releases/download/v${mutagenVersionLegacy}-garden-1/mutagen_linux_amd64_v${mutagenVersionLegacy}.tar.gz`,
sha256: "e8c0708258ddd6d574f1b8f514fb214f9ab5d82aed38dd8db49ec10956e5063a",
extract: {
format: "tar",
targetPath: "mutagen",
},
},
{
platform: "linux",
architecture: "arm64",
url: `https://github.com/garden-io/mutagen/releases/download/v${mutagenVersionLegacy}-garden-1/mutagen_linux_arm64_v${mutagenVersionLegacy}.tar.gz`,
sha256: "80f108fc316223d8c3d1a48def18192e666b33a334b75aa3ebcc95938b774e64",
extract: {
format: "tar",
targetPath: "mutagen",
},
},
{
platform: "windows",
architecture: "amd64",
url: `https://github.com/garden-io/mutagen/releases/download/v${mutagenVersionLegacy}-garden-1/mutagen_windows_amd64_v${mutagenVersionLegacy}.zip`,
sha256: "fdae26b43cc418b2525a937a1613bba36e74ea3dde4dbec3512a9abd004def95",
extract: {
format: "zip",
targetPath: "mutagen.exe",
},
},
],
}
}
export const mutagenVersion = "0.17.6"

export function mutagenCliSpecNative(): PluginToolSpec {
return {
name: "mutagen",
version: mutagenVersionNative,
description: `The mutagen synchronization tool, v${mutagenVersionNative}`,
type: "binary",
_includeInGardenImage: false,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersionNative}/mutagen_darwin_amd64_v${mutagenVersionNative}.tar.gz`,
sha256: "f082eef2ae405a6bf5effdbcd000bb5fe2bc7b0968f86b2b54d9d3260c48c739",
extract: {
format: "tar",
targetPath: "mutagen",
},
export const mutagenCliSpec: PluginToolSpec = {
name: "mutagen",
version: mutagenVersion,
description: `The mutagen synchronization tool, v${mutagenVersion}`,
type: "binary",
_includeInGardenImage: false,
builds: [
{
platform: "darwin",
architecture: "amd64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersion}/mutagen_darwin_amd64_v${mutagenVersion}.tar.gz`,
sha256: "f082eef2ae405a6bf5effdbcd000bb5fe2bc7b0968f86b2b54d9d3260c48c739",
extract: {
format: "tar",
targetPath: "mutagen",
},
{
platform: "darwin",
architecture: "arm64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersionNative}/mutagen_darwin_arm64_v${mutagenVersionNative}.tar.gz`,
sha256: "b6c35942ca9cbbbf726bfa249da554d829a8a28cad620a55e02d098d692121d1",
extract: {
format: "tar",
targetPath: "mutagen",
},
},
{
platform: "darwin",
architecture: "arm64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersion}/mutagen_darwin_arm64_v${mutagenVersion}.tar.gz`,
sha256: "b6c35942ca9cbbbf726bfa249da554d829a8a28cad620a55e02d098d692121d1",
extract: {
format: "tar",
targetPath: "mutagen",
},
{
platform: "linux",
architecture: "amd64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersionNative}/mutagen_linux_amd64_v${mutagenVersionNative}.tar.gz`,
sha256: "1b826e121be59506e133d90dc2b8a0c820b92f480d9b2b230d8b389d6178a6cf",
extract: {
format: "tar",
targetPath: "mutagen",
},
},
{
platform: "linux",
architecture: "amd64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersion}/mutagen_linux_amd64_v${mutagenVersion}.tar.gz`,
sha256: "1b826e121be59506e133d90dc2b8a0c820b92f480d9b2b230d8b389d6178a6cf",
extract: {
format: "tar",
targetPath: "mutagen",
},
{
platform: "linux",
architecture: "arm64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersionNative}/mutagen_linux_arm64_v${mutagenVersionNative}.tar.gz`,
sha256: "2a383cb572a1bdad83f7c4be3cc4a541a58e6c9e11e326ee4cc2d0e14f9d003a",
extract: {
format: "tar",
targetPath: "mutagen",
},
},
{
platform: "linux",
architecture: "arm64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersion}/mutagen_linux_arm64_v${mutagenVersion}.tar.gz`,
sha256: "2a383cb572a1bdad83f7c4be3cc4a541a58e6c9e11e326ee4cc2d0e14f9d003a",
extract: {
format: "tar",
targetPath: "mutagen",
},
{
platform: "windows",
architecture: "amd64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersionNative}/mutagen_windows_amd64_v${mutagenVersionNative}.zip`,
sha256: "3019ccb556afb39cf2213adcacab97576c4419f8d08d3a55d063a5c773ec6d35",
extract: {
format: "zip",
targetPath: "mutagen.exe",
},
},
{
platform: "windows",
architecture: "amd64",
url: `https://github.com/mutagen-io/mutagen/releases/download/v${mutagenVersion}/mutagen_windows_amd64_v${mutagenVersion}.zip`,
sha256: "3019ccb556afb39cf2213adcacab97576c4419f8d08d3a55d063a5c773ec6d35",
extract: {
format: "zip",
targetPath: "mutagen.exe",
},
],
}
},
],
}

export const mutagenCliSpec = gardenEnv.GARDEN_ENABLE_NEW_SYNC ? mutagenCliSpecNative() : mutagenCliSpecLegacy()

export const mutagenCli = new PluginTool(mutagenCliSpec)

const mutagenFauxSshVersion = "v0.0.1"
Expand Down Expand Up @@ -1139,14 +1058,9 @@ export const mutagenFauxSshSpec: PluginToolSpec = {
export const mutagenFauxSsh = new PluginTool(mutagenFauxSshSpec)

/**
* Returns the path to the location of the faux SSH Mutagen transport if the original Mutagen is used
* (i.e. if {@code GARDEN_ENABLE_NEW_SYNC=true}) or {@code undefined} otherwise.
* Returns the path to the location of the faux SSH Mutagen transport
*/
async function getMutagenSshPath(log: Log): Promise<string | undefined> {
if (!gardenEnv.GARDEN_ENABLE_NEW_SYNC) {
return undefined
}

const fauxSshToolPath = await mutagenFauxSsh.ensurePath(log)
// This must be the dir containing the faux SSH binary,
// not the full path that includes the binary name.
Expand Down
13 changes: 2 additions & 11 deletions core/src/plugins/kubernetes/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

import type { DockerImageWithDigest } from "../../util/string.js"
import { gardenEnv } from "../../constants.js"
import { makeDocsLinkPlain } from "../../docs/common.js"

export const MAX_CONFIGMAP_DATA_SIZE = 1024 * 1024 // max ConfigMap data size is 1MB
Expand Down Expand Up @@ -48,25 +47,17 @@ function makeImagePath({
}

export function getK8sUtilImagePath(registryDomain: string): DockerImageWithDigest {
const k8sUtilImageNameLegacy: DockerImageWithDigest =
"gardendev/k8s-util:0.5.7@sha256:522da245a5e6ae7c711aa94f84fc83f82a8fdffbf6d8bc48f4d80fee0e0e631b"
const k8sUtilImageName: DockerImageWithDigest =
"gardendev/k8s-util:0.6.2@sha256:f51e7ce040e2e23bc0eaa7216e4d976f13786d96773ef7b8c8f349e7a63d74e9"

return gardenEnv.GARDEN_ENABLE_NEW_SYNC
? makeImagePath({ imageName: k8sUtilImageName, registryDomain })
: makeImagePath({ imageName: k8sUtilImageNameLegacy, registryDomain })
return makeImagePath({ imageName: k8sUtilImageName, registryDomain })
}

export function getK8sSyncUtilImagePath(registryDomain: string): DockerImageWithDigest {
const k8sSyncUtilImageName: DockerImageWithDigest =
"gardendev/k8s-sync:0.2.2@sha256:9ebcd84df4a3a55ae0ba95051cab521d249a4d2d7a15d04da7301c888c02347b"
const k8sSyncUtilImageNameLegacy: DockerImageWithDigest =
"gardendev/k8s-sync:0.1.5@sha256:28263cee5ac41acebb8c08f852c4496b15e18c0c94797d7a949a4453b5f91578"

return gardenEnv.GARDEN_ENABLE_NEW_SYNC
? makeImagePath({ imageName: k8sSyncUtilImageName, registryDomain })
: makeImagePath({ imageName: k8sSyncUtilImageNameLegacy, registryDomain })
return makeImagePath({ imageName: k8sSyncUtilImageName, registryDomain })
}

export function getK8sReverseProxyImagePath(registryDomain: string): DockerImageWithDigest {
Expand Down
48 changes: 1 addition & 47 deletions core/src/plugins/kubernetes/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import { convertServiceResource } from "./kubernetes-type/common.js"
import { prepareConnectionOpts } from "./kubectl.js"
import type { GetSyncStatusResult, SyncState, SyncStatus } from "../../plugin/handlers/Deploy/get-sync-status.js"
import { ConfigurationError } from "../../exceptions.js"
import { gardenEnv } from "../../constants.js"
import { styles } from "../../logger/styles.js"
import { commandListToShellScript } from "../../util/escape.js"
import { toClearText } from "../../util/secrets.js"
Expand Down Expand Up @@ -985,48 +984,7 @@ export function makeSyncConfig({
}
}

async function getKubectlExecDestinationLegacy({
ctx,
log,
namespace,
containerName,
resourceName,
targetPath,
}: {
ctx: KubernetesPluginContext
log: Log
namespace: string
containerName: string
resourceName: string
targetPath: string
}) {
const kubectl = ctx.tools["kubernetes.kubectl"]
const kubectlPath = await kubectl.ensurePath(log)

const connectionOpts = prepareConnectionOpts({
provider: ctx.provider,
namespace,
})

const command = [
kubectlPath,
"exec",
"-i",
...connectionOpts,
"--container",
containerName,
resourceName,
"--",
mutagenAgentPath,
"synchronizer",
]

log.debug("Using legacy Mutagen (Garden fork)")

return `exec:'${command.join(" ")}':${targetPath}`
}

async function getKubectlExecDestinationNative({
export async function getKubectlExecDestination({
ctx,
log,
namespace,
Expand Down Expand Up @@ -1074,8 +1032,4 @@ async function getKubectlExecDestinationNative({
return `${hostname}:${targetPath}`
}

export const getKubectlExecDestination = gardenEnv.GARDEN_ENABLE_NEW_SYNC
? getKubectlExecDestinationNative
: getKubectlExecDestinationLegacy

const isReverseMode = (mode: string) => mode === "one-way-reverse" || mode === "one-way-replica-reverse"
4 changes: 2 additions & 2 deletions core/test/unit/src/verify-ext-tool-binary-hashes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { mutagenCliSpecLegacy, mutagenCliSpecNative, mutagenFauxSshSpec } from "../../../src/mutagen.js"
import { mutagenCliSpec, mutagenFauxSshSpec } from "../../../src/mutagen.js"
import { kubectlSpec } from "../../../src/plugins/kubernetes/kubectl.js"
import { kustomize4Spec, kustomize5Spec } from "../../../src/plugins/kubernetes/kubernetes-type/kustomize.js"
import { helmSpec } from "../../../src/plugins/kubernetes/helm/helm-cli.js"
Expand All @@ -22,7 +22,7 @@ describe("regctlCLI binaries", () => {
})

describe("Mutagen binaries", () => {
downloadBinariesAndVerifyHashes([mutagenCliSpecNative(), mutagenCliSpecLegacy()])
downloadBinariesAndVerifyHashes([mutagenCliSpec])
})

describe("Mutagen faux SSH binaries", () => {
Expand Down
Loading

0 comments on commit 578abfd

Please sign in to comment.