josmo/drone-rancher

Support Rancher environments

Closed this issue · 1 comments

Multiple Rancher environments with the same stack name, possibly containing different services but that is not necessary, results in drone-rancher selecting the first matching stack name, from any environment, to act upon. This can cause unexpected service upgrades or failures to find the service depending on what the upgrade targets.

Example Rancher site layout:

Rancher Environment -> Stack -> Services
Cloud - Dev1 -> MyCoolStack -> Service4, Service5
Cloud - Dev2 -> MyCoolStack -> Service6
Cloud - Prod1 -> MyCoolStack -> Service1, Service3
Cloud - Prod2 -> MyCoolStack -> Service1, Service2

Example drone.yml snippet:

- name: rancher-deploy
  image: peloton/drone-rancher
  settings:
    url: https://rancher
    access_key:
      from_secret: rancher_access_key_id
    secret_key:
      from_secret: rancher_secret_access_key
    service: MyCoolStack/Service6
    docker_image: foo/bar:v1.1.3-alpha
    confirm: true
    timeout: 180

Using the above snippet upgrading the service MyCoolStack/Service6 in the environment Cloud - Dev2 will fail with a service not found error because drone-rancher matched the first stack name MyCoolStack in the site Cloud - Dev1. As Service6 doesn't exist in this stack the upgrade fails.

Likewise attempting to upgrade the service MyCoolStack/Service1 in the environment Cloud - Prod2 will actually upgrade the service MyCoolStack/Service1 in the environment Cloud - Prod1 as there is no way to specify the target environment.

Workarounds-

  • Per-environment API keys
  • Unique Stack naming in each environment

Related to issues #30 and #32