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

Use DeployFromRepository when possible. #409

Merged
merged 3 commits into from Feb 23, 2024

Conversation

hmlanigan
Copy link
Member

Description

If the controller has implemented the Application facade of version 19 or higher, use DeployFromRepository method to deploy a charm. This method shortcuts most of the deploy business logic in the client and allows the controller to handle it all.

To handle shared input manipulation between the 2 methods, created a new input struct with a parse() method.

Type of change

  • Logic changes in resources (the API interaction with Juju has been changed)

Environment

  • Juju controller version: 2.9.47, 3.3.1

  • Terraform version: any

QA steps

Run the following plan against a 2.9.47 controller and against a 3.3.1 controller with debug enabled, export TF_LOG_PROVIDER=TRACE ; export TF_LOG_PATH=./terraform.log.

Against 2.9.47, you should find the debug line "Calling Deploy". Against 3.3.1, you should find the debug line "Calling DeployFromRepository".

terraform {
  required_providers {
    juju = {
      version = ">= 0.11.0"
      source  = "juju/juju"
    }
  }
}

provider "juju" {
}

resource "juju_model" "one" {
  name = "unit-test"
}

resource "juju_application" "app-a" {
  model = juju_model.one.name
  charm {
    name = "juju-qa-test"
  }
}

resource "juju_application" "app-b" {
  model = juju_model.one.name
  charm {
    name = "jameinel-ubuntu-lite"
  }
}

Also run

Additional notes

JUJU-5429

@hmlanigan hmlanigan requested review from cderici and removed request for cderici February 20, 2024 23:11
@anvial
Copy link
Member

anvial commented Feb 23, 2024

@hmlanigan, I successfully passed QA on 2.9.47,

But on 3.3.1 I faced the following error:

juju_model.one: Creating...
╷
│ Error: Client Error
│
│   with juju_model.one,
│   on plan.tf line 13, in resource "juju_model" "one":
│   13: resource "juju_model" "one" {
│
│ Unable to create model, got error: interface conversion: interface {} is nil, not string
╵

@anvial
Copy link
Member

anvial commented Feb 23, 2024

DeployFromRepository

It sorted out that was my problem of "not removing the previous version of the plugin".

Copy link
Member

@anvial anvial left a comment

Choose a reason for hiding this comment

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

QA passed, I'm ok with code

internal/juju/applications.go Show resolved Hide resolved
If the controller has implemented the Application facade of version 19
or higher, use DeployFromRepository method to deploy a charm. This
method shortcuts most of the deploy business logic in the client and
allows the controller to handle it all.
Juju 2.9 and 3.1 still require series in the url to work properly.
Import for future efforts to know when this can happen.
@hmlanigan
Copy link
Member Author

2.9 tests have expected failure of "Unable to create model, got error: juju client with version 3.3 used with a
controller having major version 2 not supported"

@hmlanigan hmlanigan merged commit 0e61a6b into juju:main Feb 23, 2024
16 of 23 checks passed
@hmlanigan hmlanigan deleted the use-deploy-from-repository branch February 23, 2024 19:23
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.

None yet

2 participants