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

Fix flaky set_computer_name in mac_system module #54178

Merged
merged 4 commits into from Aug 12, 2019

Conversation

dwoz
Copy link
Contributor

@dwoz dwoz commented Aug 11, 2019

What does this PR do?

Use scutil instead of systemsetup to set and get the computer name on MacOS. systemsetup is from 2002 and is not reliable at setting the computer name.

(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -setcomputername "RS-KFQZY1"
setcomputername: RS-KFQZY1
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -setcomputername "RS-KFQZY1"
setcomputername: RS-KFQZY1
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP
(venv) root@carbon:~/src/salt-forge/2019.2.1-tests/salt# systemsetup -getcomputername
Computer Name: RS-KFQZYP

scutil is from 2008 and scutil --set ComputerName "RS-KFQZY1" works reliably.

Tests written?

No - Has existing test coverage that was failing

Commits signed with GPG?

Yes

Copy link
Contributor

@Ch3LL Ch3LL left a comment

Choose a reason for hiding this comment

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

Great find! I think there are other modules that use systemsetup as well that are flaky. That command is just flaky in general so might be good to switch to a different command if available in those modules too if they keep failing in the future. The other modules are mac_timezone.py and mac_power.py

@dwoz
Copy link
Contributor Author

dwoz commented Aug 12, 2019

Great find! I think there are other modules that use systemsetup as well that are flaky. That command is just flaky in general so might be good to switch to a different command if available in those modules too if they keep failing in the future. The other modules are mac_timezone.py and mac_power.py

I agree.

@dwoz dwoz merged commit 19f4d5e into saltstack:2019.2.1 Aug 12, 2019
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

4 participants