Commit graph

191 commits

Author SHA1 Message Date
Luke Hoban 96e4b74b15
Support for stack outputs (#581)
Adds support for top-level exports in the main script of a Pulumi Program to be captured as stack-level output properties.

This create a new `pulumi:pulumi:Stack` component as the root of the resource tree in all Pulumi programs.  That resources has properties for each top-level export in the Node.js script.

Running `pulumi stack` will display the current value of these outputs.
2017-11-17 15:22:41 -08:00
joeduffy d840a86a0a Fix outdated config error message 2017-11-17 08:53:58 -08:00
Matt Ellis 46c35281ab Adopt new makefile system
See https://github.com/pulumi/home/pull/56 for more details.
2017-11-16 23:56:29 -08:00
Joe Duffy 98ef0c4bb5
Allow overriding a Pulumi.yaml's entrypoint (#582)
Because the Pulumi.yaml file demarcates the boundary used when
uploading a program to the Pulumi.com service at the moment, we
have trouble when a Pulumi program uses "up and over" references.
For instance, our customer wants to build a Dockerfile located
in some relative path, such as `../../elsewhere/`.

To support this, we will allow the Pulumi.yaml file to live
somewhere other than the main Pulumi entrypoint.  For example,
it can live at the root of the repo, while the Pulumi program
lives in, say, `infra/`:

    Pulumi.yaml:
    name: as-before
    main: infra/

This fixes pulumi/pulumi#575.  Further work can be done here to
provide even more flexibility; see pulumi/pulumi#574.
2017-11-16 07:49:07 -08:00
CyrusNajmabadi 36a692390d
Properly capture 'arguments' when creating our serialization closure. (#569)
* Simplify how we capture 'this' in our serialization logic.
* Properly capture 'arguments'

* add tests for 'arguments' capture.

* Properly serialize out 'arguments'
* Invert 'with' and function closure.
2017-11-15 11:31:17 -08:00
Joe Duffy 571d3814f8
Format logs the same way Node.js console APIs do (#561)
This change formats log messages the same way that Node.js does
in its console.log/error APIs.  This ensures, for example, that
errors have their stack printed if present, and switches over to
just printing the error directly rather than manually toStringing it.
2017-11-14 09:55:54 -08:00
Luke Hoban af5298f4aa
Initial work on tracing support (#521)
Adds OpenTracing in the Pulumi engine and plugin + langhost subprocesses.

We currently create a single root span for any `Enging.plan` operation - which is a single `preview`, `update`, `destroy`, etc.

The only sub-spans we currently create are at gRPC boundaries, both on the client and server sides and on both the langhost and provider plugin interfaces.

We could extend this to include spans for any other semantically meaningful sections of compute inside the engine, though initial examples show we get pretty good granularity of coverage by focusing on the gRPC boundaries.

In the future, this should be easily extensible to HTTP boundaries and to track other bulky I/O like datastore read/writes once we hook up to the PPC and Pulumi Cloud.

We expose a `--trace <endpoint>` option to enable tracing on the CLI, which we will aim to thread through to subprocesses.

We currently support sending tracing data to a Zipkin-compatible endpoint.  This has been validated with both Zipkin and Jaeger UIs.

We do not yet have any tracing inside the TypeScript side of the JS langhost RPC interface.  There is not yet automatic gRPC OpenTracing instrumentation (though it looks like it's in progress now) - so we would need to manually create meaningful spans on that side of the interface.
2017-11-08 17:08:51 -08:00
joeduffy 4d26cf4f2c Fix a function comment 2017-11-08 16:20:27 -08:00
CyrusNajmabadi 89b5a4be71
remove use of 'eval' in tests. (#510)
* remove use of 'eval' in tests.

* Remove another eval.

* Remove usage of eval.
2017-10-31 14:41:58 -07:00
Joe Duffy 8d916dc00c
Improve promise leak diagnostics (#508)
This change adds more context information to debuggable promises
to aid with leak detection.  This was super helpful for me just now!
2017-10-31 07:48:59 -07:00
joeduffy b3c4a52933 Add a diagnostics messages for the serialized promise chain 2017-10-31 06:52:42 -07:00
Matt Ellis 67426833a4
Merge pull request #505 from pulumi/FixWindows
Get windows integration tests working again
2017-10-31 00:19:20 -07:00
Matt Ellis 25552b8432 Remove unused import 2017-10-30 23:35:18 -07:00
Matt Ellis 3fcf5889c1 Don't change cd in Windows launch scripts
Previously, we would CD into the directory of the launch script and
invoke node.exe from there. We did this because the require statement
was a relative path and so we needed to be in the langhost directory for
things to work.

This behavior differs from how we launch things on *nix and was causing
some issues with relative paths, since the CWD would now differ between
Windows and *nix. So instead we construct a full path for our require
statements and don't cd anymore. The only tricky thing is to change path
separators from \ to / when computing the path to the root folder we
should do our require from.
2017-10-30 15:37:06 -07:00
Joe Duffy 0383c24087
Drain the message queue before exiting (#498)
This change remembers that we failed due to an uncaught exception,
and defers the process.exit(1) until we actually reach the process's
exit event.  This ensures that we drain the message queue before
exiting, which ensures that outbound messages actually reach their
destination.
2017-10-30 11:48:54 -07:00
pat@pulumi.com 8fd2d3e9e0 Fix require paths in closure serialization on Windows.
We were ending up with unescaped backslashes in require paths, which was
causing the requires to fail.
2017-10-30 08:55:18 -07:00
Joe Duffy cdb2c79e8e
Exit with an error code in the face of unhandled errors (#495)
As part of fixing the exit bug recently, we accidentally made errors
lead to zero exit codes.  As a result, the Pulumi CLI thought the
prgoram exited ordinarily, and proceeded to do its usual planning and
deployment, rather than terminating abruptly.

This is a byproduct of how Node's process.uncaughtException handler
works.  It hijacks and replaces all usual error logic, including the
process.exit part.  This change simply adds back the non-zero exit.

I also added a test (and fixed one other that began failing
afterwards), so that we can prevent regressions down the road.
2017-10-28 17:05:05 -07:00
Matthew Riley 90e53482dc
Merge pull request #485 from pulumi/remove-proccnt
Remove unused PROCCNT variable
2017-10-27 15:43:24 -07:00
Matthew Riley 418ff30725 Remove unused PROCCNT variable 2017-10-27 14:42:47 -07:00
Pat Gavlin a5358088d7
Merge pull request #484 from pulumi/Followup
Follow up to PR feedback for #475.
2017-10-27 14:18:58 -07:00
pat@pulumi.com 73baaa2867 Follow up to PR feedback for #475.
- Change a `console.log` to `log.debug`
- Null out gRPC clients after disconnecting.
2017-10-27 13:51:47 -07:00
Pat Gavlin 40c72f37d5
Merge pull request #478 from pulumi/PadProviderArgs
Pad provider arguments on Windows.
2017-10-27 13:49:54 -07:00
Chris Smith d81b00f758
Update error message to reflect current CLI format (#482) 2017-10-27 13:44:32 -07:00
pat@pulumi.com 6ef0747219 Pad provider arguments on Windows.
All of our providers expect to be invoked as `node path/to/provider
...provider_args`, but on Windows, we are invoking them as `node -e
require(path/to/provider) ...provider_args`. This throws off the
provider's argument processing and causes connections to the resource
monitor to fail.

Fixes #477, though I think that there is going to be another issue with
dynamic resources.
2017-10-26 18:44:29 -07:00
pat@pulumi.com 73f2670b98 Add a Windows version of the dynamic provider. 2017-10-26 15:01:16 -07:00
pat@pulumi.com 97f99d7fa1 Do not disconnect from the engine prematurely.
The `nodejs` language support is implemented as two programs: one that
manages the initial connection to the engine and provides the language
serivce itself, and another that the language service invokes in order
to run a `nodejs` Pulumi program. The latter is responsible for running
the user's program and communicating its resource requests to the
engine. Currently, `run` effectively assumes that the user's program
will run synchronously from start to finish, and will disconnect from
the engine once the user's program has completed. This assumption breaks
if the user's program requires multiple turns of the event loop to
finish its root resource requests. For example, the following program
would fail to create its second resource because the engine will be
disconnected once it reaches its `await`:

```
(async () => {
    let a = new Resource();
    await somePromise();
    let = new Resource();
})();
```

These changes fix this issue by disconnecting from the engine during
process shutdown rather than after the user's program has finished its
first turn through the event loop.
2017-10-26 12:16:32 -07:00
CyrusNajmabadi 3bbe21db25 Simplify the type system around 'computed' a little. (#469) 2017-10-25 12:52:49 -07:00
joeduffy c61bce3e41 Permit undefined in more places
The prior code was a little too aggressive in rejected undefined
properties, because it assumed any occurrence indicated a resource
that was unavailable due to planning.  This is a by-produt of our
relatively recent decision to flow undefineds freely during planning.

The problem is, it's entirely legitimate to have undefined values
deep down in JavaScript structures, entirely unrelated to resources
whose property values are unknown due to planning.

This change flows undefined more freely.  There really are no
negative consequences of doing so, and avoids hitting some overly
aggressive assertion failures in some important scenarios.  Ideally
we would have a way to know statically whether something is a resource
property, and tighten up the assertions just to catch possible bugs
in the system, but because this is JavaScript, and all the assertions
are happening at runtime, we simply lack the necessary metadata to do so.
2017-10-23 16:02:28 -07:00
joeduffy 680e73bb97 Add context to "unexpected unknown property" error log 2017-10-23 15:31:45 -07:00
Joe Duffy 69f7f51375 Many asset improvements
This improves a few things about assets:

* Compute and store hashes as input properties, so that changes on
  disk are recognized and trigger updates (pulumi/pulumi#153).

* Issue explicit and prompt diagnostics when an asset is missing or
  of an unexpected kind, rather than failing late (pulumi/pulumi#156).

* Permit raw directories to be passed as archives, in addition to
  archive formats like tar, zip, etc. (pulumi/pulumi#240).

* Permit not only assets as elements of an archive's member list, but
  also other archives themselves (pulumi/pulumi#280).
2017-10-22 13:39:21 -07:00
Luke Hoban ba98f5e837 Fix bugs in free variable analysis (#444)
Properties and methods were not being traversed correctly.

Fixes #442.
2017-10-19 23:20:57 -07:00
joeduffy 599ca8ea43 Add accessors to fetch the Pulumi project and stack names
This change adds functions, `pulumi.getProject()` and `pulumi.getStack()`,
to fetch the names of the project and stack, respectively.  These can be
handy in generating names, specializing areas of the code, etc.

This fixes pulumi/pulumi#429.
2017-10-19 08:26:57 -07:00
CyrusNajmabadi d929c169de Enable tslinting of the nodejs sdk. (#433) 2017-10-18 15:03:56 -07:00
CyrusNajmabadi d007f040b9 Move from acorn to TypeScript as the parser we use when computing free variables. (#431) 2017-10-18 13:29:53 -07:00
joeduffy d2b5ce9252 Add a Resource.runInParentlessScope function
As part of adding components, we sometimes want to allocate things
that are guaranteed not to get attributed to the calling component's
initialization code.  This includes lazily allocated pooled resources.
In those cases, we can invoke Resource.runInParentlessScope to
temporarily squelch the parent.  Also renames withParent to
runInParentScope to be more symmetric and explicit about what it does.
2017-10-18 07:39:03 -07:00
Pat Gavlin 2543966110 Shorten lines. 2017-10-16 23:06:53 -07:00
Pat Gavlin e4ae5bcd03 Update error reporting and add a couple comments. 2017-10-16 23:06:53 -07:00
pat@pulumi.com e66d45ed30 Add a newline. 2017-10-16 23:06:53 -07:00
Pat Gavlin 308045b274 Move serializeProvider out of dynamic.Resource. 2017-10-16 23:06:53 -07:00
Pat Gavlin 1b4ed6cce3 PR feedback 2017-10-16 23:06:53 -07:00
Pat Gavlin afd7c400ad Remove the testing provider.
This provider has been obviated by dynamic resources.
2017-10-16 23:06:53 -07:00
pat@pulumi.com 9453f86c2e Implement dynamic resources.
A dynamic resource is a resource whose provider is implemented alongside
the resource itself. This provider may close over and use orther
resources in the implementation of its CRUD operations. The provider
itself must be stateless, as each CRUD operation for a particular
dynamic resource type may use an independent instance of the provider.
Changes to the definition of a resource's provider result in replacement
of the resource itself (rather than a simple update), as this allows the
old provider definition to delete the old resource and the new provider
definition to create an appropriate replacement.
2017-10-16 23:06:53 -07:00
Matt Ellis 6fc250447d Merge pull request #411 from pulumi/move-build-into-make
Restore TESTPARALLELISM to 10
2017-10-16 11:56:47 -07:00
Matt Ellis fc14329cfc Stop using yarn scripts for building
We have Makefiles, so we might as well use them, instead of spliting
build logic across two systems.
2017-10-16 10:47:37 -07:00
joeduffy 301739c6b5 Add auto-parenting
This changes a few things about "components":

* Rename what was previously ExternalResource to CustomResource,
  and all of the related fields and parameters that this implies.
  This just seems like a much nicer and expected name for what
  these represent.  I realize I am stealing a name we had thought
  about using elsewhere, but this seems like an appropriate use.

* Introduce ComponentResource, to make initializing resources
  that merely aggregate other resources easier to do correctly.

* Add a withParent and parentScope concept to Resource, to make
  allocating children less error-prone.  Now there's no need to
  explicitly adopt children as they are allocated; instead, any
  children allocated as part of the withParent callback will
  auto-parent to the resource provided.  This is used by
  ComponentResource's initialization function to make initialization
  easier, including the distinction between inputs and outputs.
2017-10-15 04:38:26 -07:00
joeduffy fbfca58a3f Implement components
This change implements core support for "components" in the Pulumi
Fabric.  This work is described further in pulumi/pulumi#340, where
we are still discussing some of the finer points.

In a nutshell, resources no longer imply external providers.  It's
entirely possible to have a resource that logically represents
something but without having a physical manifestation that needs to
be tracked and managed by our typical CRUD operations.

For example, the aws/serverless/Function helper is one such type.
It aggregates Lambda-related resources and exposes a nice interface.
All of the Pulumi Cloud Framework resources are also examples.

To indicate that a resource does participate in the usual CRUD resource
provider, it simply derives from ExternalResource instead of Resource.

All resources now have the ability to adopt children.  This is purely
a metadata/tagging thing, and will help us roll up displays, provide
attribution to the developer, and even hide aspects of the resource
graph as appropriate (e.g., when they are implementation details).

Our use of this capability is ultra limited right now; in fact, the
only place we display children is in the CLI output.  For instance:

    + aws:serverless:Function: (create)
      [urn=urn:pulumi:demo::serverless::aws:serverless:Function::mylambda]
      => urn:pulumi:demo::serverless::aws:iam/role:Role::mylambda-iamrole
      => urn:pulumi:demo::serverless::aws:iam/rolePolicyAttachment:RolePolicyAttachment::mylambda-iampolicy-0
      => urn:pulumi:demo::serverless::aws:lambda/function:Function::mylambda

The bit indicating whether a resource is external or not is tracked
in the resulting checkpoint file, along with any of its children.
2017-10-14 18:30:59 -07:00
joeduffy 65184ec6bd Enable PULUMI_CONFIG envvars, use them
This change adds environment variable fallbacks for configuration
variables, such that you can either set them explicitly, as a specific
variable PULUMI_CONFIG_<K>, or an entire JSON serialized bag via
PULUMI_CONFIG.

This is convenient when simply invoking programs at the command line,
via node, e.g.

    PULUMI_CONFIG_AWS_CONFIG_REGION=us-west-2 node bin/index.js

Our language host also now uses this to communicate config when invoking
a Run RPC, rather than at the command line.  This fixes pulumi/pulumi#336.
2017-10-11 18:41:52 -07:00
joeduffy ce87899792 Add Maybe<T> as a shortcut for T | undefined
This arose during a conversation with @CyrusNajmabadi, where he
suggested it would be useful in user code to have a "name" for these,
since they show up so frequently during resource property consumption.
2017-10-11 17:35:44 -07:00
Pat Gavlin ee410bfe1e Add a mock resource provider for testing purposes. (#401)
This resource provider accepts a single configuration parameter, `testing:provider:module`, that is the path to a Javascript module that implements CRUD operations for a set of resource types. This allows e.g. a test case to provide its own implementation of these operations that may succeed or fail in interesting ways.

Fixes #338.
2017-10-11 15:27:34 -07:00
Matt Ellis e7c3aaba69 Merge pull request #395 from pulumi/pulumi-service-interface
More engine refactoring
2017-10-11 13:44:36 -07:00