Skip to content

Commit

Permalink
fix: pr bugs (TBS)
Browse files Browse the repository at this point in the history
  • Loading branch information
edvald committed Aug 5, 2019
1 parent da326b9 commit 461e5f6
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 13 deletions.
8 changes: 8 additions & 0 deletions docs/reference/providers/kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,14 @@ The primary namespace used for resource deployments.
| -------- | -------- |
| `string` | Yes |

### `providers.<provider-name>.default-hostname`

The default hostname configured on the provider.

| Type | Required |
| -------- | -------- |
| `string` | No |

### `providers.<provider-name>.metadata-namespace`

The namespace used for Garden metadata.
Expand Down
8 changes: 8 additions & 0 deletions docs/reference/providers/local-kubernetes.md
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,14 @@ The primary namespace used for resource deployments.
| -------- | -------- |
| `string` | Yes |

### `providers.<provider-name>.default-hostname`

The default hostname configured on the provider.

| Type | Required |
| -------- | -------- |
| `string` | No |

### `providers.<provider-name>.metadata-namespace`

The namespace used for Garden metadata.
Expand Down
14 changes: 8 additions & 6 deletions garden-service/src/plugins/kubernetes/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { combineStates, ServiceStatusMap } from "../../types/service"
*/
export async function getEnvironmentStatus({ ctx, log }: GetEnvironmentStatusParams): Promise<EnvironmentStatus> {
const k8sCtx = <KubernetesPluginContext>ctx
const provider = k8sCtx.provider

let projectReady = true

Expand All @@ -61,6 +62,7 @@ export async function getEnvironmentStatus({ ctx, log }: GetEnvironmentStatusPar
dashboardPages: [],
outputs: {
...namespaces,
"default-hostname": provider.config.defaultHostname || null,
},
}

Expand All @@ -69,14 +71,14 @@ export async function getEnvironmentStatus({ ctx, log }: GetEnvironmentStatusPar
systemServiceNames.length === 0
||
// Make sure we don't recurse infinitely
k8sCtx.provider.config.namespace === systemNamespace
provider.config.namespace === systemNamespace
) {
return result
}

const variables = getKubernetesSystemVariables(k8sCtx.provider.config)
const variables = getKubernetesSystemVariables(provider.config)
const sysGarden = await getSystemGarden(k8sCtx, variables || {}, log)
const sysProvider = await sysGarden.resolveProvider(k8sCtx.provider.name)
const sysProvider = await sysGarden.resolveProvider(provider.name)
const sysCtx = <KubernetesPluginContext>await sysGarden.getPluginContext(sysProvider)

// Check Tiller status in system namespace
Expand All @@ -87,7 +89,7 @@ export async function getEnvironmentStatus({ ctx, log }: GetEnvironmentStatusPar
detail.systemTillerReady = false
}

const api = await KubeApi.factory(log, k8sCtx.provider.config.context)
const api = await KubeApi.factory(log, provider.config.context)
const contextForLog = `Checking Garden system service status for plugin "${ctx.provider.name}"`
const sysNamespaceUpToDate = await systemNamespaceUpToDate(api, log, systemNamespace, contextForLog)

Expand Down Expand Up @@ -122,7 +124,7 @@ export async function getEnvironmentStatus({ ctx, log }: GetEnvironmentStatusPar
* 3. Deploys system services (if provider has system services)
*/
export async function prepareEnvironment(params: PrepareEnvironmentParams): Promise<PrepareEnvironmentResult> {
const { ctx, log, force } = params
const { ctx, log, force, status } = params
const k8sCtx = <KubernetesPluginContext>ctx

// Install Tiller to project namespace
Expand All @@ -131,7 +133,7 @@ export async function prepareEnvironment(params: PrepareEnvironmentParams): Prom
// Prepare system services
await prepareSystem({ ...params, clusterInit: false })

return { status: { ready: true, outputs: {} } }
return { status: { ready: true, outputs: status.outputs } }
}

export async function prepareSystem(
Expand Down
2 changes: 2 additions & 0 deletions garden-service/src/plugins/kubernetes/kubernetes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ const outputsSchema = joi.object()
"app-namespace": joiIdentifier()
.required()
.description("The primary namespace used for resource deployments."),
"default-hostname": joi.string()
.description("The default hostname configured on the provider."),
"metadata-namespace": joiIdentifier()
.required()
.description("The namespace used for Garden metadata."),
Expand Down
2 changes: 2 additions & 0 deletions garden-service/src/plugins/openfaas/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { ContainerModule } from "../container/config"
import { ConfigureModuleParams, ConfigureModuleResult } from "../../types/plugin/module/configure"
import { getNamespace } from "../kubernetes/namespace"
import { LogEntry } from "../../logger/log-entry"
import { baseBuildSpecSchema } from "../../config/module"

export interface OpenFaasModuleSpec extends ExecModuleSpec {
handler: string
Expand All @@ -32,6 +33,7 @@ export interface OpenFaasModuleSpec extends ExecModuleSpec {

export const openfaasModuleSpecSchema = joi.object()
.keys({
build: baseBuildSpecSchema,
dependencies: joiArray(joi.string())
.description("The names of services/functions that this function depends on at runtime."),
env: joiEnvVars(),
Expand Down
8 changes: 3 additions & 5 deletions garden-service/src/tasks/resolve-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@ export class ResolveProviderTask extends BaseTask {
const actions = await this.garden.getActionHelper()
const ctx = this.garden.getPluginContext(tmpProvider)

const log = this.log.placeholder()

this.log.silly(`Getting status for ${pluginName}`)

const handler = await actions.getActionHandler({
Expand All @@ -147,15 +145,15 @@ export class ResolveProviderTask extends BaseTask {
defaultHandler: async () => defaultEnvironmentStatus,
})

let status = await handler({ ctx, log })
let status = await handler({ ctx, log: this.log })

this.log.silly(`${pluginName} status: ${status.ready ? "ready" : "not ready"}`)

if (this.forceInit || !status.ready) {
// Deliberately setting the text on the parent log here
this.log.setState(`Preparing environment...`)

const envLogEntry = log.info({
const envLogEntry = this.log.info({
status: "active",
section: pluginName,
msg: "Configuring...",
Expand All @@ -166,7 +164,7 @@ export class ResolveProviderTask extends BaseTask {
pluginName,
defaultHandler: async () => ({ status }),
})
const result = await prepareHandler({ ctx, log, force: this.forceInit, status })
const result = await prepareHandler({ ctx, log: this.log, force: this.forceInit, status })

status = result.status

Expand Down
5 changes: 3 additions & 2 deletions garden-service/test/e2e/garden.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,9 @@ tests:
command: [npm, run, e2e-full, --, --project=tasks, --showlog=true, --env=testing]
- name: hot-reload # Tests for hot-reload are currently being skipped
command: [npm, run, e2e-full, --, --project=hot-reload, --showlog=true, --env=testing]
- name: openfaas
command: [npm, run, e2e-full, --, --project=openfaas, --showlog=true, --env=testing]
# Disabling until https://github.com/garden-io/garden/issues/1045 is fixed
# - name: openfaas
# command: [npm, run, e2e-full, --, --project=openfaas, --showlog=true, --env=testing]
- name: project-variables
command: [npm, run, e2e-full, --, --project=project-variables, --showlog=true, --env=testing]
- name: vote-helm
Expand Down

0 comments on commit 461e5f6

Please sign in to comment.