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

after write multipath.conf, reconfigure or reload is not working. #2

Open
HHHSong opened this issue Oct 18, 2019 · 3 comments
Open

Comments

@HHHSong
Copy link

HHHSong commented Oct 18, 2019

Hi:
I used function write_to_multipathd_conf() to update the multipath.conf. and then use 'multipathd -k'reconfigure'' or 'multipathd -k'reload'' update the multipathd, but the multipath.conf is not immediately working.
so I sleep 2s after write_to_multipatd_config() , the multipath.conf is working . is this a problem?

I think
def write_to_multipathd_conf(self, value, filepath=DEFAULT_CONF_FILE): """ save configuration to multipathd.conf file in order for the configuration to take affect, call reload() """ from ..config import Configuration assert isinstance(value, Configuration) with open(filepath, 'w') as fd: fd.write(value.to_multipathd_conf())

  After write, only write the data to the kernel buffer, but not to the disk.  so  we need  flush the kernel buffer to the disk .  used  fd.flush()  after write,  is that ok?
@wiggin15
Copy link
Contributor

Since we're using "with open ..." in write_to_multipathd_conf, the file is closed after writing so it should already be flushed there. I don't think adding another "flush" will have any effect. I'm not aware of a problem where the configuration doesn't take effect fast enough that "sleep" should fix. Maybe something else can explain what you're experiencing?

@HHHSong
Copy link
Author

HHHSong commented Oct 25, 2019

Sorry, I was wrong , the function write_to_multipathd_conf() is no problem, it can write to multipath.conf immediately, the problem is used ' multipathd reconfigure ' is not working , It seems that 'multipathd reconfigure' need time to take affect. I used function rescan() can use to reload, is that right?

@wiggin15
Copy link
Contributor

Hi @HHHSong . From what we remember, the refresh could be asynchronous and take time to take effect - it might depends on the operating system and version of multipath-tools. We don't remember for sure.

What we do when we want to detect specific changes in the storage stack, is use infi.storagemodel to do a full rescan of the stack, and write a "predicate" that makes sure the changes are applied. The predicate is a class that you can write to detect the changes you expect (e.g. a new multipath device appears). The rescan function will retry the rescan until the predicate returns True, or until a certain timeout expires.
See function rescan_and_wait_for: https://github.com/Infinidat/infi.storagemodel/blob/develop/src/infi/storagemodel/base/__init__.py#L83
and examples of predicates:
https://github.com/Infinidat/infi.storagemodel/blob/develop/src/infi/storagemodel/predicates/__init__.py

I hope this helps.

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

No branches or pull requests

2 participants