Commit graph

2343 commits

Author SHA1 Message Date
Matthew Riley c0a69a5131 Honor PULUMI_FAILED_TESTS_DIR when destroy fails
We weren't keeping the test directory around when the deferred function
failed the test because the failure happened after we set `testFinished`.
2018-03-07 11:26:42 -08:00
Joe Duffy 0d66dbf160
Merge pull request #1005 from pulumi/python_prereqs
Prefer Python2 tools; fail-fast when wrong
2018-03-07 09:07:14 -08:00
joeduffy 66f3f84d16 Disable Pylint temporarily
This change temporarily disables Pylint.  Assuming it is on the path,
and furthermore that the one on the path runs under 2.7, simply won't
work.  See pulumi/pulumi#1007 for details; it also tracks reenabling.
2018-03-07 09:06:51 -08:00
Matt Ellis d78755765e Set ROOT in publish_packages.sh 2018-03-06 19:36:41 -08:00
Matt Ellis 936abeb118 Publish tgz's in the middle of the build, packages at the end
While it's safe to publish the tgz that we use internally for other
repositories that are on "the link plan" after the build completes, we
shouldn't publish packages to NPM and PyPi at that point. There are
two reasons for doing this:

1. Publishing packages before they are tested, which means we could
end up publishing packages that don't work.

2. NPM prevents publishing the same package more than once, so if we
had to re-run the job (due to tests failing for transient issues), the
publish step will start failing, preventing us from running the tests
at all.
2018-03-06 19:20:47 -08:00
joeduffy 440ffb27e5 Prefer Python2 tools; fail-fast when wrong
This change includes a few things:

1) Prefer python2 and pip2 when on the PATH, over the undecorated
   names python and pip.  This is the standard convention for package
   managers like Pip, etc., to support Python2 and Python3 side-by-side.

2) Fail-fast if neither can be found on the PATH.

3) Check the reported version number for python, pip, and pylint, and
   fail-fast if it doesn't report back 2.7, just to safeguard against
   undecorated binaries with unsupported versions.

Also, we had not listed wheel as a dependency in the requirements.txt
file.  This needs to be there to support building bdist_wheels.  Fixed.
2018-03-06 17:50:42 -08:00
Matt Ellis 70633c2a06 Copy stack config for non aditive tests
The change to refactor out where we store configuration data broke our
old strategy, which we discovered when we tried to take this payload
into pulumi-aws.
2018-03-06 17:32:36 -08:00
Luke Hoban f59931d242
Fix filename in Node.js SDK tsconfig (#1001) 2018-03-05 18:29:38 -08:00
Sean Gillespie 93cc2cd5cb
Fix some unecessary branches to appease golint (#999) 2018-03-05 16:15:09 -08:00
CyrusNajmabadi 410351f571
Do not throw if 'typeof' references an undeclared variable. (#998) 2018-03-05 12:58:25 -08:00
Joe Duffy 09cceb4e9e
Remove a few outdated references (#997) 2018-03-04 13:34:20 -08:00
Joe Duffy caceeea290
Reintroduce untyped deployments (#996)
By using untyped deployment structures via `json.RawMessage`, we can
support round-tripping between old CLI clients and newer servers, without
dropping possibly-important information on the floor.  I hadn't realized
this design goal with the original system, and after talking to @pgavlin,
I better realized the intent and that we want to preserve this.
2018-03-03 12:12:54 -08:00
Matt Ellis 96d7f9307a
Merge pull request #986 from pulumi/config-refactor
Rework config storage
2018-03-02 13:46:49 -08:00
joeduffy e0554b08d8 Only publish packages on Linux 2018-03-01 18:14:19 -08:00
joeduffy c2b1705bf9 Pass Pulumi API token to PyPI in the querystring 2018-03-01 17:43:56 -08:00
Matt Ellis cdcee76abd Fix flaky update history test
The filenames we used to store history data locally only had second
level precision. On my machine, the test history test is able to run
multiple `pulumi update` commands in the same second, which causes a
newer history file to overwrite an older one.

This change moves to using a nanosecond precision timestamp when
writing config. In addition, the CLI was trying to sort the updates
that came back from the backend (instead of just trusting them to be
in newest first order, as we documented) so I removed that code as
well.
2018-03-01 16:20:09 -08:00
joeduffy 567724ed30 Pass username/password to twine publish
This prevents blocking waiting on stdin, which obviously will hang CI.
2018-03-01 09:33:42 -08:00
CyrusNajmabadi f295a5ca66
Remove line from travis. (#990) 2018-03-01 00:49:00 -08:00
CyrusNajmabadi e7c0e4cdaa
Make many fixes to closure serialization (#944)
Make many fixes to closure serialization

Primary things that i've done as part of this change:

    Added support for cyclic objects.
    Properly serialize objects that are shared across different function. previously you would get multiple copies, now you properly reference the same copy.
    Remove the usages of 'hashes' for functions. Because we track identity of objects, we no longer need them.
    Serialize properties of functions (if they have any).
    Handle Objects/Functions with different __proto__s than normal. i.e. classes/constructors. but also anything the user may have done themselves to the object.
    Handle generator functions.
    Handle functions with 'computed' names.
    Handle functions with 'symbol' names.
    Handle serializing Promises as Promises.
    Removed the dual Closure/AsyncClosure tree. One existed solely so we could have a tree without promises (for use in testing maybe?). Because this all exists in a part of our codebase that is entirely async, it's fine to have promises in the tree, and to await them when serializing the Closure to a string.
    Handle serializing class-constructors and methods. Including properly handling 'super' calls.
2018-03-01 00:32:01 -08:00
Joe Duffy 9412f4ac7a
Publish Pulumi Python SDK package (#988)
We now publish the Pulumi Python SDK package to our private PyPI
server at the same time we also publish the NPM package.  For now,
we use the test Pulumi.com service, and will switch to staging as
soon as it becomes available.
2018-02-28 18:38:08 -08:00
Matt Ellis 4b850dcb15 Remove pkg/resource/idl
A hold-over from a previous experiment (LumiIDL) which we don't use
anymore. If we decide to bring that back, we can easily restore these
types, but for now, let's just remove this dead code.
2018-02-28 17:41:04 -08:00
Matt Ellis eb1b9d685f Remove pkg/compiler/errors
Most of the errors in this package are holdovers from our previous
syetem where we had our own custom compiler and evaluator and are no
longer needed. The few we still use during plan applicaton (via the
diagnostics system, which is another component from the old system
that we still use) have been promoted into the diag package. Doing so,
allows us to not have to import "github.com/pkg/errors" as "goerr" in
some parts of the engine, a nice cleaup.
2018-02-28 17:41:04 -08:00
Matt Ellis e2ce16b057 Upgrade configuration files on first run
Migrate configuration from the old model to the new model. The
strategy here is that when we first run `pulumi` we enumerate all of
the stacks from all of the backends we know about and for each stack
get the configuration values from the project and workspace and
promote them into the new file. As we do this, we remove stack
specific config from the workspace and Pulumi.yaml file.

If we are able to upgrade all the stacks we know about, we delete all
global configuration data in the workspace and in Pulumi.yaml as well.

We have a test that ensures upgrades continue to work.
2018-02-28 17:37:18 -08:00
Matt Ellis 207a9755d8 Rework configuration model
This change updates our configuration model to make it simpler to
understand by removing some features and changing how things are
persisted in files.

Notable changes:

- We've removed the notion of "workspace" vs "project"
  config. Now, configuration is always stored in a file next to
  `Pulumi.yaml` named `Pulumi.<stack-name>.yaml` (the same file we'd
  use for an other stack specific information we would need to persist
  in the future).
- We've removed the notion of project wide configuration. Every new
  stack gets a completely empty set of configuration and there's no
  way to share common values across stacks, instead the common value
  has to be set on each stack.

We retain some of the old code for the configuration system so we can
support upgrading a project in place. That will happen with the next
change.

This change fixes some issues and allows us to close some
others (since they are no longer possible).

Fixes #866
Closes #872
Closes #731
2018-02-28 17:30:50 -08:00
Matt Ellis 5f83fbf642 Remove Project() method from Workspace interface
We had other ways to get at this data, so let's just unify on them.
2018-02-28 17:25:09 -08:00
Matt Ellis d99f9457b0 Deprecate old configuration model
We are going to be changing the configuration model. To begin, let's
take most of the existing stuff and mark it as "deprecated" so we can
keep the existing behavior (to help transition newer code forward)
while making it clear what APIs should not be called in the
implementation of `pulumi` itself.
2018-02-28 17:25:09 -08:00
Joe Duffy 0079e4a1df
Merge pull request #985 from pulumi/984_import_errors
Eliminate type redundancy
2018-02-28 13:27:20 -08:00
joeduffy c737a3c89a Add a package apitype comment
Addresses feedback from @lukehoban.
2018-02-28 13:24:38 -08:00
joeduffy d7ef2fe498 Error if importing cross-stack checkpoints
Per pulumi/pulumi#984, we will now issue an error if it appears you're
importing a checkpoint from a different stack.  This can be overridden
if you know what you're doing (with --force), but in general this is a
sign that you're doing something very wrong that will be hard to undo.
2018-02-28 12:46:18 -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
Matt Ellis ed7a4d9157 Check plugin cache first; make version mismatch a warning
Previously, we would prefer a plugin on the $PATH which is more or
less always the case for people hacking on `pulumi`. Later, when we
went to check the loaded plugin version matched the one we requested,
we fail.

Now, if we have a version, we'll first consult the local plugin
cache. If that fails, we'll fall back to the $PATH as we used to.

When we are loading a plugin without a version, we continue to use the
one on the $PATH (without testing the cache) on the assumption it is
newer.

In addition, we've turned the "plugin versions are mis-matched" from
an error into a warning. We expect that we'll only ever see this
warning when something strange is going on (since in the normal case,
we'll have found the exact version in the cache) but having it not
hard fail does help in development cases.

Fixes #977
2018-02-26 11:39:50 -08:00
Justin Van Patten ac58f151b4
Change default of where stack is created (#971)
If currently logged in, `stack init` creates a managed stack. Otherwise, it creates a local
stack. This avoids the need to specify `--local` when not using the service.

As today, `--local` can be passed, which will create a local stack regardless of being logged
in or not.

A new flag, `--remote`, has been added, which can be passed to indicate a managed stack,
used to force an error if not logged into the service.
2018-02-26 11:00:16 -08:00
Sean Gillespie 1011989369
Produce better error messages when the main module is not found (#976)
* Produce better error messages when the main module is not found

If we fail to load a program's main module, inspect the program's
package.json and attempt to diagnose why the main module load failed.

* Code review feedback: entrypoint -> entry point, call out npm build explicitly, simplify control flow

* Code review feedback: add a little more levity to the unknown exception error message
2018-02-26 10:54:56 -08:00
Luke Hoban ff87af1a44
Workaround for issue with python setup.py (#980)
Pass `--prefix=` to avoid hitting: `error: can't combine user with with prefix/exec_prefix/home or install_(plat)base`.
2018-02-24 17:50:54 -08:00
Joe Duffy cc5ce42dc9
Merge pull request #800 from pulumi/754_python
Python support
2018-02-24 11:18:43 -08:00
joeduffy 1acb0eb226 Use new package name for empty test 2018-02-24 10:39:18 -08:00
joeduffy 329a003aff Rejigger Protobuf binplacing on Windows 2018-02-24 09:59:17 -08:00
joeduffy a1c4115fa6 Also setup.py with --user
This ensures we can properly install the built package in Travis's
images, which have everything owned by root by default.
2018-02-24 09:52:30 -08:00
joeduffy 4f591bed76 Use a newer pylint
This ensures the new exclusion syntax is accepted, which is required
to ignore the Protobuf-generated files which have numerous lint warnings.
2018-02-24 09:52:30 -08:00
joeduffy 4de49a8600 Create symlink for Travis on Mac
Pip is called `pip2.7` in Travis' Mac image.  Our script already
had to deal with this, but did so by conditionalizing the name we
use in our scripts.  Rather than doing that, let's create a symlink
with the name `pip` so that everything can just use the good name.
2018-02-24 09:52:20 -08:00
joeduffy 153344354c Pip install to user homedir
This change passes --user to pip install, so that it installs packages
underneath the home directory.  This is required because, except for the
"python" image in Travis, all Python and Pip-related directories are
root-owned.  The --user approach avoids needing to sudo all over the place.
2018-02-24 09:21:16 -08:00
joeduffy a045e2fb1e Implement more of the Python runtime
This change includes a lot more functionality.  Enough to actually
run the webserver-py example through previews, updates, and destroys!

* Actually wire up the gRPC connections to the engine/monitor.

* Move the Node.js and Python generated Protobuf/gRPC files underneath
  the actual SDK directories to simplify this generally.  No more
  copying during `make` and, in fact, this was required to give a smoother
  experience with good packages/modules for the Python's SDK development.

* Build the Python egg during `make build`.

* Add support for program stacks.  Just like with the Node.js runtime,
  we will auto-parent any resources without explicit parents to a single
  top-level resource component.

* Add support for component resource output properties.

* Add get_project() and get_stack() functions for retrieving the current
  project and stack names.

* Properly use UNKNOWN sentinels.

* Add a set_outputs() function on Resource.  This is defined by the
  code-generator and allows custom logic for output property setting.
  This is cleaner than the way we do this in Node.js, and gives us a
  way to ensure that output properties are "real" properties, complete
  with member documentation.  This also gives us a hook to perform
  name demangling, which the code-generator typically controls anyway.

* Add package dependencies to setuptools.py and requirements.txt.
2018-02-24 08:58:34 -08:00
Joe Duffy fa2377dc61
Fix spinner erasure (#979)
The spinner code used \b, but didn't overwrite with spaces, so part
of the message could get left behind when other writes to stdout/err
occurred.  This change simply overwrites characters with spaces.
2018-02-23 19:36:44 -08:00
joeduffy 74563afdc8 Get the empty Python program working
This change gets enough of the Python SDK up and running that the
empty Python program will work.  Mostly just scaffolding, but the
basic structure is now in place.  The primary remaining work is to
wire up resource creation to the gRPC interfaces.

In summary:

* The basic structure is as follows:

    - Everything goes into sdk/python/.

    - sdk/python/cmd/pulumi-langhost-python is a Go language host
      that simply knows how to spawn Python processes to run out
      entrypoint in response to requests by the engine.

    - sdk/python/cmd/pulumi-langhost-python-exec is a little Python
      shim that is invoked by the language host to run Python programs,
      and is responsible for setting up the minimal goo before we can
      do so (RPC connections and the like).

    - sdk/python/lib/ contains a Python Pip package suitable for PyPi.

    - In there, we have two packages: the root pulumi package that
      contains all of the basic Pulumi programming model abstractions,
      and pulumi.runtime, which contains the implementation of
      resource registration, RPC interfacing with the engine, and so on.

* Add logic in our test framework to conditionalize on the language
  type and react accordingly.  This will allow us to skip Yarn for
  Python projects and eventually run Pip if there's a requirements.txt.

* Created the basic project structure, including all of the usual
  Make targets for installing into the proper places.

* Building also runs Pylint and we are clean.

There are a few other minor things in here:

* Add an "empty" test for both Node.js and Python.  These pass.

* Fix an existing bug in plugin shutdown logic.  At some point, we
  started waiting for stderr/stdout to flush before shutting down
  the plugin; but if certain failures happen "early" during the
  plugin launch process, these channels will never get initialized
  and so waiting for them deadlocks.

* Recently we seem to have added logic to delete test temp
  directories  if a failure happened during initialization of said
  temp directories.  This is unfortunate, because you often need to
  look at the temp directory to see what failed.  We already clean
  them up elsewhere after the full test completes successfully, so
  I don't think we need to be doing this, and I've removed it.

Still many loose ends (config, resources, etc), but it's a start!
2018-02-23 19:33:02 -08:00
joeduffy d9a143c8a1 Implement the Python langhost RPC server
This change adds a basic Python langhost RPC server.  It's fairly
barebones and merely acts as a jumping off point for the Pulumi engine
to spawn a Python program.  The host is written in Go, in contrast to
implementing the host in Python, and more closely resembles how I
expect the Node.js language host to work once pulumi/pulumi#331 is done.
2018-02-23 19:33:02 -08:00
Sean Gillespie 9757d069ed
Merge pull request #972 from pulumi/swgillespie/dependency-view
Save resource dependency information in the checkpoint file
2018-02-23 11:19:38 -08:00
Sean Gillespie 99da1f5350
Spruce up the stack graph command:
1. Output different-colored edges for parent-child resource
    relationships
    2. Allow the changing of edge colors via command-line parameters
    3. Allow the skipping of the parent-child graph or the
    dependency graph when calculating all edges

This modifies the Graph interface slightly to allow an edge to specify
what color should be used when drawing it.
2018-02-22 17:31:45 -08:00
Sean Gillespie 30826a34f5
Code review feedback: rework graph construction to be done eagerly and efficiently, gate under PULUMI_DEBUG_COMMANDS 2018-02-22 15:52:06 -08:00
Joe Duffy 01859a70ed
Update README.md to use a valid CLI command 2018-02-22 14:26:04 -08:00
Sean Gillespie b84320b45e
Code review feedback:
1. Various idiomatic Go and TypeScript fixes
    2. Add an integration test that end-to-end roundtrips dependency
    information for a simple Pulumi program
    3. Add an additional test assert that tests that dependency information
    comes from the language host as expected
2018-02-22 13:33:50 -08:00