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
storageprovisioner: fix watching of volume-backed filesystems #7346
storageprovisioner: fix watching of volume-backed filesystems #7346
Conversation
08910cb
to
2a710d3
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.
I think this seems ok, but I might be misunderstanding the semantics of the machineFilesystemsWatcher as I don't get why all 3 contained watchers need to fire before an event is omitted.
// The tests all operate on machine "0", and the watchers | ||
// should ignore attachments for other machines, so we should | ||
// never get here. | ||
panic("should not get here") |
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.
Instead of panicing, why not return an error and let the caller's c.Assert(err, jc.ErrorIsNil) fail the test. IMO since the panic would result from a logic error ("code should do such and such"), any such violation is a test failure.
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.
Done.
@@ -0,0 +1,453 @@ | |||
package filesystemwatcher |
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.
header
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.
fixed
// results from machine- and model-scoped watchers, to conform to the behaviour | ||
// of the storageprovisioner worker. The model-level storageprovisioner watches | ||
// model-scoped filesystems that have no backing volume. The machine-level worker | ||
// watches both machine-scoped filesytems, and model-scoped filesystems attached |
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.
"that have no backing volume" also?
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 added "whose backing volumes are" between "filesystems" and "attached"
// WatchModelFilesystems returns a strings watcher that reports model-scoped | ||
// filesystems that have no backing volume. Volume-backed filesystems are | ||
// always managed by the machine to which they are attached. | ||
func (fw Watchers) WatchModelFilesystems() state.StringsWatcher { |
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.
might be verbose, but could it be WatchOrphanedModelFilesystems() or WatchUnbackedModelFileSystems() or something? the method name doesn't imply that there's a condition on which model filesystems are watched
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'll change it to "ModelManaged" and "MachineManaged", to make it clear that we're interested in machines that are managed by the model-level or machine-level storage provisioner.
w.changes = make(set.Strings) | ||
out = nil | ||
} | ||
if machineFilesystemsReceived && |
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 that right? All 3 underlying watchers have to fire before we send any events?
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.
Yes. The way all watchers work is to first give the initial state of the world in a single event, and then later changes can report on individual aspects. If we were to report the machine-scoped filesystems without also reporting the model-scoped ones, then the worker would think that the model-scoped ones were not part of the model any more.
state/watcher/watchertest/strings.go
Outdated
C chan []string | ||
} | ||
|
||
func NewStringsWatcher(ch chan []string) *StringsWatcher { |
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.
should comment here and above
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.
done
1dcc94d
to
6e6d9a0
Compare
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
Build failed: Tests failed |
We previously handled Dying storage attachments by destroying and then removing them. The watcher will still observe the lifecycle state going from Dying to Dead, so we defer the removal until the Dead state is observed.
6e6d9a0
to
d828986
Compare
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
Build failed: Tests failed |
|
Status: merge request accepted. Url: http://juju-ci.vapour.ws:8080/job/github-merge-juju |
Description of change
A recent change was made to the state package's filesystem and filesystem attachment watchers. The change was to filter the results based on the state of volume attachments. This doesn't work without also watching the volume attachment collection for changes, so that change has been reverted.
In its place, we introduce composite watchers in the apiserver/storageprovisioner/internal/filesystemwatcher package. These watchers compose watchers for model and machine filesystems, and volume attachments, to produce answers that the storage provisioner worker expects.
There are some incidental bug fixes, found while verifying this change:
QA steps
$ juju bootstrap google
$ juju deploy postgresql --storage pgdata=gce,10G
(wait)
$ juju detach-storage pgdata/0
(wait)
$ juju attach-storage postgresql/0 pgdata/0
(storage should show up as attached)
Documentation changes
None.
Bug reference
None.