Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

TITUS-2326 Cloned titus-log-viewer executable. Preparing shared log … #162

Closed

Conversation

rickkw
Copy link
Contributor

@rickkw rickkw commented Jul 30, 2018

  1. Cloned titus-darion to titus-log-viewer executable
  2. Modified darion shared code to work with log root in both inside and outside of container

…iewer code to work in both inside and outside container.
Copy link
Contributor

@sargun sargun left a comment

Choose a reason for hiding this comment

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

We can change the API for the single-tenant version of Darion. It doesn't have to be focused around container ID, and it can be designed to just "browse" /logs.

}

func newMux() *http.ServeMux {
r := http.NewServeMux()
Copy link
Contributor

Choose a reason for hiding this comment

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

If you're cloning this, it probably makes sense to split up this (shared) code.

@@ -39,8 +39,8 @@ func LogHandler(w http.ResponseWriter, r *http.Request) {
}

func logHandler(w http.ResponseWriter, r *http.Request, containerID, fileName string) {
filePath := filepath.Join(conf.ContainersHome, containerID, "logs", fileName)
fout, err := os.Open(filePath)
logPath := filepath.Join(buildLogLocationBase(containerID), fileName)
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't know if the cloned version is meant to be multi-tenant, or single-tenant. If it's meant to be single-tenant (i.e. Darion per container), then you should remove everything around containerID.

Copy link
Contributor Author

@rickkw rickkw Jul 30, 2018

Choose a reason for hiding this comment

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

@sargun the goal of this PR is to fudge the darion code just enough that allows both multi-tenant and single-tenant to work (initially), so I can work on injecting it into the container. When I commented about cloning, I referred to the executable, titus-log-viewer. The shared darion stays mostly intact. This is not meant to be the final code.

I don't want to spend time refactoring this code (just yet). Rather, I think it's better to focus on the process injection which has more unknowns.

Copy link
Contributor

Choose a reason for hiding this comment

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

Then I would keep this on your own branch for now, and wait to merge until it's ready, because this part of the code isn't touched very much.


// TitusTaskID initialized using TITUS_TASK_ID from OS environment variable.
// It can be used as a crude way to determine if this process is running inside a container.
TitusTaskID = os.Getenv("TITUS_TASK_ID")
Copy link
Contributor

Choose a reason for hiding this comment

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

See Above, RE: multi-tenant vs. single-tenant.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 1795

  • 15 of 27 (55.56%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.06%) to 24.099%

Changes Missing Coverage Covered Lines Changed/Added Lines %
darion/api/handlers.go 6 9 66.67%
cmd/titus-log-viewer/main.go 9 18 50.0%
Totals Coverage Status
Change from base Build 1786: 0.06%
Covered Lines: 2299
Relevant Lines: 9540

💛 - Coveralls

@codecov
Copy link

codecov bot commented Jul 30, 2018

Codecov Report

Merging #162 into master will increase coverage by 0.01%.
The diff coverage is 50%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #162      +/-   ##
==========================================
+ Coverage   33.76%   33.78%   +0.01%     
==========================================
  Files          63       64       +1     
  Lines        7543     7560      +17     
==========================================
+ Hits         2547     2554       +7     
- Misses       4689     4697       +8     
- Partials      307      309       +2
Impacted Files Coverage Δ
darion/conf/conf.go 40% <ø> (ø) ⬆️
cmd/titus-log-viewer/main.go 46.66% <46.66%> (ø)
darion/api/handlers.go 64.62% <60%> (-0.9%) ⬇️

logsutil.MaybeSetupLoggerIfUnderSystemd()
log.Println("Titus log viewer is starting")
r := newMux()
if err := http.ListenAndServe(":8004", r); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this meant to run in a different network namespace where it won't clash on port with Darion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

"testing"
)

func TestPing(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is this test actually testing? Looks like it's just using golang http packages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

honest I don't know. I just cloned the test from darion.

@fabiokung
Copy link
Contributor

@rickkw are you still looking for reviews here, or should we wait until you have done testing in your own branch and are ready to open the final PR?

@rickkw
Copy link
Contributor Author

rickkw commented Aug 1, 2018

@fabiokung per @sargun advice, I am leaving this PR open while working on injecting Darion inside containers. No need to merge this PR and introduce risk, while this effort is still WIP. I won't be merging this PR until I make progress with the actual injection work.

@sargun sargun closed this Nov 12, 2018
@sargun sargun deleted the TITUS-2326_prepare_log_viewer_to_run_inside_container branch November 12, 2018 18:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants