Skip to content

Commit

Permalink
improvement(k8s): more robust and useful deployment status checks
Browse files Browse the repository at this point in the history
This combines a general refactor of our workload status checks, more
robust checking of related resource statuses (in order to fail fast on
common errors like ImagePullBackOff and CrashLoopBackOff), as well as an
improvement on the level of information given when errors do come up.

This should aid considerably in debugging deployment issues.

Closes #863
  • Loading branch information
edvald authored and thsig committed Jun 24, 2019
1 parent 61e6dad commit 4f1ff3b
Show file tree
Hide file tree
Showing 16 changed files with 779 additions and 681 deletions.
2 changes: 1 addition & 1 deletion garden-service/src/logger/renderers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const cliPadEnd = (s: string, width: number): string => {
const truncateSection = (s: string) => cliTruncate(s, SECTION_PREFIX_WIDTH)
const sectionStyle = (s: string) => chalk.cyan.italic(cliPadEnd(truncateSection(s), SECTION_PREFIX_WIDTH))
export const msgStyle = (s: string) => hasAnsi(s) ? s : chalk.gray(s)
export const errorStyle = chalk.red
export const errorStyle = (s: string) => hasAnsi(s) ? s : chalk.red(s)

/*** RENDER HELPERS ***/
function insertVal(out: string[], idx: number, toRender: Function | string, renderArgs: any[]): string[] {
Expand Down
3 changes: 2 additions & 1 deletion garden-service/src/plugins/kubernetes/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,8 @@ export class KubeApi {
? `${basePath}/namespaces/${namespace}/${resource.name}/${name}`
: `${basePath}/${resource.name}/${name}`

return this.request(log, apiPath)
const res = await this.request(log, apiPath)
return res.body
}

async upsert<K extends keyof CrudMapType>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { RuntimeContext, Service, ServiceStatus } from "../../../types/service"
import { ContainerModule, ContainerService } from "../../container/config"
import { createIngressResources } from "./ingress"
import { createServiceResources } from "./service"
import { waitForResources } from "../status"
import { waitForResources } from "../status/status"
import { apply, deleteObjectsByLabel } from "../kubectl"
import { getAppNamespace } from "../namespace"
import { PluginContext } from "../../../plugin-context"
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/plugins/kubernetes/container/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { sleep } from "../../../util/util"
import { GetServiceStatusParams } from "../../../types/plugin/service/getServiceStatus"
import { ContainerModule } from "../../container/config"
import { KubeApi } from "../api"
import { compareDeployedObjects } from "../status"
import { compareDeployedObjects } from "../status/status"
import { getIngresses } from "./ingress"
import { getAppNamespace } from "../namespace"
import { KubernetesPluginContext } from "../config"
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/plugins/kubernetes/helm/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { ServiceStatus } from "../../../types/service"
import { getAppNamespace } from "../namespace"
import { waitForResources } from "../status"
import { waitForResources } from "../status/status"
import { helm } from "./helm-cli"
import { HelmModule } from "./config"
import {
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/plugins/kubernetes/helm/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import { ServiceStatus, ServiceState } from "../../../types/service"
import { GetServiceStatusParams } from "../../../types/plugin/service/getServiceStatus"
import { getExecModuleBuildStatus } from "../../exec"
import { compareDeployedObjects } from "../status"
import { compareDeployedObjects } from "../status/status"
import { KubeApi } from "../api"
import { getAppNamespace } from "../namespace"
import { LogEntry } from "../../../logger/log-entry"
Expand Down
2 changes: 1 addition & 1 deletion garden-service/src/plugins/kubernetes/helm/tiller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { helm } from "./helm-cli"
import { safeLoadAll } from "js-yaml"
import { KubeApi } from "../api"
import { getAppNamespace } from "../namespace"
import { checkResourceStatuses, waitForResources } from "../status"
import { checkResourceStatuses, waitForResources } from "../status/status"
import { combineStates } from "../../../types/service"
import { apply } from "../kubectl"
import { KubernetesProvider } from "../config"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { getNamespace, getAppNamespace } from "../namespace"
import { KubernetesPluginContext } from "../config"
import { KubernetesResource } from "../types"
import { ServiceStatus } from "../../../types/service"
import { compareDeployedObjects, waitForResources } from "../status"
import { compareDeployedObjects, waitForResources } from "../status/status"
import { KubeApi } from "../api"
import { ModuleAndRuntimeActions } from "../../../types/plugin/plugin"
import { getAllLogs } from "../logs"
Expand Down
Loading

0 comments on commit 4f1ff3b

Please sign in to comment.