-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat(storage): extend application schema for storage flag #492
feat(storage): extend application schema for storage flag #492
Conversation
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.
Is it possible to do CRUD operations on all the storage parameters? If not would we have to use a data source instead?
}, | ||
"size": schema.StringAttribute{ | ||
Description: "The size of each volume. E.g. 100G", | ||
Required: true, |
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.
From reading the storage constraints docs, it seems to me that size is not required. From what I can tell you can choose to leave out any of size, pool and count.
I guess it would technically be fine if the user left out all three, it should just have no effect.
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.
Hm, and where we said that this is optional...
Knowing that we do not support dynamic size volumes, I wonder how the "size" could be optional.
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.
Find the default that juju uses and make that the default. Then the attribute can be optional.
Default: stringdefault.StaticString("str"),
I'm not sure if setting a default in the schema is possible or not. Charm metadata can optionally define a MinimumSize for storage:
// There is no default MinimumSize; if left unspecified, a provider
// specific default will be used, typically 1GB for block storage.
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.
Here is the doc I was looking at https://juju.is/docs/juju/storage-constraint
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.
Couple of comments and a suggestion:
- I'm not sure if I understand what
label
is for, and why it is required? also the name "label" might get confused with the label for block devices in the context of storages. - why is the
size
required? - it might be a good idea to have some validation in the schema with a
ValidateConfig
(example here) against small stuff (like size being positive, or count defaults to 1 if size is specified, etc) (format here).
Also it would great if you can provide an example resource_application
in the PR description that includes the use of this storage SetNestedAttribute so it would be clear what it'll look like.
Here we mimic under
where
In Juju, we have a policy that "storage constraints require at least one field to be specified." However, this is difficult to provide in the declarative nature of TF. So, as a solution to be more strict about size.
thx I'll have a look
I'll add example in the description. |
aa0ccbd
to
12f3b91
Compare
}, | ||
"size": schema.StringAttribute{ | ||
Description: "The size of each volume. E.g. 100G", | ||
Required: true, |
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.
Find the default that juju uses and make that the default. Then the attribute can be optional.
Default: stringdefault.StaticString("str"),
I'm not sure if setting a default in the schema is possible or not. Charm metadata can optionally define a MinimumSize for storage:
// There is no default MinimumSize; if left unspecified, a provider
// specific default will be used, typically 1GB for block storage.
PlanModifiers: []planmodifier.Object{ | ||
objectplanmodifier.RequiresReplaceIfConfigured(), | ||
objectplanmodifier.UseStateForUnknown(), | ||
}, |
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.
On reflection, we may want to make these plan modifiers on each attribute, rather than on the object themselves. I need to understand the difference better.
Our goal is to mimic the behavior of juju deploy --storage
and juju refresh --storage
.
Scenarios to consider
- A new application resource with storage is created -> the application is deployed with storage.
- Storage attribute is added to an existing application resource without a new charm revision to refresh to. -> We should fail ?? Or recreate the application?
- Storage attribute is added to an existing application resource WITH a new charm revision to refresh to. -> Refresh the charm and add the storage.
- An existing storage attribute is removed from the plan -> recreate the application without the storage.
A resource or data source for storage is beyond the scope of the current storage project. The goal is to provide the functionality of We need to enhance the documentation to be clear on this point. |
283c239
to
7ba2ac6
Compare
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.
Approved once the two items have been addressed.
…urce This commit extends the application schema to support the storage flag in the Terraform provider for Juju. The schema now includes varios attributes for configuring the storage constraints of a Juju application.
7ba2ac6
to
5ab3f0e
Compare
Description
This PR introduces significant enhancements to our Terraform provider for Juju. The main changes include extending of the application schema to support the storage flag in the Terraform provider for Juju.
The schema now includes various attributes for configuring the storage constraints of a Juju application.
Fixes:
Type of change
Environment
Juju controller version: -
Terraform version: -
Plan example