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

Fixes #23699 - Remediation Support for Host Status #6135

Conversation

akshay-mendhe
Copy link
Member

Hello, I am just confused about what text should we display when the status is "pending installation" or "installation error", as the case may have variety of solutions. Also in case of "Token expired", we can show cancel build and regenerate token again but if same host renders Token expired for many times, then we can tell user to create a new host instead, isn't it?

N_("Unknown status")
end
end

Choose a reason for hiding this comment

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

Layout/EmptyLinesAroundModuleBody: Extra empty line detected at module body end.

@theforeman-bot
Copy link
Member

Issues: #23699

Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

I love the idea. Could it be adfed in a more gemeric way so any host status can define it's help texts? Basically the helper would mostly be moved to HostStatus::Base class.

@akshay-mendhe
Copy link
Member Author

Hello, @ares Updated the changes.

Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

Thanks, I left a comment with more details, this is going the right direction, just needs few more steps.

def self.status_name
N_("Build")
end

def to_label(options = {})
case to_status
when PENDING
@@build_status_help_text["Pending installation"] = "Wait for sometime and if build fails, rebuild again"
Copy link
Member

Choose a reason for hiding this comment

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

How about adding a method to to_label_help that would have the same case, but instead of label would return the full help. Then we wouldn't need @@ var nor the helper method. In the view we'd check if this methods returns nil or string, in case of string, we'd use it as help.

I guess that means changing the current host page a bit more, but I believe, that would be cleaner. Let me know, if you need help or I should explain more.

N_("Check audit log")
when "Unknown build status"
N_("Unknown status")
else

This comment was marked as resolved.

@akshay-mendhe
Copy link
Member Author

Hi, @ares updated the changes, but sorry, I didn't get the point related to checking whether the function returns string or nil. As, in view, we have to show help text on only one row i.e. build status, that is why i am using that if condition in view. can you please explain it more.

Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

Nicely done, couple of comments.

app/models/host_status/build_status.rb Show resolved Hide resolved
@@ -64,7 +64,7 @@ def token_expired?
def build_errors?
host && host.build_errors.present?
end
end
end

Choose a reason for hiding this comment

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

Layout/EndAlignment: end at 67, 3 is not aligned with class at 2, 2.

@@ -517,4 +517,19 @@ def power_status_visible?
def host_breadcrumb
breadcrumbs(resource_url: "/api/v2/hosts?thin=true'")
end

def remediation_help_text
case @host.build_status_label

Choose a reason for hiding this comment

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

Layout/IndentationWidth: Use 2 (not 4) spaces for indentation.

@@ -517,4 +517,19 @@ def power_status_visible?
def host_breadcrumb
breadcrumbs(resource_url: "/api/v2/hosts?thin=true'")
end

Choose a reason for hiding this comment

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

Layout/TrailingWhitespace: Trailing whitespace detected.

@akshay-mendhe akshay-mendhe force-pushed the remediation_support_host_status branch 3 times, most recently from 7721a66 to 52702f4 Compare October 16, 2018 09:27
when "Token expired"
N_("Cancel your build and regenerate token by initiating build again")
when "Installed"
N_("Done!")
Copy link
Member

Choose a reason for hiding this comment

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

Probably: OS installer reported end of installation and rebooted the system

when "Installed"
N_("Done!")
when "Installation error"
N_("Check audit log")
Copy link
Member

Choose a reason for hiding this comment

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

Probably: OS installer post script reported failure, check logs (I don't think this can be found in audit but in normal log)

@@ -517,4 +517,19 @@ def power_status_visible?
def host_breadcrumb
breadcrumbs(resource_url: "/api/v2/hosts?thin=true'")
end

def remediation_help_text
case @host.build_status_label
Copy link
Member

Choose a reason for hiding this comment

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

Please use build_status method instead and compare constants rather than text.

when "Installation error"
N_("Check audit log")
when "Unknown build status"
N_("Unknown status")
Copy link
Member

Choose a reason for hiding this comment

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

Probably: The host was not scheduled for build yet

@lzap
Copy link
Member

lzap commented Oct 16, 2018

Few more comments, looks good.

@akshay-mendhe akshay-mendhe force-pushed the remediation_support_host_status branch 3 times, most recently from 9c1f4fc to b3fed67 Compare October 16, 2018 18:23
Copy link
Member

@lzap lzap left a comment

Choose a reason for hiding this comment

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

Apologies, missed two more strings which might be improved I think.

def remediation_help_text
case host.build_status
when PENDING
N_("Install media and if build fails, rebuild again")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
N_("Install media and if build fails, rebuild again")
N_("Installation haven't started yet or in progress")

when PENDING
N_("Install media and if build fails, rebuild again")
when TOKEN_EXPIRED
N_("Cancel your build and regenerate token by initiating build again")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
N_("Cancel your build and regenerate token by initiating build again")
N_("Build token is no longer valid, cancel build mode and enter it again to generate new")

Copy link
Member

@ares ares left a comment

Choose a reason for hiding this comment

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

Great, this is what I meant. Just one question, will this work in non build statuses? I think the method remediation_help_text is now defined only there. We should implement a default one in Base class, that would return nil or something. So in view layer, we'd only renser this if remediation_help_text returns some value.

@akshay-mendhe
Copy link
Member Author

Hello, @ares and @lzap sorry for the delay, but if we move the method remediation_help_text() to main status file i.e. status.rb then, we will not be able to use build status labels like PENDING, BUILT,etc. or we have to check with strings , build_status_label. Also if I am not wrong, if we try to check whether this method returns string or nil in View, it will always return some or other status as it will always be set, resulting in showing hover text on other things too. Also we cannot pass "Value" from view as parameter to this method, as it is HTML tag and contains other html attributes, so is there any other alternative we can do?

@ares
Copy link
Member

ares commented Oct 22, 2018

The point is, you query the status object itself. The method should live in status.rb returnil nil. Then you override the method in build status that looks at self.to_status. It's the same pattern as with to_label method. Any other substatus can override the method. That way all statuses automatically returns nil (inherited) by default and those that provide more details would return strings. Hence checking for nil in views.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants