Skip to content
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

[JUJU-3442] Wait for apps before integrate #189

Conversation

juanmanuel-tirado
Copy link
Contributor

@juanmanuel-tirado juanmanuel-tirado commented Apr 5, 2023

Description

In certain situations the integrate resource can be requested before the applications are available in the Juju side. This app includes an active wait that waits until the two apps are available. For the sake of configurability, the juju_integration resource has been updated with a timeout field indicating the number of seconds to wait before requesting two applications to be integrated. If the applications are not available before the timeout, the integration will not be done.

Fix #188

Type of change

Please mark if proceeds.

  • New resource (a new resource in the schema)
  • Changed resource (changes in an existing resource)
  • Logic changes in resources (the API interaction with Juju has been changed)
  • Test changes (one or several tests have been changed)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Other (describe)

Environment

  • Juju controller version: 2.9.42
  • Terraform version: 1.4.4

QA steps

Reproduce the deployment of a subordinate indicated in #188 This deployment may not fail in every use case. To emulate the benefit of using the timeout, we will force a situation were the timeout is reached, check that the integration is not done, and finally create the integration.

juju bootstrap lxd tftesting --debug
locals {
  charm_name    = "ubuntu"
  charm_channel = "latest/stable"
}

provider "juju" {}

resource "juju_model" "relation_test" {
  name = "relation-test"
}

resource "juju_application" "ubuntu" {
  name  = "ubuntu"
  model = juju_model.relation_test.name

  charm {
    name    = local.charm_name
    channel = local.charm_channel
  }

  config = {}

  units = 1
}


resource "juju_application" "telegraf" {
  name  = "telegraf"
  model = juju_model.relation_test.name

  charm {
    name = "telegraf"
  }

  units = 0
}

resource "juju_integration" "ubuntu_telegraf" {
  model = juju_model.relation_test.name

  application {
    name = "ubuntu"
  }

  application {
    name = "telegraf"
  }
  timeout = 1
}

Now terraform apply should not finished, because 1 second is not probably enough for the integration to be requested. This can be checked with juju status -m relation-test --relations.

Model          Controller  Cloud/Region         Version  SLA          Timestamp
relation-test  test2942    localhost/localhost  2.9.42   unsupported  14:40:17+02:00

App       Version  Status   Scale  Charm     Channel        Rev  Exposed  Message
telegraf           unknown      0  telegraf  latest/stable   66  no       
ubuntu    20.04    active       1  ubuntu    latest/stable   21  no       

Unit       Workload  Agent  Machine  Public address  Ports  Message
ubuntu/0*  active    idle   0        10.220.18.115          

Machine  State    Address        Inst id        Series  AZ  Message
0        started  10.220.18.115  juju-a623bf-0  focal       Running

Next, increase the timeout, apply again, and check that the relation is there

resource "juju_integration" "ubuntu_telegraf" {
  model = juju_model.relation_test.name

  application {
    name = "ubuntu"
  }

  application {
    name = "telegraf"
  }
  timeout = 10
}
And the status should be something like this:
```sh
Model          Controller  Cloud/Region         Version  SLA          Timestamp
relation-test  test2942    localhost/localhost  2.9.42   unsupported  14:42:09+02:00

App       Version  Status       Scale  Charm     Channel        Rev  Exposed  Message
telegraf           maintenance      1  telegraf  latest/stable   66  no       installing charm software
ubuntu    20.04    active           1  ubuntu    latest/stable   21  no       

Unit           Workload     Agent      Machine  Public address  Ports  Message
ubuntu/0*      active       idle       0        10.220.18.115          
  telegraf/1*  maintenance  executing           10.220.18.115          (install) installing charm software

Machine  State    Address        Inst id        Series  AZ  Message
0        started  10.220.18.115  juju-a623bf-0  focal       Running

Relation provider  Requirer            Interface  Type         Message
ubuntu:juju-info   telegraf:juju-info  juju-info  subordinate  

@juanmanuel-tirado juanmanuel-tirado added this to the 0.7.0 milestone Apr 5, 2023
@juanmanuel-tirado juanmanuel-tirado self-assigned this Apr 5, 2023
Copy link

@cderici cderici left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. QA went well. Not a huge fan of active waiting (like the wait_for_idle in pylibjuju), but I don't have a better alternative.

@juanmanuel-tirado
Copy link
Contributor Author

The failing tests are due to a new version of the Ubuntu charm that requires storage. That has to be addressed in another PR. This can be merged.

@juanmanuel-tirado juanmanuel-tirado merged commit 77e9f43 into juju:main Apr 11, 2023
@juanmanuel-tirado juanmanuel-tirado deleted the JUJU-3442_wait_for_apps_before_integrate branch April 11, 2023 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deploying a plan in an empty model with a subordinate fails on ordering
2 participants