Commit graph

44 commits

Author SHA1 Message Date
Matt Ellis b7b80f7ea1 Use glog instead of printf
When running `pulumi logs -f` we'd also see these messages printed to
standard out:

Getting more logs for /aws/lambda/urlshortenereeb67ce9-d8fa6fa...

This could be useful diagnostics information, but we should be
glog'ing it not unconditionally writing it to the terminal.
2018-04-27 18:27:37 -07:00
Matthew Riley f9b7468bfd Don't cache AWS sessions with different credentials
We might create an AWS session with one set of credentials, cache it, then
return it when a later caller asked for a session with *different* creds.

Instead, just cache one default session and Copy other sessions from it.

Less important in the CLI, but critical when the engine is used as a library
in a long-running process.
2018-04-09 16:57:27 -07:00
joeduffy 8b5874dab5 General prep work for refresh
This change includes a bunch of refactorings I made in prep for
doing refresh (first, the command, see pulumi/pulumi#1081):

* The primary change is to change the way the engine's core update
  functionality works with respect to deploy.Source.  This is the
  way we can plug in new sources of resource information during
  planning (and, soon, diffing).  The way I intend to model refresh
  is by having a new kind of source, deploy.RefreshSource, which
  will let us do virtually everything about an update/diff the same
  way with refreshes, which avoid otherwise duplicative effort.

  This includes changing the planOptions (nee deployOptions) to
  take a new SourceFunc callback, which is responsible for creating
  a source specific to the kind of plan being requested.

  Preview, Update, and Destroy now are primarily differentiated by
  the kind of deploy.Source that they return, rather than sprinkling
  things like `if Destroying` throughout.  This tidies up some logic
  and, more importantly, gives us precisely the refresh hook we need.

* Originally, we used the deploy.NullSource for Destroy operations.
  This simply returns nothing, which is how Destroy works.  For some
  reason, we were no longer doing this, and instead had some
  `if Destroying` cases sprinkled throughout the deploy.EvalSource.
  I think this is a vestige of some old way we did configuration, at
  least judging by a comment, which is apparently no longer relevant.

* Move diff and diff-printing logic within the engine into its own
  pkg/engine/diff.go file, to prepare for upcoming work.

* I keep noticing benign diffs anytime I regenerate protobufs.  I
  suspect this is because we're also on different versions.  I changed
  generate.sh to also dump the version into grpc_version.txt.  At
  least we can understand where the diffs are coming from, decide
  whether to take them (i.e., a newer version), and ensure that as
  a team we are monotonically increasing, and not going backwards.

* I also tidied up some tiny things I noticed while in there, like
  comments, incorrect types, lint suppressions, and so on.
2018-03-28 07:45:23 -07:00
Pat Gavlin a23b10a9bf
Update the copyright end date to 2018. (#1068)
Just what it says on the tin.
2018-03-21 12:43:21 -07:00
Chris Smith 441f4566c7
Fix panic when getting logs for older stacks (#1053)
* Fix panic when getting logs for older stacks

* Make GetChild return a tuple

* Update tests; add test
2018-03-15 13:26:43 -07:00
Matt Ellis 936cab0c22 Add a version property to checkpoints
This takes the existing `apitype.Checkpoint` type and renames it to
`apitype.CheckpointV1` locking in the shape. In addition, we introduce
a `apitype.VersionedCheckpoint` type, which holds a version number and
a json document representing a checkpoint at that version. Now, when
reading a checkpoint, the CLI can determine if it's in a format it
understands, and fail gracefully if it is not.

While the CLI understands the older checkpoint version, it always
writes the newest version format, meaning that if you manage a
fire-and-forget stack with this version of the CLI, it will be
un-readable by previous versions.

Stacks managed by Pulumi.com are not impacted by this change.

Fixes: #887
2018-03-10 13:03:05 -08:00
Matt Ellis 731463c282 Have MakeKey fail if namespace contains a colon
This helper method is only really used for testing, but we should not
allow it to create a Key who's namespace has a colon (as ParseKey
would not build something like this).
2018-03-08 11:52:48 -08:00
Matt Ellis 81a273c7bb Change represention of config.Key
config.Key has become a pair of namespace and name. Because the whole
world has not changed yet, there continues to be a way to convert
between a tokens.ModuleMember and config.Key, however now sometime the
conversion from tokens.ModuleMember can fail (when the module member
is not of the form `<package>:config:<name>`).
2018-03-08 10:52:25 -08:00
Matt Ellis 7c39620e9a Introduce config.Key
Right now, config.Key is a type alias for tokens.ModuleMember. I did a
pass over the codebase such that we use config.Key everywhere it
looked like the value did not leak to some external process (e.g a
resource provider or a langhost).

Doing this makes it a little clearer (hopefully) where code is
depending on a module member structure (e.g. <package>:config:<value>)
instead of just an opaque type.
2018-03-08 10:52:25 -08:00
joeduffy 2362d45a5c Eliminate type redundancy
Despite our good progress moving towards having an apitype package,
where our exchange types live and can be shared among the engine and
our services, there were a few major types that were still duplciated.
Resource was the biggest example -- and indeed, the apitype varirant
was missing the new Dependencies property -- but there were others,
like Manfiest, PluginInfo, etc.  These too had semi-random omissions.

This change merges all of these types into the apitype package.  This
not only cleans up the redundancy and missing properties, but will
"force the issue" with respect to keeping them in sync and properly
versioning the information in a backwards compatible way.

The resource/stack package still exists as a simple marshaling layer
to and from the engine's core data types.

Finally, I've made the controversial change to share the actual
Deployment data structure at the apitype layer also.  This will force
us to confront differences in that data structure similarly, and will
allow us to leverage the strong typing throughout to catch issues.
2018-02-28 12:44:55 -08:00
Luke Hoban c7adaf107d
Don't include pending-delete resources in tree representation (#902)
Resources in the checkpoint file which are pending-delete represent old versions of resources which are no longer part of the active deployment.  For purposes of constructing the active resource tree, we should skip these resources.
2018-02-12 08:47:09 -08:00
Matthew Riley b0905d99aa Fix long line 2018-01-30 10:52:42 -08:00
Matthew Riley c74db59231 Keep embedded newlines in Lambda log messages
Set the `s` flag in the regexp so `.` matches `\n`.

Add an explicit `\n` to the regexp to account for the newline inserted by Lambda.
2018-01-29 23:33:59 -08:00
joeduffy 5ac81c2818 Add missing Infof argument 2017-12-27 14:54:27 -08:00
Luke Hoban bc95745fb6
Update regexp to match changes in AWS generated names (#760)
Also keeps support for older name generation pattern.
2017-12-22 14:49:42 -08:00
Luke Hoban 7cc782e856
Add support for pulumi logs --since when targeting cloud backend (#756)
Hooks up the CLI to be able to pass query parameters through to the
service.

Part of pulumi/pulumi-service#431.
2017-12-21 17:16:45 -08:00
Luke Hoban 3b461ffcb3
Use AWS access key in operations prvider when available (#697)
If the stack config specifies AWS credentials, these should be used in the operations provider instead of ambient credentials.  This is necessary to ensure that we have access to resources in the target account.

Fixes pulumi/pulumi-service#389
2017-12-11 15:40:39 -08:00
Luke Hoban 90c7305f55
Update logs after changes in pulumi/cloud names (#684) 2017-12-09 17:27:43 -08:00
CyrusNajmabadi 75ee89f2b1
Always add 8 chars of randomness to URN names we create. Error if that exceeds the max length allowed for that resource. (#500)
* Include parent type in urn to better ensure component URN uniqueness.
2017-12-04 14:50:55 -08:00
Joe Duffy 8d862b52c5
Merge pull request #632 from pulumi/629_cloud
Improve the overall cloud CLI experience
2017-12-03 08:40:34 -08:00
joeduffy 1c4e41b916 Improve the overall cloud CLI experience
This improves the overall cloud CLI experience workflow.

Now whether a stack is local or cloud is inherent to the stack
itself.  If you interact with a cloud stack, we transparently talk
to the cloud; if you interact with a local stack, we just do the
right thing, and perform all operations locally.  Aside from sometimes
seeing a cloud emoji pop-up ☁️, the experience is quite similar.

For example, to initialize a new cloud stack, simply:

    $ pulumi login
    Logging into Pulumi Cloud: https://pulumi.com/
    Enter Pulumi access token: <enter your token>
    $ pulumi stack init my-cloud-stack

Note that you may log into a specific cloud if you'd like.  For
now, this is just for our own testing purposes, but someday when we
support custom clouds (e.g., Enterprise), you can just say:

    $ pulumi login --cloud-url https://corp.acme.my-ppc.net:9873

The cloud is now the default.  If you instead prefer a "fire and
forget" style of stack, you can skip the login and pass `--local`:

    $ pulumi stack init my-faf-stack --local

If you are logged in and run `pulumi`, we tell you as much:

    $ pulumi
    Usage:
      pulumi [command]

    // as before...

    Currently logged into the Pulumi Cloud ☁️
        https://pulumi.com/

And if you list your stacks, we tell you which one is local or not:

    $ pulumi stack ls
    NAME            LAST UPDATE       RESOURCE COUNT   CLOUD URL
    my-cloud-stack  2017-12-01 ...    3                https://pulumi.com/
    my-faf-stack    n/a               0                n/a

And `pulumi stack` by itself prints information like your cloud org,
PPC name, and so on, in addition to the usuals.

I shall write up more details and make sure to document these changes.

This change also fairly significantly refactors the layout of cloud
versus local logic, so that the cmd/ package is resonsible for CLI
things, and the new pkg/backend/ package is responsible for the
backends.  The following is the overall resulting package architecture:

* The backend.Backend interface can be implemented to substitute
  a new backend.  This has operations to get and list stacks,
  perform updates, and so on.

* The backend.Stack struct is a wrapper around a stack that has
  or is being manipulated by a Backend.  It resembles our existing
  Stack notions in the engine, but carries additional metadata
  about its source.  Notably, it offers functions that allow
  operations like updating and deleting on the Backend from which
  it came.

* There is very little else in the pkg/backend/ package.

* A new package, pkg/backend/local/, encapsulates all local state
  management for "fire and forget" scenarios.  It simply implements
  the above logic and contains anything specific to the local
  experience.

* A peer package, pkg/backend/cloud/, encapsulates all logic
  required for the cloud experience.  This includes its subpackage
  apitype/ which contains JSON schema descriptions required for
  REST calls against the cloud backend.  It also contains handy
  functions to list which clouds we have authenticated with.

* A subpackage here, pkg/backend/state/, is not a provider at all.
  Instead, it contains all of the state management functions that
  are currently shared between local and cloud backends.  This
  includes configuration logic -- including encryption -- as well
  as logic pertaining to which stacks are known to the workspace.

This addresses pulumi/pulumi#629 and pulumi/pulumi#494.
2017-12-02 14:34:42 -08:00
Luke Hoban 1ab9ae1dda Fix error handling in GetLogs
Ensure we don't create a multierror unless there is at least one non-nil error.
2017-12-02 13:00:49 -08:00
joeduffy 88086816f2 Merge branch 'master' of github.com:pulumi/pulumi into resource_parenting_lite 2017-11-29 08:16:38 -08:00
joeduffy b02cf64416 Tolerate missing children
This changes our resource creation logic to tolerate missing children.
This ultimately shouldn't be necessary, but we appear to have a bug where
sometimes during deletions we end up with dangling child pointers.  See
pulumi/pulumi#613; it tracks fixing the bug, and also removing this
workaround and reenabling the assertion.
2017-11-28 20:07:27 -08:00
joeduffy 7d4f735ffa Make resource tree creation order independent 2017-11-28 18:03:48 -08:00
Luke Hoban 65c9025480
Address PR feedback on #600 (#611) 2017-11-28 12:54:36 -08:00
joeduffy 5762f2d0a6 Merge remote-tracking branch 'origin/resource_parenting' into resource_parenting_lite 2017-11-28 11:03:34 -08:00
joeduffy fbff100789 Expose operations.NewResourceMap and Tree APIs
This change includes a NewResourceMap API, alongside the existing,
but renamed, NewResourceTree API.  This also tidies up the resulting
struct for public consumption.  This is required for downstream tests.
2017-11-28 07:43:07 -08:00
joeduffy 17ab1120e5 Integrate parent/child pointer changes with ops pkg 2017-11-27 11:08:04 -08:00
Luke Hoban a79b3ab50f TODO and comment fixup 2017-11-26 09:57:41 -08:00
Luke Hoban 6c694dd959 Use better names for container logs
Use the URN name instead of the log group name for logs reported up by `cloud:service:Service` and `cloud:task:Task` components.
2017-11-22 21:46:50 -08:00
Luke Hoban 75f7416524 Collect logs in parallel
Parallelize collection of logs at each layer of the resource tree walk.  Since almost all cost of log collection is at leaf nodes, this should allow the total time for log collection to be close to the time taken for the single longest leaf node, instead of the sum of all leaf nodes.
2017-11-22 21:33:36 -08:00
Luke Hoban 88452ff8da Include all children of resources that match resource filter in logging
We need to clear the resource filter during the resource tree walk to ensure that logs from children of matched resources are collected and aggregated.
2017-11-22 21:10:23 -08:00
Luke Hoban 9648444b05 Support for filtering logs by resource 2017-11-22 20:58:46 -08:00
Luke Hoban e8a8bfb2c5 Fix lint errors 2017-11-22 13:08:19 -08:00
Luke Hoban 098c90419a Use correct source ID for logs from LogCollector
We have to reverse engineer the name from the soruce LogGroup information since that is all we got at runtime, but luckily that is sufficient given current name generation approach.

This kind of code is *very* sensitive to any changes to automatic name generation - but that is likely inevitable at this layer.
2017-11-22 12:47:40 -08:00
Luke Hoban 512044b407 Simplify paging FilterLogEvents 2017-11-20 23:23:11 -08:00
Luke Hoban bee1b55b0b Get all pages of results 2017-11-20 23:18:47 -08:00
Luke Hoban c6aac7df89 Support --since on pulumi logs
Adds a `since` flag which gets only longs since some relative offset in the past.
2017-11-20 16:37:41 -08:00
Luke Hoban af34e5cb83 Add container logging support
Also fix bug in de-duping.
2017-11-20 14:55:09 -08:00
Luke Hoban 7555eed3d5 Consolidate AWS operations 2017-11-20 13:44:23 -08:00
Luke Hoban 16ccc67654 Incorporate logs from logCollector
Also allow AWS Lambda Function logs to be projected in raw form, but filtered/formatted by higher level layers.
2017-11-20 13:31:20 -08:00
Luke Hoban 329d70fba2 Rename cloud operations file 2017-11-19 22:31:30 -08:00
Luke Hoban 06f0559849 Refactoring of OperationsProvider code 2017-11-19 22:28:49 -08:00