Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Adapt logs command to Loki #213

Merged
merged 1 commit into from
Aug 17, 2020
Merged

Conversation

Kristian-ZH
Copy link
Contributor

What this PR does / why we need it:
Adapt logs command to Loki

This PR depends on this one: gardener/gardener#2515 and should wait until it is merged

Which issue(s) this PR fixes:
Fixes #

Special notes for your reviewer:
@DockToFuture

Release note:

`--loki` flag is added in the `gardenctl logs` command
`--elasticsearch` flag is removed from the `gardenctl logs` command.

@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jun 26, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 added needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Jun 26, 2020
@vpnachev
Copy link
Contributor

/reviewed ok-to-test

@gardener-robot gardener-robot added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jul 31, 2020
@gardener-robot-ci-3 gardener-robot-ci-3 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Jul 31, 2020
@vpnachev
Copy link
Contributor

gardener/gardener#2515 has been merged.
In the best case, I think that gardenctl should support both flags for some time and remove --elasticsearch later. This is needed to support landscape running on different versions of Gardener. However, I have no strong opinion about it.

@neo-liang-sap
Copy link
Contributor

Hi @Kristian-ZH , i see this PR is failing at https://concourse.ci.gardener.cloud/builds/67311
in your local build env you can run gardenctl/.ci/check to reproduce this error.
Could you please fix this error in your PR?
Thanks
-Neo

Running golangci-lint...
pkg/cmd/logs.go:37:2: `emptyString` is unused (deadcode)
	emptyString           = ""
	^
pkg/cmd/logs.go:38:2: `unauthorized` is unused (deadcode)
	unauthorized          = "Unauthorized"
	^
pkg/cmd/logs.go:219:6: `getCredentials` is unused (deadcode)
func getCredentials(namespace string) (*v1.Secret, error) {
     ^
pkg/cmd/logs.go:261:3: ineffectual assignment to `lokiQuery` (ineffassign)
		lokiQuery += fmt.Sprintf("&&query={container_name=~\"%s.*\"", container)
		^

@neo-liang-sap
Copy link
Contributor

Update: per Slack conversation with @Kristian-ZH , he will fix this validation error soon

@Kristian-ZH Kristian-ZH requested a review from a team as a code owner August 10, 2020 06:32
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 10, 2020
@neo-liang-sap
Copy link
Contributor

@dansible @DockToFuture do you have any comments on this PR? if not i will go ahead merge this PR, thanks!

@Kristian-ZH
Copy link
Contributor Author

@dansible @DockToFuture do you have any comments on this PR? if not i will go ahead merge this PR, thanks!

I want also to discuss with @vpnachev if we need to add support for --elasticsearch also :)

@neo-liang-sap
Copy link
Contributor

neo-liang-sap commented Aug 10, 2020

I want also to discuss with @vpnachev if we need to add support for --elasticsearch also :)

sure, take your time, thanks for the PR!

@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 10, 2020
@Kristian-ZH
Copy link
Contributor Author

I added support for --elasticsearch flag too

@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 10, 2020
@Kristian-ZH
Copy link
Contributor Author

@vlvasilev Can you please check the PR and make a review

@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 10, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 10, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 10, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 10, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 added reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) and removed reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) labels Aug 11, 2020
}
pieces := strings.Split(apiAdress, ".")

return "garden-" + pieces[2]

Choose a reason for hiding this comment

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

why piece 2? Is this apiAddress always be in the 2 position?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know other option how to take the project namespace from the garden cluster

Copy link
Contributor

@vpnachev vpnachev Aug 12, 2020

Choose a reason for hiding this comment

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

If you know the project name, you can retrieve the namespace out of its spec, e.g. .spec.namespace.
Also, not all project namespaces are prefixed with garden-, and some have a trailing hash, so I advise you to get the namespace name from the project.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm, what about when the user is targeting shoot directly.
e.g. g target garden -> seed -> shoot. In this way I do not know the project name

Copy link
Contributor

Choose a reason for hiding this comment

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

The URL of the API is not a better solution, it will even not work when the DNS is disabled and the public address of the kube-apiserver service is used directly.

Copy link
Contributor

Choose a reason for hiding this comment

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

The kubeconfig file contains the technical name of the shoot as cluster and context name, e.g. shoot-[-]<project-name-[-]<shoot-name>. You have the shoot name in the current target, so you can easily find the project name from the technical name.

@vlvasilev
Copy link

/lgtm

@gardener-robot gardener-robot added the reviewed/lgtm Has approval for merging label Aug 12, 2020
}
pieces := strings.Split(apiAdress, ".")

return "garden-" + pieces[2]
Copy link
Contributor

Choose a reason for hiding this comment

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

The kubeconfig file contains the technical name of the shoot as cluster and context name, e.g. shoot-[-]<project-name-[-]<shoot-name>. You have the shoot name in the current target, so you can easily find the project name from the technical name.

@Kristian-ZH
Copy link
Contributor Author

Kristian-ZH commented Aug 14, 2020

Sorry for the delay but we are fixing issues with the logging stack.

Hope next week will finish this PR
(Will refactor the function GetProjectName, because does not work correctly)

@neo-liang-sap
Copy link
Contributor

Sorry for the delay but we are fixing issues with the logging stack.
Hope next week will finish this PR

@Kristian-ZH , thanks! absolutely not urgent, take your time! i just regularly (as one of code owner) check the existing PR to make sure it's not blocked or forgotten ;)
thanks again for working on this PR!
-Neo

@gardener-robot-ci-2 gardener-robot-ci-2 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 17, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 17, 2020
@Kristian-ZH
Copy link
Contributor Author

@vpnachev @neo-liang-sap Please check the latest changes

@gardener-robot-ci-3 gardener-robot-ci-3 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 17, 2020
@gardener-robot-ci-1 gardener-robot-ci-1 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 17, 2020
@neo-liang-sap
Copy link
Contributor

/lgtm

Copy link
Contributor

@vpnachev vpnachev left a comment

Choose a reason for hiding this comment

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

Some suggestions for improvements.

pkg/cmd/logs.go Outdated Show resolved Hide resolved
pkg/cmd/logs.go Outdated Show resolved Hide resolved
pkg/cmd/logs.go Outdated Show resolved Hide resolved
pkg/cmd/logs.go Outdated Show resolved Hide resolved
pkg/cmd/logs.go Outdated Show resolved Hide resolved
pkg/cmd/logs.go Outdated Show resolved Hide resolved
pkg/cmd/miscellaneous.go Outdated Show resolved Hide resolved
@gardener-robot-ci-1 gardener-robot-ci-1 added the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 17, 2020
@gardener-robot-ci-2 gardener-robot-ci-2 removed the reviewed/ok-to-test Has approval for testing (check PR in detail before setting this label because PR is run on CI/CD) label Aug 17, 2020
Copy link
Contributor

@vpnachev vpnachev left a comment

Choose a reason for hiding this comment

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

/lgtm

@neo-liang-sap neo-liang-sap merged commit ec77b52 into gardener-attic:master Aug 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
needs/ok-to-test Needs approval for testing (check PR in detail before setting this label because PR is run on CI/CD) reviewed/lgtm Has approval for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants