Commit graph

1905 commits

Author SHA1 Message Date
Pat Gavlin d18b59e9c6
Fix a dependency graph bug during DBR. (#3329)
The dependency graph used to determine the set of resources that
depend on a resource being DBR'd is constructured from the list of
resource states present in the old snapshot. However, the dependencies
of resources that are present in both the old snapshot and the current
plan can be different, which in turn can cause the engine to make
incorrect decisions during DBR with respect to which resources need to
be replaced. For example, consider the following program:

```
var resA = new Resource("a", {dbr: "foo"});
var resB = new Resource("b", {dbr: resA.prop});
```

If this program is then changed to:
```
var resB = new Resource("b", {dbr: "<literal value of resA.prop>"});
var resA = new Resource("a", {dbr: "bar"});
```

The engine will first decide to make no changes to "b", as its input
property values have not changed. "b" has changed, however, such that it
no longer has a dependency on "a".

The engine will then decide to DBR "a". In the process, it will
determine that it first needs to delete "b", because the state for "b"
that is used when calculating "a"'s dependents does not reflect the
changes made during the plan.

To fix this issue, we rely on the observation that dependents can only
have been _removed_ from the base dependency graph: for a dependent to
have been added, it would have had to have been registered prior to the
root--a resource it depends on--which is not a valid operation. This
means that any resources that depend on the root must not yet have
been registered, which in turn implies that resources that have already
been registered must not depend on the root. Thus, we ignore these
resources if they are encountered while walking the old dependency graph
to determine the set of dependents.
2019-10-12 17:22:13 -07:00
Pat Gavlin 2c67288189
Stop using loreley. (#3331)
Loreley's approach to colorization via Go templates has significant
overhead when colorization is used extensively.

Also, stop parsing colorized text with regexes and use the actual
parser.
2019-10-12 13:53:57 -07:00
Pat Gavlin 834e583c95
Revert "Propagate inputs to outputs during preview. (#3245)" (#3324)
This reverts commit 80504bf0bc.
2019-10-10 10:33:05 -07:00
Alex Clemmer 5e1c4d31c6 Use PulumiPolicy.yaml instead of Pulumi.yaml for PolicyPacks 2019-10-10 10:15:51 -07:00
Chris Smith bec608d0d3
Improve error message when using PAC on out-of-date SDK (#3307)
* Fix lint warnings

* Improve error message when using PAC on old SDK

* Update pkg/resource/plugin/analyzer_plugin.go

Co-Authored-By: Justin Van Patten <jvp@justinvp.com>
2019-10-09 13:51:10 -07:00
Chris Smith 0e52e965db
Add local policy packs to summary event (#3308) 2019-10-09 13:50:28 -07:00
Mikhail Shilkov 69743fe2bf Make the path to .pulumi folder configurable with an ENV variable (#3300)
Introduces `PULUMI_HOME` environment variable which points to a path to the path to `.pulumi` folder. Defaults to `<user's home dir> + ".pulumi"` if not specified.

Fixes #2966. In addition to plugins, it "moves" the credentials file, templates, workspaces.

`bin` folder is intact: to move it, we need to adjust all installation scripts to respect `PULUMI_HOME` and put executables in the proper `bin` folder.
2019-10-08 15:01:46 -07:00
Mikhail Shilkov 90e111ba73 Override all options in ProgramTest.With (#3264) 2019-10-07 14:11:36 +03:00
Chris Smith 97d769000d
Support renaming stack projects (#3292)
* Support renaming stack projects

* Update CHANGELOG.md

* Address PR feedback
2019-10-03 09:13:13 -07:00
Pat Gavlin 5ad307d457
Close test language runtime connections. (#3289)
This should help address the issues we've begun seeing with too many
open files when running tests on OS X.
2019-10-01 12:12:06 -07:00
CyrusNajmabadi 52884096e9
Add support for updating a subset of resources in the stack (i.e. --target) (#3251) 2019-09-30 23:41:56 -07:00
Alex Clemmer 429bde332b Print PolicyPacks run as part of update summary
Fixes pulumi/pulumi-policy#69.
2019-09-30 14:49:21 -07:00
Pat Gavlin 80504bf0bc
Propagate inputs to outputs during preview. (#3245)
These changes restore a more-correct version of the behavior that was
disabled with #3014. The original implementation of this behavior was
done in the SDKs, which do not have access to the complete inputs for a
resource (in particular, default values filled in by the provider during
`Check` are not exposed to the SDK). This lack of information meant that
the resolved output values could disagree with the typings present in
a provider SDK. Exacerbating this problem was the fact that unknown
values were dropped entirely, causing `undefined` values to appear in
unexpected places.

By doing this in the engine and allowing unknown values to be
represented in a first-class manner in the SDK, we can attack both of
these issues.

Although this behavior is not _strictly_ consistent with respect to the
resource model--in an update, a resource's output properties will come
from its provider and may differ from its input properties--this
behavior was present in the product for a fairly long time without
significant issues. In the future, we may be able to improve the
accuracy of resource outputs during a preview by allowing the provider
to dry-run CRUD operations and return partially-known values where
possible.

These changes also introduce new APIs in the Node and Python SDKs
that work with unknown values in a first-class fashion:
- A new parameter to the `apply` function that indicates that the
  callback should be run even if the result of the apply contains
  unknown values
- `containsUnknowns` and `isUnknown`, which return true if a value
  either contains nested unknown values or is exactly an unknown value
- The `Unknown` type, which represents unknown values

The primary use case for these APIs is to allow nested, properties with
known values to be accessed via the lifted property accessor even when
the containing property is not fully know. A common example of this
pattern is the `metadata.name` property of a Kubernetes `Namespace`
object: while other properties of the `metadata` bag may be unknown,
`name` is often known. These APIs allow `ns.metadata.name` to return a
known value in this case.

In order to avoid exposing downlevel SDKs to unknown values--a change
which could break user code by exposing it to unexpected values--a
language SDK must indicate whether or not it supports first-class
unknown values as part of each `RegisterResourceRequest`.

These changes also allow us to avoid breaking user code with the new
behavior introduced by the prior commit.

Fixes #3190.
2019-09-30 11:03:58 -07:00
Chris Smith 7254b3db4d
Remove vestigial field from apitype (#3284) 2019-09-30 08:33:47 -07:00
Luke Hoban 9374c374c3
Transformations (#3174)
Adds the ability to provide `transformations` to modify the properties and resource options that will be used for any child resource of a component or stack.

This offers an "escape hatch" to modify the behaviour of a component by peeking behind it's abstraction.  For example, it can be used to add a resource option (`additionalSecretOutputs`, `aliases`, `protect`, etc.) to a specific known child of a component, or to modify some input property to a child resource if the component does not (yet) expose the ability to control that input directly.  It could also be used for more interesting scenarios - such as:
1. Automatically applying tags to all resources that support them in a stack (or component)
2. Injecting real dependencies between stringly-referenced  resources in a Helm Chart 
3. Injecting explicit names using a preferred naming convention across all resources in a stack
4. Injecting `import` onto all resources by doing a lookup into a name=>id mapping

Because this feature makes it possible to peek behind a component abstraction, it must be used with care in cases where the component is versioned independently of the use of transformations.  Also, this can result in "spooky action at a distance", so should be used judiciously.  That said - this can be used as an escape hatch to unblock a wide variety of common use cases without waiting on changes to be made in a component implementation.  

Each transformation is passed the `resource`, `name`, `type`, `props` and `opts` that are passed into the `Resource` constructor for any resource descended from the resource that has the transformation applied.  The transformation callback can optionally return alternate versions of the `props` and `opts` to be used in place of the original values provided to the resource constructor.

Fixes #2068.
2019-09-29 11:27:37 -07:00
Alex Clemmer ec85408eee Don't throw away secrets in calls to Analyze 2019-09-27 15:26:13 -07:00
Chris Smith 2801bfe0c2
Update apitype.StackRenameRequest // Support project renames (#3273)
* Update apitype.StackRenameRequest

* Add support for renaming projects in Snapshots

* Address PR feedback
2019-09-26 15:23:09 -07:00
Chris Smith fbb28eacc9
Fix problem with divergent project names (#3269)
* Prevent stack/workspace project name mismatch

* Account for Pulumi.yaml missing entirely
2019-09-26 12:27:37 -07:00
Praneet Loke 4404dfb470
Add codefresh CI detection. Thanks to @fernandocarletti. (#3270)
* Add codefresh CI detection. Thanks to @fernandocarletti.
2019-09-25 14:41:13 -07:00
Chris Smith a128b613ac
Remve use of GENERIC_CI_SYSTEM (#3259) 2019-09-25 14:03:00 -07:00
CyrusNajmabadi 0ea50f458e
Print destroyed outputs when a stack is destroyed. (#3261) 2019-09-24 17:15:46 -07:00
CyrusNajmabadi ef7b7d0bd1
Share target checking code. (#3252) 2019-09-20 17:50:44 -07:00
CyrusNajmabadi c1ff9c37f8
Delete specific target (#3244) 2019-09-19 19:28:14 -07:00
Pat Gavlin 40b0f8cbab
Cache ciphertext for secret properties. (#3183)
This caching is enabled by wrapping the `secrets.Manager` returned by
`DefaultSecretsProvider.OfType` in an outer `secrets.Manager` that
cooperates with `stack.{Serialize,Deserialize}PropertyValue`. Ciphertext
is cached on a per-secret-instance basis (i.e. not a per-plaintext-value
basis). Cached ciphertext is only reused if the plaintext for the secret
value has not changed. Entries are inserted into the cache upon both
encryption and decryption so that values that originated from ciphertext
and that have not changed can aoid re-encryption.

Contributes to #3178.
2019-09-18 15:52:31 -07:00
CyrusNajmabadi c53c0b6c15
Produce appropriate diagnostic when asked to refresh a resource that we cannot find. (#3246) 2019-09-18 14:28:42 -07:00
Erin Krengel cde4ecd84a
Add Applied to GetPolicyPackResponse (#3241) 2019-09-18 14:27:08 -07:00
CyrusNajmabadi 1387afec8f
Color 'reads' as cyan so they don't look like 'creates'. (#3236) 2019-09-18 09:49:13 -07:00
CyrusNajmabadi f788eb8fc1
Add support for refreshing specific targets. (#3225) 2019-09-17 18:14:10 -07:00
Erin Krengel 938c2e8bd8
Fix parsing of Gitlab urls w subgroups (#3239) 2019-09-16 20:35:23 -07:00
Pat Gavlin 82204230e1
Improve tracing support. (#3238)
* Fix some tracing issues.

- Add endpoints for `startUpdate` and `postEngineEventsBatch` so that
  spans for these invocations have proper names
- Inject a tracing span when walking a plan so that resource operations
  are properly parented
- When handling gRPC calls, inject a tracing span into the call's
  metadata if no span is already present so that resource monitor and
  engine spans are properly parented
- Do not trace client gRPC invocations of the empty method so that these
  calls (which are used to determine server availability) do not muddy
  the trace. Note that I tried parenting these spans appropriately, but
  doing so broke the trace entirely.

With these changes, the only unparented span in a typical Pulumi
invocation is a single call to `getUser`. This span is unparented
because that call does not have a context available. Plumbing a context
into that particular call is surprisingly tricky, as it is often called
by other context-less functions.

* Make tracing support more flexible.

- Add support for writing trace data to a local file using Appdash
- Add support for viewing Appdash traces via the CLI
2019-09-16 14:16:43 -07:00
Erin Krengel 48a00b507d
bump api version number to indicate PaC support (#3237) 2019-09-16 13:04:29 -07:00
Mikhail Shilkov 6c9556fe78 Add a link to docs for the 409 Conflict error message (#3207)
* Add a link to docs for the 409 Conflict error message

* Formatting
2019-09-10 13:25:08 -07:00
Mikhail Shilkov bf96123d14 Stop ignoring HTTP errors at token validation (#3208) 2019-09-10 13:24:30 -07:00
Harrison Heck a6c6ab0c9c fix: node_modules typo (#3175) 2019-09-09 23:11:35 +03:00
Paul Stack 8d1b725840
GH-2319: Increase the grpc.MaxCallRecvMsgSize (#3201)
Fixes: #2319

In #2319, a user is hitting the gRPC limit on the message size the
server can receive when uploading ec2 user-data

This commit doubles the limit that can be sent from `1024*1024*4` to
`1024*1024*8`
2019-09-09 21:31:54 +03:00
Pat Gavlin 38876d64f0
Ignore reads in HasChanges. (#3197)
This matches the behavior of the display logic, which does not consider
reads to be changes. This also matches the expectation of tests that
pass `--expect-no-changes` (and likely user intuition).
2019-09-06 22:10:34 -07:00
Pat Gavlin b7404f202e
Expose update events to ExtraRuntimeValidation. (#3160)
* Add the ability to log all engine events to a file.

The path to the file can be specified using the `--event-log` flag to
the CLI. The file will be truncated if it exists. Events are written as
a list of JSON values using the schema described by `pkg/apitype`.

* Expose update engine events to ExtraRuntimeValidation.

Just what it says on the tin. Events from previews are not exposed.
2019-09-06 17:07:54 -07:00
Matt Ellis 685b30b685 Ignore plugins which are being installed
When installing plugins, we download the plugin into a temporary
folder, unpack it and then move that folder into its final
location (as an atomic operation). We do this so that if the download
fails in some way, we would not "poision" our plugin cache.

In order to ensure the move into the final location happens
atomically, we download the plugin into a folder with a `.tmpXXXXXX`
suffix inside the plugin root itself.  However, we were not ignoring
this folder when enumarating plugins. This would cause some weird
behaviors:

- When a plugin was being installed `pulumi plugin ls` would show a
plugin with a version like `v1.0.0-rc.1.tmp123456`.

- For cases where the version of the plugin had applied
metadata (e.g. our alpha builds where we append the commit hash to the
version via `+gACBDEF123`) the `.tmpXXXXXX` suffix was considered part
of the build metadata. This would mean we could actually end up
selecting these plugins and trying to run them, which was not going to
work correctly (since they are in the process of being
downloaded). Because the way to hit this was using a dev release while
also trying to run a another program that used the same plugin, it was
unlikely that customers would hit this, but we would see this from
time to time in CI, where we run many pulumi programs at the same
time (the `examples` repo is one case where we'd often hit it).

Fixes: #1353
2019-09-06 13:49:57 -07:00
Paul Stack b54a1902cc
Exclude stack owner from stackname when using CloudStorage (#3169)
This was causing an error as follows:

```
error: could not create stack: validating stack properties: invalid stack name: a stack name may only contain alphanumeric, hyphens, underscores, or periods
```
2019-09-02 19:29:45 +03:00
CyrusNajmabadi 015bada975 Add more details to an assert (#3129)
Since we don't fully understand what was causing the assert to file,
instead of making changes to return an error when there are equal
plugins, keep the shape of the existing code and just do the work we
need to do to ensure that the assert message has actionable data for
us to look at.
2019-08-28 11:28:04 -07:00
Luke Hoban f0a24079ce
Filter the list of templates shown by default (#3147)
If any templates are marked as `Important: true` then by default show only those templates along with an option to see additional templates.

Fixes #3094.
2019-08-27 17:56:49 -07:00
Luke Hoban 47dc3cfb8b
Print a Welcome to Pulumi message (#3145)
Present a warm welcome to users when they interactively login.

Also use this as an opportunity to present a "Tip of the Day" - which for now we will use to highlight auto-naming as this has been a common new user question.
2019-08-27 17:19:35 -07:00
Alex Clemmer 99d70e4610 Introduce MarshalOptions.{RejectAsset, RejectArchive}
Not all resource providers support Pulumi's Asset and Archive types. In
particular, the Kubernetes provider should reject any resource
definition that contains either of these types.

This commit will introduce two MarshalOptions that will make it easy for
the Kubernetes provider to guarantee that no properties of this type are
in a resource request, as it's deserializing the request from the
engine.
2019-08-26 15:19:14 -07:00
Matt Ellis 5188232afa
Merge pull request #3135 from pulumi/ellismg/use-pip-install-not-pienv-install
Use pip and not pipenv for installing dependencies during testing
2019-08-23 17:58:06 -07:00
Pat Gavlin 2455564ddc
Allow IDs to change during import. (#3133)
This is necessary for resources like `aws.ec2.RouteTableAssociation`.

Part of https://github.com/pulumi/pulumi-aws/issues/708.
2019-08-23 15:00:24 -07:00
Matt Ellis ec6abd84d1 Use pip and not pipenv for installing dependencies during testing
This matches what we tell our customers to do and makes some
downstream testing stuff for beta versions of our python packages
easier (since `pip` has a more straightforward package selection
algorithm than `pipenv`)
2019-08-23 13:48:09 -07:00
Mikhail Shilkov a2769f385e Format 2019-08-23 14:45:29 +02:00
Mikhail Shilkov 6ac9770a46 Linter 2019-08-23 14:45:29 +02:00
Mikhail Shilkov 273ade2ac0 Parameterize the progress function with a message 2019-08-23 14:45:29 +02:00
Mikhail Shilkov 370047bbb6 Show a progress bar for plugin installation during pulumi up 2019-08-23 14:45:29 +02:00