New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a resource for GCE routes #993
Conversation
nixops/resources/gce_route.py
Outdated
self.copy_credentials(defn) | ||
|
||
if check: | ||
if self._check(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doesn't seem like self._check() ever returns True right ?
Fix an issue with real_state_differ check, GCP API adds the region and the project name to the network so we need to remove those before checking if the network in the state match.
…tHop Example: ``` {}:{ machine = { config, pkgs, resources, lib, ... }: let in { deployment.targetEnv = "gce"; .... }; ec2machine = {resources, lib, ...}: { deployment.targetEnv = "ec2"; ... }; resources.gceRoutes.lb-default = {resources, ...}:{ destination = resources.machines.ec2machine; priority = 800; nextHop = resources.machines.machine ; tags = [ "workers" ] ; }; } ``` Be aware that nextHop can only be a GCE machine, if not an exception will be raised
raise Exception("nextHop can only be a GCE machine.") | ||
raise | ||
except libcloud.common.google.ResourceNotFoundError: | ||
raise Exception("The machine {0} isn't deployed, it need to be before it's added as nextHop".format(nextHop_name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use create_after method instead ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added create_after, but I'm keeping this in case we use --include the flag to only deploy the route. In that case the deployment the above exception will be raised.
nix/gce-routes.nix
Outdated
}; | ||
|
||
destination = mkOption { | ||
example ="1.1.1.1/32"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: add space afer =
nix/gce-routes.nix
Outdated
example ="1.1.1.1/32"; | ||
type = types.nullOr (types.either types.str (resource "machine")); | ||
apply = x: if x == null || (builtins.isString x) then x else "res-" + x._name; | ||
description = "The destination IP range that this route applies to. If the destination IP of a packet falls in this range, it matches this route."; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick: can you use '' '' for long descriptions instead
description = ''
foo
''
If nextHop or destination is a machine, wait for them to be deployed before creating the route.
An example of a route is