-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Embed Logger inside Deployer #5809
Conversation
|
||
podSelectors := kubernetes.NewImageList() | ||
|
||
logger := getLogger(runCtx, kubectlCLI, podSelectors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we rather instantiate a LoggerProvider
that can instantiate the right Logger
in the corresponding Deployer
? All the NewDeployer
methods can take the LoggerProvider
instead. This could map pretty well with a docker.NewDeployer(_, _, loggerProvider)
(for the upcoming docker deployer) without any more changes to this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LoggerProvider
can maintain a singleton instance of a KubernetesLogger
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that idea a lot, I definitely planned on abstracting away the logging implementation from the getLogger()
method, but your idea of a provider is much better than a big switch
statement. I also want to move all of the get*()
methods out of new.go
(since this file is getting huge). WDYT about doing this in a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sounds good!
if !r.runCtx.Tail() { | ||
return nil | ||
} | ||
type Logger interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: does this conflict with the application Logger
interfaces? Should we call it DeployLogger
or ResourceLogger
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please address #5809 (comment) in a follow up PR.
Codecov Report
@@ Coverage Diff @@
## master #5809 +/- ##
==========================================
- Coverage 71.00% 70.95% -0.06%
==========================================
Files 438 439 +1
Lines 16497 16521 +24
==========================================
+ Hits 11714 11722 +8
- Misses 3921 3935 +14
- Partials 862 864 +2
Continue to review full report at Codecov.
|
This reverts commit cbb0545.
This change embeds the
Logger
object's responsibilities inside of theDeployer
. As "logging" can really be interpreted as "retrieving information from deployed resources", any implementation of aLogger
is implicitly tied to an implementation of aDeployer
in Skaffold. To pave the way for future implementations of aDeployer
that are not centered around Kubernetes, we need to delegate logging responsibilities to theDeployer
.A slightly modified interface for
Logger
is introduced:such that the logging-specific actions are more clearly identified when present on the
Deployer
. One additional method is added,RegisterBuildArtifacts
, which allows newly-built artifacts to be added to a pre-existingLogger
.This interface is then embedded into the
Deployer
interface:to ensure that every implementation of
Deployer
in Skaffold also provides an implementation forLogger
.All existing implementations of
Deployer
in Skaffold are Kubernetes-centric, and have been retrofitted to use thekubernetes.LogAggregator
as their implementation ofLogger
. in the future, any new Kubernetes-centricDeployer
implementations can reuse thisLogger
, but any newDeployer
implementations that use a non-Kubernetes platform (e.g.docker
) will need to implement a newLogger
.cc #5813