Commit graph

97 commits

Author SHA1 Message Date
Alex Clemmer 429bde332b Print PolicyPacks run as part of update summary
Fixes pulumi/pulumi-policy#69.
2019-09-30 14:49:21 -07:00
Chris Smith 7254b3db4d
Remove vestigial field from apitype (#3284) 2019-09-30 08:33:47 -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
Erin Krengel cde4ecd84a
Add Applied to GetPolicyPackResponse (#3241) 2019-09-18 14:27:08 -07:00
Chris Smith 952b6d0d89
Remove some unused apitype fields (#3057) 2019-08-14 15:26:58 -07:00
Alex Clemmer ef8cc236c4 Implement --policy-pack flag on up and preview
Fixes pulumi/pulumi-policy#43.
2019-08-12 12:45:48 -07:00
Erin Krengel 2a968a2086
Move required PP out of start update (#3023) 2019-08-05 13:57:43 -07:00
Alex Clemmer 826e6a1cca Add pulumi policy apply command 2019-07-16 00:58:33 -07:00
Alex Clemmer fc80eaaa3d Implement GetAnalyzerInfo in analyzer plugin 2019-07-16 00:58:33 -07:00
Paul Stack 02ffff8840
Addition of Custom Timeouts (#2885)
* Plumbing the custom timeouts from the engine to the providers

* Plumbing the CustomTimeouts through to the engine and adding test to show this

* Change the provider proto to include individual timeouts

* Plumbing the CustomTimeouts from the engine through to the Provider RPC interface

* Change how the CustomTimeouts are sent across RPC

These errors were spotted in testing. We can now see that the timeout
information is arriving in the RegisterResourceRequest

```
req=&pulumirpc.RegisterResourceRequest{
           Type:                    "aws:s3/bucket:Bucket",
           Name:                    "my-bucket",
           Parent:                  "urn:pulumi:dev::aws-vpc::pulumi:pulumi:Stack::aws-vpc-dev",
           Custom:                  true,
           Object:                  &structpb.Struct{},
           Protect:                 false,
           Dependencies:            nil,
           Provider:                "",
           PropertyDependencies:    {},
           DeleteBeforeReplace:     false,
           Version:                 "",
           IgnoreChanges:           nil,
           AcceptSecrets:           true,
           AdditionalSecretOutputs: nil,
           Aliases:                 nil,
           CustomTimeouts:          &pulumirpc.RegisterResourceRequest_CustomTimeouts{
               Create:               300,
               Update:               400,
               Delete:               500,
               XXX_NoUnkeyedLiteral: struct {}{},
               XXX_unrecognized:     nil,
               XXX_sizecache:        0,
           },
           XXX_NoUnkeyedLiteral: struct {}{},
           XXX_unrecognized:     nil,
           XXX_sizecache:        0,
       }
```

* Changing the design to use strings

* CHANGELOG entry to include the CustomTimeouts work

* Changing custom timeouts to be passed around the engine as converted value

We don't want to pass around strings - the user can provide it but we want
to make the engine aware of the timeout in seconds as a float64
2019-07-16 00:26:28 +03:00
Erin Krengel 433c7ed7e5
add GetPolicyPackResponse (#2923) 2019-07-12 13:10:05 -07:00
Pat Gavlin 6e5c4a38d8
Defer all diffs to resource providers. (#2849)
Thse changes make a subtle but critical adjustment to the process the
Pulumi engine uses to determine whether or not a difference exists
between a resource's actual and desired states, and adjusts the way this
difference is calculated and displayed accordingly.

Today, the Pulumi engine get the first chance to decide whether or not
there is a difference between a resource's actual and desired states. It
does this by comparing the current set of inputs for a resource (i.e.
the inputs from the running Pulumi program) with the last set of inputs
used to update the resource. If there is no difference between the old
and new inputs, the engine decides that no change is necessary without
consulting the resource's provider. Only if there are changes does the
engine consult the resource's provider for more information about the
difference. This can be problematic for a number of reasons:

- Not all providers do input-input comparison; some do input-state
  comparison
- Not all providers are able to update the last deployed set of inputs
  when performing a refresh
- Some providers--either intentionally or due to bugs--may see changes
  in resources whose inputs have not changed

All of these situations are confusing at the very least, and the first
is problematic with respect to correctness. Furthermore, the display
code only renders diffs it observes rather than rendering the diffs
observed by the provider, which can obscure the actual changes detected
at runtime.

These changes address both of these issues:
- Rather than comparing the current inputs against the last inputs
  before calling a resource provider's Diff function, the engine calls
  the Diff function in all cases.
- Providers may now return a list of properties that differ between the
  requested and actual state and the way in which they differ. This
  information will then be used by the CLI to render the diff
  appropriately. A provider may also indicate that a particular diff is
  between old and new inputs rather than old state and new inputs.

Fixes #2453.
2019-07-01 12:34:19 -07:00
Chris Smith f59a934044
Add EngineEventsBatch type (#2858) 2019-06-23 16:56:09 -07:00
Erin Krengel 93c2736e2d
move requiredPolicies to UpdateProgramResponse (#2850) 2019-06-19 16:42:02 -07:00
Alex Clemmer 0fc4bc7885 Remove policy ID from policy API 2019-06-13 17:39:30 -07:00
Alex Clemmer 8b7d329c69 Use Analyzer PB in analyzer code 2019-06-13 16:04:13 -07:00
Erin Krengel 96f82f004f
Ekrengel/pac apitypes (#2798) 2019-06-04 10:27:53 -07:00
Luke Hoban 15e924b5cf
Support aliases for renaming, re-typing, or re-parenting resources (#2774)
Adds a new resource option `aliases` which can be used to rename a resource.  When making a breaking change to the name or type of a resource or component, the old name can be added to the list of `aliases` for a resource to ensure that existing resources will be migrated to the new name instead of being deleted and replaced with the new named resource.

There are two key places this change is implemented. 

The first is the step generator in the engine.  When computing whether there is an old version of a registered resource, we now take into account the aliases specified on the registered resource.  That is, we first look up the resource by its new URN in the old state, and then by any aliases provided (in order).  This can allow the resource to be matched as a (potential) update to an existing resource with a different URN.

The second is the core `Resource` constructor in the JavaScript (and soon Python) SDKs.  This change ensures that when a parent resource is aliased, that all children implicitly inherit corresponding aliases.  It is similar to how many other resource options are "inherited" implicitly from the parent.

Four specific scenarios are explicitly tested as part of this PR:
1. Renaming a resource
2. Adopting a resource into a component (as the owner of both component and consumption codebases)
3. Renaming a component instance (as the owner of the consumption codebase without changes to the component)
4. Changing the type of a component (as the owner of the component codebase without changes to the consumption codebase)
4. Combining (1) and (3) to make both changes to a resource at the same time
2019-05-31 23:01:01 -07:00
Chris Smith 6577784114
Reduce overhead of emitting engine events (#2735)
* Reduce size of most common apitype EngineEvents

* Update endpoint names for trace logging
2019-05-22 12:22:40 -07:00
Matt Ellis cb59c21c01 Rename SecretOutputs to AdditionalSecretOutputs
This makes the intention of this field clearer.
2019-05-10 17:07:52 -07:00
Matt Ellis 307ee72b5f Use existing secrets manager when roundtripping
There are a few operations we do (stack rename, importing and edits)
where we will materialize a `deploy.Snapshot` from an existing
deployment, mutate it in somewhay, and then store it.

In these cases, we will just re-use the secrets manager that was used
to build the snapshot when we re-serialize it. This is less than ideal
in some cases, because many of these operations could run on an
"encrypted" copy of the Snapshot, where Inputs and Outputs have not
been decrypted.

Unfortunately, our system now is not set up in a great way to support
this and adding something like a `deploy.EncryptedSnapshot` would
require large scale code duplications.

So, for now, we'll take the hit of decrypting and re-encrypting, but
long term introducing a `deploy.EncryptedSnapshot` may be nice as it
would let us elide the encryption/decryption steps in some places and
would also make it clear what parts of our system have access to the
plaintext values of secrets.
2019-05-10 17:07:52 -07:00
Matt Ellis 480a2f6c9e Augment secret outputs based on per request options 2019-05-10 17:07:52 -07:00
Matt Ellis cc74ef8471 Encrypt secret values in deployments
When constructing a Deployment (which is a plaintext representation of
a Snapshot), ensure that we encrypt secret values. To do so, we
introduce a new type `secrets.Manager` which is able to encrypt and
decrypt values. In addition, it is able to reflect information about
itself that can be stored in the deployment such that we can
deserialize the deployment into a snapshot (decrypting the values in
the process) without external knowledge about how it was encrypted.

The ability to do this is import for allowing stack references to
work, since two stacks may not use the same manager (or they will use
the same type of manager, but have different state).

The state value is stored in plaintext in the deployment, so it **must
not** contain sensitive data.

A sample manager, which just base64 encodes and decodes strings is
provided, as it useful for testing. We will allow it to be varried
soon.
2019-05-10 17:07:52 -07:00
CyrusNajmabadi ca373c1c1e
Fix spelling (#2567) 2019-03-19 11:35:17 -07:00
Matt Ellis d1f8af249d Add apitype for stack rename request 2019-03-11 14:44:15 -07:00
Pat Gavlin 4b33a45561
Filter diff keys based on provider info (#2526)
If a provider returns information about the top-level properties that
differ, use those keys to filter the diffs that are rendered to the
user.

Fixes #2453.
2019-03-06 16:41:19 -08:00
Pat Gavlin 1ecdc83a33 Implement more precise delete-before-replace semantics. (#2369)
This implements the new algorithm for deciding which resources must be
deleted due to a delete-before-replace operation.

We need to compute the set of resources that may be replaced by a
change to the resource under consideration. We do this by taking the
complete set of transitive dependents on the resource under
consideration and removing any resources that would not be replaced by
changes to their dependencies. We determine whether or not a resource
may be replaced by substituting unknowns for input properties that may
change due to deletion of the resources their value depends on and
calling the resource provider's Diff method.

This is perhaps clearer when described by example. Consider the
following dependency graph:

  A
__|__
B   C
|  _|_
D  E F

In this graph, all of B, C, D, E, and F transitively depend on A. It may
be the case, however, that changes to the specific properties of any of
those resources R that would occur if a resource on the path to A were
deleted and recreated may not cause R to be replaced. For example, the
edge from B to A may be a simple dependsOn edge such that a change to
B does not actually influence any of B's input properties. In that case,
neither B nor D would need to be deleted before A could be deleted.

In order to make the above algorithm a reality, the resource monitor
interface has been updated to include a map that associates an input
property key with the list of resources that input property depends on.
Older clients of the resource monitor will leave this map empty, in
which case all input properties will be treated as depending on all
dependencies of the resource. This is probably overly conservative, but
it is less conservative than what we currently implement, and is
certainly correct.
2019-01-28 09:46:30 -08:00
Pat Gavlin cfe4e127be
Add API types for the V3 checkpoint (#2384)
Resources gain two new fields: `PropertyDependencies` and
`PendingReplacement`. The former maps an input property's name to the
dependencies that may affect the value of that property. The latter is
used to track resources that have been deleted as part of a
delete-before-replace operation but have not yet been recreated.

In addition to the new fields, resource properties may now contain
encrypted first-class secret values. These values are of type `SecretV1`,
where the `Sig` field is set to `resource.SecretSig`.

Finally, the deployment type gains a new field, `SecretsProviders`,
which contains any configuration necessary to handle secrets that may be
present in resource properties.
2019-01-23 13:33:25 -08:00
Matt Ellis 6a2e20a289 Rename projName to projectName in apitype.Stack
This value was never used before, but it had a shorter name. In other
API Types we are using `projectName` which we all prefer. Since we are
going to start using this value going forward, let's adopt the good
name now when it won't break anyone.
2019-01-14 14:40:00 -08:00
Matt Ellis 732166450e Add projectName member of StackSummary API type
This will allow the service to include information about what project
a stack is assocated with when listing all stacks a user has access
to.

This was not previously needed because the project did not play into
the stack identity, but it will shortly.
2019-01-08 12:52:09 -08:00
Chris Smith 3045236dec
Record engine events concurrently (#2314)
* Record engine events concurrently

* Drop errors recording engine events
2018-12-20 15:34:30 -08:00
Chris Smith 84ea2f0df7
Don't emit pre-rendered update logs (#2268)
* Don't emit pre-rendered update logs

* Retry posting engine events if needed

* Update comment
2018-12-04 14:46:32 -08:00
Chris Smith ba31c6c69a
Incorporate feedback on Engine Events API (#2235)
* Add Sequence number to EngineEvents apitype

* Fix typo

* Send Timestamp with EngineEvents
2018-11-27 07:34:44 -08:00
Chris Smith c63c43b3a9 Add missing annotation 2018-11-09 11:11:05 -08:00
Chris Smith 8b76fd53d1
Record engine events (#2168)
* apitypes for surfacing engine events

* Add more comments to runEngineAction

* Persist engine events in the service

* Use cmdutil.IsTruthy
2018-11-09 10:01:29 -08:00
Joe Duffy 9aedb234af
Tidy up some data structures (#2135)
In preparation for some workspace restructuring, I decided to scratch a
few itches of my own in the code:

* Change project's RuntimeInfo field to just Runtime, to match the
  serialized name in JSON/YAML.

* Eliminate the no-longer-used Context and NoDefaultIgnores fields on
  project, and all of the associated legacy PPC-related code.

* Eliminate the no-longer-used IgnoreFile constant.

* Remove a bunch of "// nolint: lll" annotations, and simply format
  the structures with comments on dedicated lines, to avoid overly
  lengthy lines and lint suppressions.

* Mark Dependencies and InitErrors as `omitempty` in the JSON
  serialization directives for CheckpointV2 files. This was done for
  the YAML directives, but (presumably accidentally) omitted for JSON.
2018-11-01 08:28:11 -07:00
Pat Gavlin a93bb948c8
Restore the CloudName field of apitype.Stack. (#2128)
This field is necessary in order to support downlevel CLIs.
2018-10-30 13:49:51 -07:00
Matt Ellis 74672857fd Remove pulumi archive and archive uploading code
In the past, we had a mode where the CLI would upload the Pulumi
program, as well as its contents and do the execution remotely.

We've since stopped supporting that, but all the supporting code has
been left in the CLI.

This change removes the code we had to support the above case,
including the `pulumi archive` command, which was a debugging tool to
generate the archive we would have uploaded (which was helpful in the
past to understand why behavior differed between local execution and
remote execution.)
2018-10-26 18:03:58 -07:00
Chris Smith f324a460e9
Remove references to Pulumi private clouds (#2095)
* Remove TODO for issue since fixed in PPCs.

* Update issue reference to source

* Update comment wording

* Remove --ppc arg of stack init

* Remove PPC references in int. testing fx

* Remove vestigial PPC API types
2018-10-24 13:50:35 -07:00
Praneet Loke 052bc69a52
Add gitlab metadata - Part 1 (#2090)
* Introduce new metadata keys `vcs.repo`, `vcs.kind` and `vcs.owner` to keep the keys generic for any vcs. Expanded the git SSH regex to account for bitbucket's .org domain.

* Introduce new stack tags keys with the same theme of detecting the vcs.
2018-10-23 14:53:52 -07:00
Chris Smith a7d70fa63b
Have ListStacksResponse include data required for 'stacks ls' (#1908)
* Have ListStacks return data required for 'stacks ls'

* Have ListStacks return data required for 'stacks ls'

* Split out org name and stack name
2018-09-10 12:50:10 -07:00
joeduffy cd5707f483 Clarify refresh text
The wording for refresh doesn't accurately convey that the operations
aren't actually mutating your resources, but instead are simply changing
your checkpoint state. This change (hopefully) helps in two ways:

First, put text just before the prompt:

Do you want to perform this refresh?
No resources will be modified as part of this refresh; just your stack's state will be.

Second, alter the summary ever-so-slightly, from:

info: 2 changes performed:
    ~ 2 resources updated
      3 resources unchanged

to:

info: 2 changes refreshed:
    ~ 2 resources updated
      3 resources unchanged

This reads just slightly better, and removes any sense of panic I might
have otherwise had that my refresh just did something wrong.

As I was in here, since I had to pass UpdateKind information to new
places, I cleaned up the situation where we had three mostly-similar
enums (but which actually diverged) and several areas where we were
using untyped strings for this same information. Now there's just one.

This fixes pulumi/pulumi#1551.
2018-08-29 17:09:14 -07:00
Sean Gillespie 347148c374
Don't try to convert a checkpoint's Latest field if nil (#1800)
Not all checkpoints have a Latest field and it is not guaranteed to be
non-nil. Fixes pulumi/pulumi#1788.
2018-08-20 13:47:49 -07:00
Matt Ellis e51e159d18 Warn when pulumi is out of date
Before running commands, ask the service for version information about
the CLI and warn the user to upgrade in some cases.

Fixes #1686
2018-08-13 13:18:02 -07:00
Sean Gillespie 491bcdc602
Add a list of in-flight operations to the deployment (#1759)
* Add a list of in-flight operations to the deployment

This commit augments 'DeploymentV2' with a list of operations that are
currently in flight. This information is used by the engine to keep
track of whether or not a particular deployment is in a valid state.

The SnapshotManager is responsible for inserting and removing operations
from the in-flight operation list. When the engine registers an intent
to perform an operation, SnapshotManager inserts an Operation into this
list and saves it to the snapshot. When an operation completes, the
SnapshotManager removes it from the snapshot. From this, the engine can
infer that if it ever sees a deployment with pending operations, the
Pulumi CLI must have crashed or otherwise abnormally terminated before
seeing whether or not an operation completed successfully.

To remedy this state, this commit also adds code to 'pulumi stack
import' that clears all pending operations from a deployment, as well as
code to plan generation that will reject any deployments that have
pending operations present.

At the CLI level, if we see that we are in a state where pending
operations were in-flight when the engine died, we'll issue a
human-friendly error message that indicates which resources are in a bad
state and how to recover their stack.

* CR: Multi-line string literals, renaming in-flight -> pending

* CR: Add enum to apitype for operation type, also name status -> type for clarity

* Fix the yaml type

* Fix missed renames

* Add implementation for lifecycle_test.go

* Rebase against master
2018-08-10 21:39:59 -07:00
Chris Smith 254c83f788
Expand ErrorResponse type (#1720) 2018-08-07 10:43:18 -07:00
Sean Gillespie 48aa5e73f8
Save resources obtained from ".get" in the snapshot (#1654)
* Protobuf changes to record dependencies for read resources

* Add a number of tests for read resources, especially around replacement

* Place read resources in the snapshot with "external" bit set

Fixes pulumi/pulumi#1521. This commit introduces two new step ops: Read
and ReadReplacement. The engine generates Read and ReadReplacement steps
when servicing ReadResource RPC calls from the language host.

* Fix an omission of OpReadReplace from the step list

* Rebase against master

* Transition to use V2 Resources by default

* Add a semantic "relinquish" operation to the engine

If the engine observes that a resource is read and also that the
resource exists in the snapshot as a non-external resource, it will not
delete the resource if the IDs of the old and new resources match.

* Typo fix

* CR: add missing comments, DeserializeDeployment -> DeserializeDeploymentV2, ID check
2018-08-03 14:06:00 -07:00
Sean Gillespie 48d095d66f Remove "down" operation for migration - it is not semantically valid in
general.
2018-07-27 14:52:28 -07:00
Sean Gillespie 9ca76b65c0
Round out V2 breaking changes for Resource 2018-07-27 13:53:14 -07:00
Alex Clemmer f037c7d143 Checkpoint resource initialization errors
When a resource fails to initialize (i.e., it is successfully created,
but fails to transition to a fully-initialized state), and a user
subsequently runs `pulumi update` without changing that resource, our
CLI will fail to warn the user that this resource is not initialized.

This commit begins the process of allowing our CLI to report this by
storing a list of initialization errors in the checkpoint.
2018-07-20 17:59:06 -07:00