Add Pod Log viewer - #10201
Conversation
This reverts commit e16bf24.
83f168f to
ef7bc22
Compare
| container_group = ContainerGroup.find(params.expect(:id)) | ||
| container_name = params[:container] | ||
|
|
||
| render :json => {:logs => container_group.logs(container_name)} |
There was a problem hiding this comment.
I wonder if this makes more sense over the API instead?
Then you also wouldn't have a split between logs and logs_page...instead you'd have container_groups/1/logs for UI and /api/container_groups/1/logs for API
There was a problem hiding this comment.
@Fryguy, Just to make sure I build the right thing — should this stay as a POST resource action (reusing the existing logs_resource/check_compliance-style pattern), or would you prefer a proper GET subcollection (GET /api/container_groups/:id/logs?container=...)? The latter needs a different mechanism (subcollection route + handler vs. the resource-action config), so want to confirm before I build it out.
There was a problem hiding this comment.
I was thinking get on a subcollection. @agrare Thoughts?
There was a problem hiding this comment.
are you expecting something like this?
GET /api/container_groups/:id/logs?container=my-container
instead of a resource action?
ef7bc22 to
6445598
Compare
|
Checked commits ishaaq-48/manageiq-ui-classic@21c46fe~...6445598 with ruby 3.3.10, rubocop 1.86.0, haml-lint 0.73.0, and yamllint 1.37.1 app/views/container_group/logs.html.haml
|
|
@Fryguy I have updated the code kindly check it out |
| action: 'logs', | ||
| container: selectedContainer, | ||
| }), | ||
| }) |
There was a problem hiding this comment.
Instead of fetch to call the /api, you can use the helper API.post.
API.post('api/container_groups/${podId}'), { payload.... }
| @@ -0,0 +1,77 @@ | |||
| import React, { useState } from 'react'; | |||
There was a problem hiding this comment.
We can remove import React from 'react'
| </select> | ||
|
|
||
| <button onClick={ fetchLogs } disabled={ !selectedContainer } style={ { marginLeft: '10px' } }> | ||
| View Logs |
There was a problem hiding this comment.
Missing translation. Wrap with __()
| View Logs | ||
| </button> | ||
|
|
||
| { loading && <p>Loading...</p> } |
|
|
||
| return ( | ||
| <div> | ||
| <h3>{ `Logs for ${podName}` }</h3> |
| <select | ||
| value={ selectedContainer } | ||
| onChange={ (e) => setSelectedContainer(e.target.value) } | ||
| > | ||
| { containers.map((name) => ( | ||
| <option key={ name } value={ name }>{ name }</option> | ||
| )) } | ||
| </select> | ||
|
|
||
| <button onClick={ fetchLogs } disabled={ !selectedContainer } style={ { marginLeft: '10px' } }> |
There was a problem hiding this comment.
Please use Carbon components instead of native HTML elements. The project uses @carbon/react throughout. You could use <SelectItem>, <Button>
| </button> | ||
|
|
||
| { loading && <p>Loading...</p> } | ||
| { error && <p style={ { color: 'red' } }>{ error }</p> } |
There was a problem hiding this comment.
See if you could use <InlineNotification> instead
| View Logs | ||
| </button> | ||
|
|
||
| { loading && <p>Loading...</p> } |
There was a problem hiding this comment.
Use <Loading> from '@carbon/react'
| ); | ||
| }; | ||
|
|
||
| export default ContainerGroupLogs; No newline at end of file |
There was a problem hiding this comment.
nit - No new line at the eof
|
This pull request is not mergeable. Please rebase and repush. |
Purpose
Provide a UI to view Kubernetes/OpenShift pod logs for running pod.
Changes
Testing
Select the container for which the pod log should be shown and click View Logs.
Depends On: