Skip to content

Commit

Permalink
Merge branch 'master' of github.com:flyteorg/flyte into enable-agent-…
Browse files Browse the repository at this point in the history
…service
  • Loading branch information
pingsutw committed Mar 4, 2024
2 parents 4e11e29 + 4a95abf commit 8e0ff4d
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 6 deletions.
18 changes: 17 additions & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,35 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- name: Fetch the code
- name: Fetch flyte code
uses: actions/checkout@v4
with:
path: "${{ github.workspace }}/flyte"
- name: Fetch flytekit code
uses: actions/checkout@v4
with:
repository: flyteorg/flytekit
path: "${{ github.workspace }}/flytekit"
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.9
- shell: bash -el {0}
working-directory: ${{ github.workspace }}/flyte
run: |
conda install -c conda-forge conda-lock
conda-lock install -n monodocs-env monodocs-environment.lock.yaml
- shell: bash -el {0}
working-directory: ${{ github.workspace }}/flyte
run: |
conda activate monodocs-env
export SETUPTOOLS_SCM_PRETEND_VERSION="2.0.0"
pip install -e ./flyteidl
- shell: bash -el {0}
working-directory: ${{ github.workspace }}/flytekit
run: |
conda activate monodocs-env
pip install -e .
conda info
conda list
conda config --show-sources
Expand All @@ -49,6 +64,7 @@ jobs:
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
- name: Build the documentation
working-directory: ${{ github.workspace }}/flyte
shell: bash -el {0}
run: |
conda activate monodocs-env
Expand Down
1 change: 1 addition & 0 deletions flyteplugins/go/tasks/logs/logging_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ func GetLogsForContainerInPod(ctx context.Context, logPlugin tasklog.Plugin, tas
TaskExecutionID: taskExecID,
ExtraTemplateVars: extraLogTemplateVars,
TaskTemplate: taskTemplate,
HostName: pod.Spec.Hostname,
},
)

Expand Down
65 changes: 60 additions & 5 deletions flyteplugins/go/tasks/logs/logging_utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,40 @@ func TestGetLogsForContainerInPod_All(t *testing.T) {
assert.Len(t, logs, 2)
}

func TestGetLogsForContainerInPod_HostName(t *testing.T) {
logPlugin, err := InitializeLogPlugins(&LogConfig{
IsKubernetesEnabled: true,
KubernetesURL: "k8s.com",
IsCloudwatchEnabled: true,
CloudwatchRegion: "us-east-1",
CloudwatchLogGroup: "/kubernetes/flyte-production",
})
assert.NoError(t, err)

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

logs, err := GetLogsForContainerInPod(context.TODO(), logPlugin, dummyTaskExecID(), pod, 0, " Suffix", nil, nil)
assert.Nil(t, err)
assert.Len(t, logs, 2)
}

func TestGetLogsForContainerInPod_Stackdriver(t *testing.T) {
logPlugin, err := InitializeLogPlugins(&LogConfig{
IsStackDriverEnabled: true,
Expand Down Expand Up @@ -268,7 +302,7 @@ func TestGetLogsForContainerInPod_LegacyTemplate(t *testing.T) {
MessageFormat: core.TaskLog_JSON,
Name: "Stackdriver Logs my-Suffix",
},
})
}, "")
})

t.Run("StackDriver", func(t *testing.T) {
Expand All @@ -281,11 +315,11 @@ func TestGetLogsForContainerInPod_LegacyTemplate(t *testing.T) {
MessageFormat: core.TaskLog_JSON,
Name: "Stackdriver Logs my-Suffix",
},
})
}, "")
})
}

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

Expand All @@ -300,6 +334,7 @@ func assertTestSucceeded(tb testing.TB, config *LogConfig, taskTemplate *core.Ta
Name: "ContainerName",
},
},
Hostname: hostname,
},
Status: v1.PodStatus{
ContainerStatuses: []v1.ContainerStatus{
Expand Down Expand Up @@ -347,7 +382,27 @@ func TestGetLogsForContainerInPod_Templates(t *testing.T) {
MessageFormat: core.TaskLog_JSON,
Name: "Internal my-Suffix",
},
})
}, "")
}

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 TestGetLogsForContainerInPod_Flyteinteractive(t *testing.T) {
Expand Down Expand Up @@ -507,7 +562,7 @@ func TestGetLogsForContainerInPod_Flyteinteractive(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
assertTestSucceeded(t, tt.config, tt.template, tt.expectedTaskLogs)
assertTestSucceeded(t, tt.config, tt.template, tt.expectedTaskLogs, "")
})
}
}

0 comments on commit 8e0ff4d

Please sign in to comment.