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
Fixes #23699 - Remediation Support for Host Status #6135
Conversation
app/helpers/hosts_helper.rb
Outdated
N_("Unknown status") | ||
end | ||
end | ||
|
There was a problem hiding this comment.
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.
Issues: #23699 |
322d862
to
682789d
Compare
There was a problem hiding this 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.
682789d
to
57617ff
Compare
Hello, @ares Updated the changes. |
There was a problem hiding this 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" |
There was a problem hiding this comment.
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.
57617ff
to
1bc8c0e
Compare
N_("Check audit log") | ||
when "Unknown build status" | ||
N_("Unknown status") | ||
else |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
1bc8c0e
to
e21a6e9
Compare
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. |
e21a6e9
to
c118de8
Compare
There was a problem hiding this 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.
c118de8
to
c8004ee
Compare
@@ -64,7 +64,7 @@ def token_expired? | |||
def build_errors? | |||
host && host.build_errors.present? | |||
end | |||
end | |||
end |
There was a problem hiding this comment.
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.
app/helpers/hosts_helper.rb
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
app/helpers/hosts_helper.rb
Outdated
@@ -517,4 +517,19 @@ def power_status_visible? | |||
def host_breadcrumb | |||
breadcrumbs(resource_url: "/api/v2/hosts?thin=true'") | |||
end | |||
|
There was a problem hiding this comment.
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.
7721a66
to
52702f4
Compare
app/helpers/hosts_helper.rb
Outdated
when "Token expired" | ||
N_("Cancel your build and regenerate token by initiating build again") | ||
when "Installed" | ||
N_("Done!") |
There was a problem hiding this comment.
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
app/helpers/hosts_helper.rb
Outdated
when "Installed" | ||
N_("Done!") | ||
when "Installation error" | ||
N_("Check audit log") |
There was a problem hiding this comment.
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)
app/helpers/hosts_helper.rb
Outdated
@@ -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 |
There was a problem hiding this comment.
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.
app/helpers/hosts_helper.rb
Outdated
when "Installation error" | ||
N_("Check audit log") | ||
when "Unknown build status" | ||
N_("Unknown status") |
There was a problem hiding this comment.
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
Few more comments, looks good. |
9c1f4fc
to
b3fed67
Compare
There was a problem hiding this 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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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") |
b3fed67
to
4dff589
Compare
4dff589
to
a8b7b20
Compare
a8b7b20
to
0e8df52
Compare
There was a problem hiding this 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.
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? |
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. |
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?