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

Bring dbus up when we can #1067

Merged
merged 1 commit into from Aug 1, 2018

Conversation

tasleson
Copy link
Contributor

We want stratisd to come up before filesystems get mounted, so
that a user can use Stratis backed filesystems in fstab. However,
dbus is not available at this time and we need to be able to start
and run without dbus. When this happens we will periodically
check to see if we can bring up the dbus API.

Fixes: #846

@tasleson tasleson added this to To do in Stratis 1.0 (Sprint 9) via automation Jul 24, 2018
@tasleson tasleson self-assigned this Jul 24, 2018
@tasleson tasleson moved this from To do to In Review in Stratis 1.0 (Sprint 9) Jul 24, 2018
),
dbus::Error,
> {
pub fn connect<'a>(engine: Rc<RefCell<Engine>>) -> Result<DbusConnectionData<'a>, dbus::Error> {
Copy link
Member

Choose a reason for hiding this comment

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

Since this change removes the type complexity, it ought to be able to remove the allow(type_complexity) directive as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed, will update

}

#[cfg(feature = "dbus_enabled")]
let poll_timeout = timeout(dbus_handle.is_none(), eventable.is_none());
Copy link
Member

Choose a reason for hiding this comment

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

I'm guessing that all the arguments to timeout above and below have the wrong values, except for the literal false. Assuming false is a correct argument, then it makes sense for the first argument to evaluate to false if D-Bus is not enabled. So, in the call to timeout above, it makes more sense for the first argument to be dbus_handle.is_some(), which will evaluate to true if stratisd has a D-Bus connection, but false otherwise. I think that a similar argument holds for the second argument.

Copy link
Contributor Author

@tasleson tasleson Jul 26, 2018

Choose a reason for hiding this comment

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

The arguments are correct and the function is doing the correct thing based on them. However, I can see the confusion. The timeout function simply selects the returned value in a prioritized order of shorter poll when dbus is compiled in but not available vs. an engine that isn't eventable. When dbus_handle.is_none() is true dbus is not available, thus we want to the time out to be shorter, 1 second. When dbus_handle.is_none() is false, then we evaluate if engine is eventable. If eventable.is_none() is true then the engine isn't eventable and we want the timeout to be 10 seconds. However, I need to ask @agrover why this was selected as the comments indicate that when we aren't eventable that the call to the engine is a no-op. Lastly when both dbus and eventable are both false we return -1 which is to wait forever on socket activity.

Obviously I need to re-work this to make it less confusing, so I'll see what I can do. Passing in the reverse and negating the comparisons in timeout may be better.

@@ -157,6 +157,18 @@ fn trylock_pid_file() -> StratisResult<File> {
}
}

/// Return desired timeout based on if dbus timeout should be selected, non-eventable timeout
/// selected or default selected
Copy link
Member

Choose a reason for hiding this comment

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

I believe that this function should be better documented, to explain the meaning of the arguments and also the reason behind the choices of the return values. This will help understand if it is called correctly and also inform any subequent revisions of the values that may become necessary.

Copy link
Contributor Author

@tasleson tasleson Jul 26, 2018

Choose a reason for hiding this comment

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

With Andy's comment at the meeting, I think we can make this much simpler in that we don't require a separate timeout for eventable.

@tasleson
Copy link
Contributor Author

tasleson commented Jul 26, 2018

Reduced poll timeout calculation complexity and removed type complexity allow.

Also rebased.

Copy link
Member

@mulkieran mulkieran left a comment

Choose a reason for hiding this comment

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

The source looks fine to me.

However, it would be tidier if you started a new PR with all commits squashed into one, or with two commits, one for the refactoring change which changed the return type of connect, and one for all the rest of the changes.

@tasleson
Copy link
Contributor Author

However, it would be tidier if you started a new PR with all commits squashed into one, or with two commits, one for the refactoring change which changed the return type of connect, and one for all the rest of the changes.
Merge state

Agreed, I can certainly squash. I've been leaving things as separate commits to allow easier review of subsequent changes. However, with the auto merge thing, I guess that's not really appropriate.

@tasleson
Copy link
Contributor Author

Squashed

mulkieran
mulkieran previously approved these changes Jul 26, 2018
Copy link
Member

@mulkieran mulkieran left a comment

Choose a reason for hiding this comment

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

I'm fine w/ this PR as it is.

But to be clear, I had requested that this PR be closed, and a new PR, with changes squashed, be put up for review, not that the commits in this PR just be squashed.

@tasleson
Copy link
Contributor Author

But to be clear, I had requested that this PR be closed, and a new PR, with changes squashed, be put up for review, not that the commits in this PR just be squashed.
Merge state

I posed this question on IRC and @agrover really said there isn't a defacto process to follow. What in your opinion is the advantage of creating a new PR which is squashed vs. squashing the existing PR?

@mulkieran
Copy link
Member

For PRs that are being changed due to review, and are fairly complex, it makes sense just to add change commits to the end of the PR. I can explain the reasoning behind this more fully if necessary.

For PRs that are actually committed to the repo, it makes sense to separate the PR into distinct and coherent individual commits, as far as is possible and within limits of difficulty of the task. I can expand on this more fully if necessary.

It makes sense to make these two PRs separate because:

  1. The first type of PR provides a handy record of the reasoning behind decisions made which can be lost or confused by a force push.
  2. It provides the person who submitted the PR with an opportunity to reassess their PR in light of the changes that they have been asked to make before making the final copy.
  3. It is a courtesy to a hypothetical second reviewer who may still have had their reservations about the PR, even if the first reviewer said that in their opinion it was good to go.

We want stratisd to come up before filesystems get mounted, so
that a user can use Stratis backed filesystems in fstab.  However,
dbus is not available at this time and we need to be able to start
and run without dbus.  When this happens we will periodically
check to see if we can bring up the dbus API.

Signed-off-by: Tony Asleson <tasleson@redhat.com>
@tasleson
Copy link
Contributor Author

Re-based to correct merge conflict induced by merge of 9b720f9

@mergify mergify bot merged commit 0a81f4f into stratis-storage:master Aug 1, 2018
Stratis 1.0 (Sprint 9) automation moved this from In Review to Done (Current Sprint) Aug 1, 2018
@agrover agrover moved this from Done (Current Sprint) to Done (Previous Sprints) in Stratis 1.0 (Sprint 9) Aug 2, 2018
@mulkieran
Copy link
Member

mulkieran commented Aug 14, 2018

It is not clear to me why stratis-cli tests managed to succeed with this change, as they failed on my machine with this change. NOTE: I can not reliably reproduce the problem on my own machine, so at this time I am giving up.

@tasleson tasleson deleted the dbus_delayed_bringup branch September 7, 2018 13:26
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

3 participants