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

add hostname to input #4939

Merged
merged 4 commits into from
Mar 4, 2024
Merged

add hostname to input #4939

merged 4 commits into from
Mar 4, 2024

Conversation

novahow
Copy link
Contributor

@novahow novahow commented Feb 23, 2024

Tracking issue

https://github.com/flyteorg/flyte/issues/

closes #4750

Why are the changes needed?

hostname not resolvable in plugin's GetTaskLogs

What changes were proposed in this pull request?

add a hostname parameter to the Input in GetTaskLogs method.

How was this patch tested?

cd flyteplugins
make test

Setup process

Screenshots

Check all the applicable boxes

  • I updated the documentation accordingly.
  • All new and existing tests passed.
  • All commits are signed-off.

Related PRs

Docs link

Signed-off-by: novahow <[email protected]>
Copy link

welcome bot commented Feb 23, 2024

Thank you for opening this pull request! 🙌

These tips will help get your PR across the finish line:

  • Most of the repos have a PR template; if not, fill it out to the best of your knowledge.
  • Sign off your commits (Reference: DCO Guide).

@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. enhancement New feature or request labels Feb 23, 2024
Copy link
Member

@pingsutw pingsutw left a comment

Choose a reason for hiding this comment

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

Copy link

codecov bot commented Feb 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 58.97%. Comparing base (df1b034) to head (b14a00e).
Report is 62 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4939      +/-   ##
==========================================
- Coverage   58.98%   58.97%   -0.02%     
==========================================
  Files         644      645       +1     
  Lines       55145    55562     +417     
==========================================
+ Hits        32528    32767     +239     
- Misses      20043    20200     +157     
- Partials     2574     2595      +21     
Flag Coverage Δ
unittests 58.97% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: novahow <[email protected]>
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XS This PR changes 0-9 lines, ignoring generated files. labels Feb 24, 2024
@novahow
Copy link
Contributor Author

novahow commented Feb 24, 2024

Thanks, could you add a unit test to this file? https://github.com/flyteorg/flyte/blob/a4ab37a852ee796996b356540984b702153bfa67/flyteplugins/go/tasks/logs/logging_utils_test.go

Added a basic test. Not sure if the added test is legitimate though. Is template testing, for example something like

func TestGetLogsForContainerInPodTemplates_Hostname(t *testing.T) {
	assertTestSucceeded(t, &LogConfig{
		Templates: []tasklog.TemplateLogPlugin{
			{
				DisplayName: "StackDriver",
				TemplateURIs: []string{
					"{{ .hostname }}/{{ .namespace }}/{{ .podName }}/{{ .containerName }}/{{ .containerId }}",
				},
				MessageFormat: core.TaskLog_JSON,
			},
		},
	}, nil, []*core.TaskLog{
		{
			Uri:           "my-hostname/my-namespace/my-pod/ContainerName/ContainerID",
			MessageFormat: core.TaskLog_JSON,
			Name:          "StackDriver my-Suffix",
		},
	}, "my-hostname")
}

func assertTestSucceeded(tb testing.TB, config *LogConfig, taskTemplate *core.TaskTemplate, expectedTaskLogs []*core.TaskLog, hostname string) {
	logPlugin, err := InitializeLogPlugins(config)
	assert.NoError(tb, err)

	pod := &v1.Pod{
		ObjectMeta: v12.ObjectMeta{
			Namespace: "my-namespace",
			Name:      "my-pod",
		},
		Spec: v1.PodSpec{
			Containers: []v1.Container{
				{
					Name: "ContainerName",
				},
			},
			Hostname: hostname,
		},
		Status: v1.PodStatus{
			ContainerStatuses: []v1.ContainerStatus{
				{
					ContainerID: "ContainerID",
				},
			},
		},
	}

	logs, err := GetLogsForContainerInPod(context.TODO(), logPlugin, dummyTaskExecID(), pod, 0, " my-Suffix", nil, taskTemplate)
	assert.Nil(tb, err)
	assert.Len(tb, logs, len(expectedTaskLogs))
	if diff := deep.Equal(logs, expectedTaskLogs); len(diff) > 0 {
		assert.FailNowf(tb, "Not Equal.", "Diff: %v", diff)
	}
}

needed?

@eapolinario
Copy link
Contributor

@novahow , can you add this test you're proposing? It tests the templating logic.

pingsutw
pingsutw previously approved these changes Feb 28, 2024
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Feb 28, 2024
Signed-off-by: novahow <[email protected]>
@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Feb 28, 2024
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:XXL This PR changes 1000+ lines, ignoring generated files. labels Feb 28, 2024
@pingsutw pingsutw merged commit cf21877 into flyteorg:master Mar 4, 2024
48 of 49 checks passed
Copy link

welcome bot commented Mar 4, 2024

Congrats on merging your first pull request! 🎉

yubofredwang pushed a commit to yubofredwang/flyte that referenced this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Docs] .hostname is not available in log templates
3 participants