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

Make repairs out of select supervisor issues #90893

Merged
merged 4 commits into from
Apr 19, 2023

Conversation

mdegat01
Copy link
Contributor

@mdegat01 mdegat01 commented Apr 6, 2023

Proposed change

As of home-assistant/supervisor#4218 Supervisor is now creating an issue when it detects multiple filesystems with the name hassos-data. Because that creates a race condition at system startup, since OS uses the first filesystem it sees with the name hassos-data as the data disk.

In addition home-assistant/supervisor#3984 added a new "reboot required" supervisor issue created when a user adjusts settings on their board as those require a system reboot to take effect.

Currently these supervisor issues are buried in the CLI. This PR adds support for easily turning supervisor issues into repairs and applying supervisor's suggestions to fix them. It contains a hard-coded list of which issues should be presented as repairs so we can evaluate each on a case-by-case basis. For now only the two described above will be presented as repairs.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Apr 6, 2023

Hey there @home-assistant/supervisor, mind taking a look at this pull request as it has been labeled with an integration (hassio) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of hassio can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign hassio Removes the current integration label and assignees on the pull request, add the integration domain after the command.

@mdegat01 mdegat01 force-pushed the supervisor-issues-to-repairs branch from 06e0014 to 477686f Compare April 6, 2023 02:59
@mdegat01 mdegat01 requested a review from emontnemery April 6, 2023 03:03
@mdegat01 mdegat01 force-pushed the supervisor-issues-to-repairs branch 2 times, most recently from a0aba6e to fd0d18d Compare April 6, 2023 18:50
@mdegat01 mdegat01 force-pushed the supervisor-issues-to-repairs branch from fd0d18d to 08d552b Compare April 14, 2023 17:06
@mdegat01 mdegat01 force-pushed the supervisor-issues-to-repairs branch from 08d552b to 2caabdb Compare April 18, 2023 21:58
@emontnemery emontnemery merged commit a511e7d into dev Apr 19, 2023
@emontnemery emontnemery deleted the supervisor-issues-to-repairs branch April 19, 2023 06:07
return f"{self.context}_{self.type_}"

@staticmethod
def from_dict(data: SuggestionDataType) -> Suggestion:
Copy link
Member

Choose a reason for hiding this comment

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

This method can preferably be a classmethod as it returns an instance of the class.

return f"issue_{self.context}_{self.type_}"

@staticmethod
def from_dict(data: IssueDataType) -> Issue:
Copy link
Member

Choose a reason for hiding this comment

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

Same here.

severity=IssueSeverity.WARNING,
translation_key=issue.key,
translation_placeholders={PLACEHOLDER_KEY_REFERENCE: issue.reference}
if issue.reference
Copy link
Member

Choose a reason for hiding this comment

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

Ternary operator expressions that span more than one line are hard to read.


async def async_step_init(self, _: None = None) -> FlowResult:
"""Handle the first step of a fix flow."""
# Got out of sync with supervisor, issue is resolved or isn't fixable. Either way, resolve the repair
Copy link
Member

Choose a reason for hiding this comment

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

Please break long strings and comments around 88 characters per line.

data = await self._client.get_resolution_info()
self.unhealthy_reasons = set(data[ATTR_UNHEALTHY])
self.unsupported_reasons = set(data[ATTR_UNSUPPORTED])

# Remove any cached issues that weren't returned
for issue_id in set(self._issues.keys()) - {
Copy link
Member

Choose a reason for hiding this comment

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

Copying a dict to a set uses the keys by default. We can remove .keys().

@github-actions github-actions bot locked and limited conversation to collaborators Apr 20, 2023
@frenck frenck added the noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) label Apr 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
cla-signed core has-tests integration: hassio new-feature noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) Quality Scale: internal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants