Skip to content

Commit

Permalink
fix: bugs 535 and 539 only find storage for application being read
Browse files Browse the repository at this point in the history
Call full status with a filter of the application name when Reading,
this ensures that the returned storage is for the current application
only.

Updated an application acceptance test to ensure storage isn't written
for applications without storage.
  • Loading branch information
hmlanigan committed Aug 28, 2024
1 parent 16dee9a commit 4d59f2d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/juju/applications.go
Original file line number Diff line number Diff line change
Expand Up @@ -901,12 +901,12 @@ func (c applicationsClient) ReadApplication(input *ReadApplicationInput) (*ReadA

appInfo := apps[0].Result

// We are currently retrieving the full status, which might be more information than necessary.
// The main focus is on the application status, particularly including the storage status.
// It might be more efficient to directly query for the application status and its associated storage status.
// TODO: Investigate if there's a way to optimize this by only fetching the required information.
// Fetch data only about the application being read. This helps to limit
// the data on storage to the specific application too. Storage is not
// provided by application, rather storage data buries a unit name deep
// in the structure.
status, err := clientAPIClient.Status(&apiclient.StatusArgs{
Patterns: []string{},
Patterns: []string{input.AppName},
IncludeStorage: true,
})
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions internal/provider/resource_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func TestAcc_ResourceApplication(t *testing.T) {
resource.TestCheckResourceAttr("juju_application.this", "charm.0.name", "jameinel-ubuntu-lite"),
resource.TestCheckResourceAttr("juju_application.this", "trust", "true"),
resource.TestCheckResourceAttr("juju_application.this", "expose.#", "1"),
resource.TestCheckNoResourceAttr("juju_application.this", "storage"),
),
},
{
Expand Down

0 comments on commit 4d59f2d

Please sign in to comment.