Commit graph

2883 commits

Author SHA1 Message Date
Matt Ellis 271f7a6d25 Adopt Contributor Covenant code of conduct
This change adopts the Contributor Covenant code of conduct, an
existing code of conduct use by many projects.
2018-05-30 11:01:52 -07:00
Chris Smith 485bb35180
Relax stack name requirements (#1381)
* Relax stack name requirements

* Add error if stack name too long

* Max tag length is 256 chars
2018-05-29 13:52:11 -07:00
Sean Gillespie 46f83f0795
Provide copy-pasteable output on CLI panics (#1431) 2018-05-29 10:58:24 -07:00
Pat Gavlin da9bd9dbff
Merge pull request #1430 from pulumi/AlwaysPrompt
Always prompt for confirmation after a preview.
2018-05-29 09:47:00 -07:00
Sean Gillespie 924c49d7e0
Fail fast when attempting to load a too-new or too-old deployment (#1382)
* Error when loading a deployment that is not a version that the CLI understands

* Add a test for 'pulumi stack import' on a badly-versioned deployment

* Move current deployment version to 'apitype'

* Rebase against master

* CR: emit CLI-friendly error message at the two points outside of the engine calling 'DeserializeDeployment'
2018-05-25 13:29:59 -07:00
Sean Gillespie fe22ade275
Differentiate between warnings and errors when sending an event (#1424)
* Differentiate between warnings and errors when sending an event

* CR: always write severity field if the event is a diagnostic
2018-05-25 13:29:33 -07:00
Sean Gillespie 58ca6f5f19
Fix a confusing error message arising from multiple API calls failing in the same way (#1432) 2018-05-24 15:36:35 -07:00
Pat Gavlin 31739c8840 Always prompt for confirmation after a preview.
An empty preview is not a guarantee that a subsequent update will cause
no changes. As such, we should always offer the user the option to
perform an update even if the preview proposes no changes.

Note that this indirectly fixes #1410 by masking the effects of #1429.
2018-05-24 12:22:20 -07:00
Sean Gillespie 38cf2de39e
Issue a better error message if you capture a V8 intrinsic (#1423) 2018-05-24 11:54:31 -07:00
Pat Gavlin a2c30f75ed
Resolve missing outputs as undefined. (#1427)
Before the changes in #1414, all output properties were guaranteed to
have values after deserialization. After #1414, any properties with no
value were no longer resolved, which was treated as an error. These
changes resolve all missing proprties to `undefined`. If a property is
missing during an update, its `undefined` value is marked as known.
2018-05-24 11:22:08 -07:00
Matt Ellis 9a8f8881c0 Show manifest information for stacks
This change supports displaying manifest information for a stack and
changes the way we handle Snapshots in our backend.

Previously, every call to GetStack would synthesize a Snapshot by
taking the set of resources returned from the
`/api/stacks/<owner>/<name>` endpoint, combined with an empty
manfiest (since the service was not returning the manifest).

This wasn't great for two reasons:

1. We didn't have manifest information, so we couldn't display any of
   its information (most important the last updated time).

2. This strategy required that the service return all the resources
   for a stack anytime GetStack was called. While the CLI did not
   often need this detailed information the fact that we forced the
   Service to produce it (which in the case of stack managed PPC would
   require the service to talk to yet another service) creates a bunch
   of work that we end up ignoring.

I've refactored the code such that `backend.Stack`'s `Snapshot()` method
now lazily requests the information from the service such that we can
construct a `Snapshot()` on demand and only pay the cost when we
actually need it.

I think making more of this stuff lazy is the long term direction we
want to follow.

Unfortunately, right now, it means in cases where we do need this data
we end up fetching it twice. The service does it once when we call
GetStack and then we do it again when we actually need to get at the
Snapshot.  However, once we land this change, we can update the
service to no longer return resources on the apistack.Stack type. The
CLI no longer needs this property.  We'll likely want to continue in a
direction where `apistack.Stack` can be created quickly by the
service (without expensive database queries or fetching remote
resources) and just add additional endpoints that let us get at the
specific information we want in the specific cases when we want it
instead of forcing us to return a bunch of data that we often ignore.

Fixes pulumi/pulumi-service#371
2018-05-23 16:43:34 -07:00
Pat Gavlin a16a880518
Discriminate unknown values in the JS runtime. (#1414)
These changes add support for distinguishing an output property with
an unknown value from an output property with a known value that is
undefined.

In a broad sense, the Pulumi property type system is just JSON with the
addition of unknown values. Notably absent, however, are undefined
values. As it stands, our marshalers between JavaScript and Pulumi
property values treat all undefined JavaScript values as unknown Pulumi
values. Unfortunately, this conflates two very different concepts:
unknown Pulumi values are intended to represent values of output
properties that are unknown at time of preview, _not_ values that are
known but undefined. This results in difficulty reasoning about when
transforms are run on output properties as well as confusing output in
the `diff` view of Pulumi preview (user-specifed undefined values are
rendered as unknown values).

As it turns out, we already have a way to decide whether or not an
Output value is known or not: Output.performApply. These changes rename
this property to `isKnown`, clarify its meaning, and take advantage of
the result to decide whether or not an Output value should marshal as
an unknown Pulumi value.

This also allowed these changes to improve the serialization of
undefined object keys and array elements s.t. we better match JavaScript
to JSON serialization behavior (undefined object keys are omitted;
undefined array elements are marshaled as `null`).

Fixes https://github.com/pulumi/pulumi-cloud/issues/483.
2018-05-23 14:47:40 -07:00
Sean Gillespie 1a51507206
Delete Before Create (#1365)
* Delete Before Create

This commit implements the full semantics of delete before create. If a
resource is replaced and requires deletion before creation, the engine
will use the dependency graph saved in the snapshot to delete all
resources that depend on the resource being replaced prior to the
deletion of the resource to be replaced.

* Rebase against master

* CR: Simplify the control flow in makeRegisterResourceSteps

* Run Check on new inputs when re-creating a resource

* Fix an issue where the planner emitted benign but incorrect deletes of DBR-deleted resources

* CR: produce the list of dependent resources in dependency order and iterate over the list in reverse

* CR: deps->dependents, fix an issue with DependingOn where duplicate nodes could be added to the dependent set

* CR: Fix an issue where we were considering old defaults and new inputs
inappropriately when re-creating a deleted resource

* CR: save 'iter.deletes[urn]' as a local, iterate starting at cursorIndex + 1 for dependency graph
2018-05-23 14:43:17 -07:00
Pat Gavlin 38d3b83494
Allow tests to perform changes in empty updates. (#1411)
This may be a useful knob to have.
2018-05-23 09:17:10 -07:00
Pat Gavlin f3201baeb5
Fix {computed,output}<> display in preview. (#1409)
At some point the summary and preview parameters to
`engine.GetResourcePropertiesDetails` were flipped s.t. we stopped
rendering computed<> and output<> values properly during previews.
2018-05-22 17:20:03 -07:00
Pat Gavlin 37a3317623
Put local backend support under PULUMI_DEBUG_COMMANDS. (#1408)
Just what it says on the tin.

Fixes #1398.
2018-05-22 17:02:45 -07:00
Joe Duffy 97e01bb4be
Merge pull request #1402 from pulumi/relicense
Relicense under Apache 2.0
2018-05-22 15:37:54 -07:00
joeduffy 5967259795 Add license headers 2018-05-22 15:02:47 -07:00
joeduffy dcef859872 Relicense under Apache 2.0 2018-05-22 13:52:41 -07:00
Matt Ellis 0732b05c5d Remove pulumi init
`pulumi init` was part of our old identity model with the service and
is no longer used. We can now delete this code.

Fixes #1241
2018-05-22 13:37:08 -07:00
Pat Gavlin b5efe40f04
Fold "global" messages under the stack resource. (#1406)
We currently display at most two rows for messages that are not
associated with a URN: one for those that arrive before the stack
resource is first observed and one for those that arrive after the stack
resource is first observed. The former is labeled "global"; the latter
is the row associated with the stack resource. These changes remove the
duplication by reassociating the row used for events with no URN that
arrive before the stack resource with the stack resource once it has
been observed.

Fixes #1385.
2018-05-22 13:30:52 -07:00
Pat Gavlin fe12800fb2
Merge pull request #1405 from pulumi/SupressMeaninglessRows
Only display preview/no-op resource rows once on non-TTYs.
2018-05-22 13:08:41 -07:00
Pat Gavlin c08ede339f Only display preview/no-op resource rows once on non-TTYs.
Our current strategy for the progress display on non-TTYs causes us to
display multiple identical rows for each resource when the row is a
preview or a no-op. This behavior is not particularly useful, and
generally just makes the display noisier than it needs to be.

These changes avoid displaying resource rows without meaningful output
by supressing the display of resource output events that are delivered
during a preview or that correspond to a no-op update.

Fixes #1384.
2018-05-22 11:35:07 -07:00
Joe Duffy 3c0376bb8e
Fix refresh on dynamic providers (#1393)
This changes two primary things about dynamic providers:

1) Always echo back the __provider upon read, even if there is a
   missing read function on the dynamic provider.  In fact, return
   the full input state in that case.

2) Store the __provider in the output state of the dynamic resource,
   in addition to the input state.  My recollection of the "model"
   discussion we had weeks ago was that the output properties are
   mean to capture the state of a resource in its entirety; not having
   this meant that refresh would marshal the outputs only, and find
   on the other side of the RPC boundary that __provider was missing.

Note that an alternative to the latter fix would be to use some hybrid
of input and output state, as we used to do, by merging property maps.
2018-05-20 07:42:24 -07:00
Joe Duffy df7a4ff827
Merge pull request #1387 from pulumi/nm_refresh_plugin_ctx
Don't pass PluginEvents for refresh
2018-05-18 16:50:15 -07:00
Matt Ellis d11acf5208 Pass --no-audit to npm install during pulumi new
While we wait for upstream to fix the security issue, we'll just pass
`--no-audit` to `npm install` when creating a new project. Since the
warning is against an indirect dependency of @pulumi/pulumi, we can't
actually address the issue ourselves.

Mitigates #1350
2018-05-18 15:14:10 -07:00
joeduffy 614a2cdeb3 Simplify previews, initialize plugin events
This changes two things:

1) Eliminates the fact that we had two kinds of previews in our engine.

2) Always initialize the plugin.Events, to ensure that all plugin loads
   are persisted no matter the update type (update, refresh, destroy),
   and skip initializing it when dryRun == true, since we won't save them.
2018-05-18 14:58:06 -07:00
joeduffy 4e9b228089 Don't pass PluginEvents for refresh
The PluginEvents will now try to register loaded plugins which,
during a refresh preview, will result in attempting to save mutations
when a token is missing.  This change mirrors the changes made to
destroy which avoid it panicing similarly, by simply leaving
PluginEvents unset.  Also adds a bit of tracing that was helpful to
me as I debugged through the underlying issues.

Fixes #1377.
2018-05-18 13:54:23 -07:00
joeduffy 8aca7ab11e Fix pulumi.com hyperlink in README 2018-05-18 11:22:42 -07:00
joeduffy 12a2626c59 Prepare package for public publishing
This adds a warning to the top of the README.md and adds a license
to the package.json (to eliminate the associated warning).
2018-05-18 11:21:32 -07:00
Sean Gillespie 7b7870cdaa
Remove unused stack name from deploy.Snapshot (#1386) 2018-05-18 11:15:35 -07:00
joeduffy 6470adad2a Update the README 2018-05-18 07:41:28 -07:00
Sean Gillespie 82ac202139
Improve the promise leak experience (#1374)
* Fix a bug in promise leak detection that leaked promises when errors occur

* Add an opt-in to the super-verbose debug error message on promise leaks

* Fix a bad merge

* was/were grammar improvement in error message

* Fail the deployment if a debuggable promise leaks
2018-05-17 15:32:39 -07:00
Matthew Riley 4398295954 Use select to notice timeouts
Before we were reading a boolean variable that was set by another goroutine.
Without any sync primitives, I think Go is within its rights to optimize
that away.

We now require that `ctx` is non-`nil`. This was already true for all callers
and consistent with other Go functions that take contexts.
2018-05-17 13:51:00 -07:00
Matthew Riley 77d9cd809a Avoid leaking connections when retry fails 2018-05-17 13:51:00 -07:00
Joe Duffy a1d806321e
Enable refresh for managed stacks (#1380) 2018-05-17 11:44:39 -07:00
Sean Gillespie 68911900fd
Graceful shutdown (#1320)
* Graceful RPC shutdown: CLI side

* Handle unavailable resource monitor in language hosts

* Fix a comment

* Don't commit package-lock.json

* fix mangled pylint pragma

* Rebase against master and fix Gopkg.lock

* Code review feedback

* Fix a race between closing the callerEventsOpt channel and terminating a goroutine that writes to it

* glog -> logging
2018-05-16 15:37:34 -07:00
Pat Gavlin 009096239c
Merge pull request #1378 from pulumi/SortPropertyKeys
Sort property keys in the progress display.
2018-05-16 11:28:11 -07:00
Pat Gavlin 3cc8758b85 Sort property keys in the progress display.
This prevents the "updated keys" list from being arbitrarily reordered
upon refresh.
2018-05-16 11:10:52 -07:00
Pat Gavlin 64d90b263d
Merge pull request #1375 from pulumi/ResourceChangesFromBackend
Validate empty previews and updates in tests.
2018-05-16 10:44:48 -07:00
Pat Gavlin 52424f5d42 PR feedback. 2018-05-16 10:22:09 -07:00
Pat Gavlin 05ef4fecb9 Validate empty previews and updates in tests.
Fixes #1154.
2018-05-15 18:03:30 -07:00
Pat Gavlin 79ec574660 Add an --expect-no-changes flag to {preview, update}.
When this flag is specified, the CLI will return an error if `preview`
proposes changes or `update` performs changes.
2018-05-15 17:44:35 -07:00
Pat Gavlin e3020e820b Expose change summaries from the backend.
This is a smallish refactoring that exposes the resource change
summaries reported by the engine from the relevant backend methods.
2018-05-15 17:44:35 -07:00
CyrusNajmabadi ad086a0dbd
Add test for filters. Also, filter anything that goes through our sinks. (#1373) 2018-05-15 16:09:16 -07:00
CyrusNajmabadi 72e00810c4
Filter the logs we emit to glog so that we don't leak out secrets. (#1371) 2018-05-15 15:28:00 -07:00
Matt Ellis 387fffd740 Allow retry of REST calls during a deployment
During a deployment, we end up making a bunch of PATCH/PUT/POST style
REST requests. For these calls, it should be safe to retry the
operation if there was a hickup during our REST call, so mark them as
retryable.
2018-05-15 13:08:03 -07:00
Pat Gavlin 016ae4acba
Add pre/post-update hooks to the test framework. (#1369)
These changes add support for pre- and post-`pulumi` callbacks to the
integration test framework. These callbacks will be invoked immediately
before and after (respectively) running a `pulumi` command.
2018-05-15 09:48:56 -07:00
Joe Duffy 369c619ab9
Skip loading language plugins when not needed (#1367)
In pulumi/pulumi#1356, we observed that we can fail during a destroy
because we attempt to load the language plugin, which now eagerly looks
for the @pulumi/pulumi package.

This is also blocking ingestion of the latest engine bits into the PPC.

It turns out that for destroy (and refresh), we have no need for the
language plugin.  So, let's skip loading it when appropriate.
2018-05-14 20:32:53 -07:00
Pat Gavlin 782a869765
Add support for passing tracing headers. (#1360)
These changes add support for adding a tracing header to API requests
made to the Pulumi service. Setting the `PULUMI_TRACING_HEADER`
environment variable or enabling debug commands and passing the
`--tracing-header` will change the value sent in this header. Setting
this value to `1` will request that the service enable distributed
tracing for all requests made by a particular CLI invocation.
2018-05-14 13:44:44 -07:00