Skip to content

Commit

Permalink
fix(k8s): warn instead of error when cluster services are outdated
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Jun 3, 2019
1 parent 6c25b84 commit c7b0130
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
16 changes: 13 additions & 3 deletions garden-service/src/plugins/kubernetes/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { KubernetesPluginContext, KubernetesConfig } from "./config"
import { checkTillerStatus, installTiller } from "./helm/tiller"
import {
prepareSystemServices,
getSystemServiceStatuses,
getSystemServiceStatus,
getSystemGarden,
systemNamespaceUpToDate,
systemNamespace,
Expand Down Expand Up @@ -68,17 +68,27 @@ export async function getEnvironmentStatus({ ctx, log }: GetEnvironmentStatusPar
const sysNamespaceUpToDate = await systemNamespaceUpToDate(api, log, namespace, contextForLog)

// Get system service statuses
const systemServiceStatuses = await getSystemServiceStatuses({
const systemServiceStatuses = await getSystemServiceStatus({
ctx: k8sCtx,
log,
namespace,
serviceNames: systemServiceNames,
variables: variables || {},
})

systemReady = systemTillerReady && systemServiceStatuses.ready && sysNamespaceUpToDate
systemReady = systemTillerReady
&& (systemServiceStatuses.state === "ready" || systemServiceStatuses.state === "outdated")
&& sysNamespaceUpToDate

dashboardPages = systemServiceStatuses.dashboardPages

if (systemServiceStatuses.state === "outdated") {
log.warn(
"One or more cluster-wide services are outdated or their configuration does not match your current " +
"configuration. You may want to run \`garden init\` to update them, or contact your cluster admin.",
)
}

// We always require manual init if we're installing any system services to remote clusters, to avoid conflicts
// between users or unnecessary work.
needManualInit = true
Expand Down
9 changes: 5 additions & 4 deletions garden-service/src/plugins/kubernetes/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { join } from "path"
import { every, values, find } from "lodash"
import { values, find } from "lodash"
import { V1Namespace } from "@kubernetes/client-node"
import * as semver from "semver"

Expand All @@ -23,6 +23,7 @@ import { deleteNamespaces } from "./namespace"
import { PluginError } from "../../exceptions"
import { DashboardPage } from "../../config/dashboard"
import { PrimitiveMap } from "../../config/common"
import { combineStates } from "../../types/service"

const GARDEN_VERSION = getPackageVersion()
const SYSTEM_NAMESPACE_MIN_VERSION = "0.9.0"
Expand Down Expand Up @@ -132,15 +133,15 @@ interface GetSystemServicesStatusParams {
variables: PrimitiveMap,
}

export async function getSystemServiceStatuses(
export async function getSystemServiceStatus(
{ ctx, log, namespace, serviceNames, variables }: GetSystemServicesStatusParams,
) {
let dashboardPages: DashboardPage[] = []

const sysGarden = await getSystemGarden(ctx.provider, variables)

const serviceStatuses = await sysGarden.actions.getServiceStatuses({ log, serviceNames })
const ready = every(values(serviceStatuses).map(s => s.state === "ready"))
const state = combineStates(values(serviceStatuses).map(s => s.state || "unknown"))

// Add the Kubernetes dashboard to the Garden dashboard
if (serviceNames.includes("kubernetes-dashboard")) {
Expand All @@ -167,7 +168,7 @@ export async function getSystemServiceStatuses(
}

return {
ready,
state,
dashboardPages,
}
}
Expand Down

0 comments on commit c7b0130

Please sign in to comment.