-
Notifications
You must be signed in to change notification settings - Fork 9.6k
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
Migrate Manta Remote state to be a backend #16296
Conversation
0c4b12b
to
748931c
Compare
backend/init/init.go
Outdated
@@ -47,6 +48,7 @@ func init() { | |||
`Warning: "azure" name is deprecated, please use "azurerm"`), | |||
"azurerm": func() backend.Backend { return backendAzure.New() }, | |||
"etcdv3": func() backend.Backend { return backendetcdv3.New() }, | |||
"manta": func() backend.Backend { return backendManta.New() }, |
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.
For historical reasons this was called Manta but arguably that's an internal name for the project now. From the product side of things its Triton Object Storage (hence the reason github.com/joyent/triton-go/storage
). I'm wondering if we should rename this to Triton and deprecate the Manta brand from TF completely.
Thoughts?
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.
Just to make it known, @cheapRoc and I discussed this internally and decided to leave it as manta :)
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.
Just in case it wasn't clear, the deprecateBackend
function used just above here in the azure
backend can be used to simply deprecate the old name if you want, but I'll leave the final decision up to you.
b5868ec
to
8bc8fd8
Compare
8bc8fd8
to
2c68eac
Compare
@jbardin would love your thoughts on this please? |
Thanks @stack72, I'll take a look at it ASAP. I'd like to get this and the gcs backend conversion both in before the next beta. |
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.
Thanks for putting the work in to update this remote state!
I have some comments inline. The backends works like the old providers, where we have to run the ACC tests manually.
backend/init/init.go
Outdated
@@ -47,6 +48,7 @@ func init() { | |||
`Warning: "azure" name is deprecated, please use "azurerm"`), | |||
"azurerm": func() backend.Backend { return backendAzure.New() }, | |||
"etcdv3": func() backend.Backend { return backendetcdv3.New() }, | |||
"manta": func() backend.Backend { return backendManta.New() }, |
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.
Just in case it wasn't clear, the deprecateBackend
function used just above here in the azure
backend can be used to simply deprecate the old name if you want, but I'll leave the final decision up to you.
) | ||
|
||
func (b *Backend) States() ([]string, error) { | ||
prefix := b.objectName + keyEnvPrefix |
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.
This looks like a breaking change for the backend if you're expecting this to upgrade from the legacy remote state, since you're adding keyEnvPrefix
to all named states. I think the original remote state would be at objectName
by itself, correct?
You should use a workspace-specific suffix like this for the objectName only when it's not the DefaultStateName
(there's a number of ways to structure it). Just for context, the keyEnvPrefix
as a directory as used in S3 was a mistake copied form the consul directory layout, but we're stuck with it.
For backends that don't need to upgrade from existing remote state, it seems to make more sense to only configure a "path", and have that be a directory containing the state files each of which are named after the respective workspace.
const ( | ||
// This will be used as directory name, the odd looking colon is simply to | ||
// reduce the chance of name conflicts with existing objects. | ||
keyEnvPrefix = "env:" |
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.
I think you want to update the comment here, and maybe the variable name, since your usage is a little different the S3.
} | ||
|
||
func (b *Backend) State(name string) (state.State, error) { | ||
|
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, and in DeleteState, it doesn't look like you're building the objectName with the workspace/state name.
backend/remote-state/manta/client.go
Outdated
} | ||
|
||
func (c *RemoteClient) Lock(info *state.LockInfo) (string, error) { | ||
info.Path = path.Join(c.directoryName, lockFileName) |
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.
Locks need to be per named state, so you need the final objectName in here somewhere too. I thought the tests covered conflicting lock paths, but I'll have to update them if they don't
contentType := "application/json" | ||
contentLength := int64(len(data)) | ||
|
||
params := &storage.PutObjectInput{ |
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.
I'm not familiar with manta at all. I assume manta is strongly consistent, so we can actually use this as a lock. Does the api prevent writing to an existing key though, or would this simply replace an existing lock? (the tests should cover this, but have the acc tests been run on this yet?)
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.
Manta is a strongly consistent backend so this is correct.
2c68eac
to
e2001b8
Compare
@jbardin so I took the liberty to remove anything to do with I am working on the tests right now |
e2001b8
to
9b18e93
Compare
@jbardin finally done :)
|
This PR changes manta from being a legacy remote state client to a new backend type. This also includes creating a simple lock within manta This PR also unifies the way the triton client is configured (the schema) and also uses the same env vars to set the backend up It is important to note that if the remote state path does not exist, then the backend will create that path. This means the user doesn't need to fall into a chicken and egg situation of creating the directory in advance before interacting with it
9b18e93
to
1fd0f80
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.
Thanks @stack72, this looks good!
The tests pass, so I'll work on getting this into the upcoming beta.
Thanks for the merge here @jbardin - glad this will be part of 0.11 GA :) |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
This is a WIP to show the progress of this work