-
Notifications
You must be signed in to change notification settings - Fork 311
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add deploy insights #4206
Conversation
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
This reverts commit c6be3c1. Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Thank you for your contribution. unfortunately, one or more of your commits are missing the required "Signed-off-by:" statement. Signing off is part of the Developer Certificate of Origin (DCO) which is used by this project. Read the DCO and project contributing guide carefully, and amend your commits using the git CLI. Note that this does not require any cryptography, keys or special steps to be taken. 馃挕 Shall we fix this?This will only take a few moments. First, clone your fork and checkout this branch using the git CLI. Next, set up your real name and email address:
Finally, run one of these commands to add the "Signed-off-by" line to your commits. If you only have one commit so far then run: Check that the message has been added properly by running "git log". |
Signed-off-by: Javier Lopez <javier@okteto.com>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #4206 +/- ##
==========================================
+ Coverage 45.62% 45.69% +0.07%
==========================================
Files 302 303 +1
Lines 27440 27535 +95
==========================================
+ Hits 12520 12583 +63
- Misses 13856 13883 +27
- Partials 1064 1069 +5 |
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
pkg/cmd/pipeline/translate.go
Outdated
if err != nil { | ||
return err | ||
} | ||
cmap.Data[phasesField] = string(encodedPhases) |
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.
Would it make sense to encode the data to base64 as we do with other data like variables?
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 don't think it's necessary given that this data is not going to grow too much in the future and from the k8s spec it should be human readable.
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.
It is not about the length, it is about the format and possible issues with chars or similar. As we are controlling the format of that, there might not be issues, but just in case. Anyways, this is completely a nit, you can ignore it
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.
Right now it's a json that we generate. We'll have to rethink it if we add the commands names but right now we are the ones that set all the naming in the json generated
cmd/deploy/cfghandler.go
Outdated
@@ -113,6 +115,14 @@ func (ch *defaultConfigMapHandler) UpdateEnvsFromCommands(ctx context.Context, n | |||
return nil | |||
} | |||
|
|||
func (ch *defaultConfigMapHandler) AddPhase(ctx context.Context, name, namespace, phase string, duration time.Duration) error { |
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.
For the future, out of scope of this PR. If we have 2 different implementations to satisfy an interface and some of the functions have duplicated the logic, it is error prone. We should extract those implementations to a common piece and the implementations should use that common piece through struct embedding or dependency
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
@jLopezbarb I think you need to merge master. There are changes not sure they should appear (apart from the conflicts) |
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
namespace := okteto.GetContext().Namespace | ||
if options.Manifest != nil { | ||
namespace = options.Manifest.Namespace | ||
} |
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.
Was all the namespace calculation done before? I mean, do we consider here if the namespace is specified as command flag?
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.
Yes, at the beginning of the command the okteto context set the namespace in the global variable of okteto contextStore which is the one we are using. When we read the manifest we set it on the options.Manifest
and use it for the rest of the command.
Why we can't use
okteto.GetContext().Namespace
?
If the namespace is specified in the manifest we are not setting the global variable, that's why we need this code
pkg/cmd/pipeline/translate.go
Outdated
if err != nil { | ||
return err | ||
} | ||
val, ok := cmap.Data[phasesField] |
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.
Backend translations of the configmap doesn't know anything about phase
field and the Data field is recreated each time. Would there be any scenario in which we might lose the information in the configmap because of that? have we thought about that?
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.
Given that right now we are only adding the phases field in order to track events and they are calculated and created in K8s in the CLI execution, there is no scenario where we might lose the information.
If we wanted to store the information to show it on the UI, there is one scenario that we have to take a look (deploying with a previous CLI version)
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.
Given that right now we are only adding the phases field in order to track events and they are calculated and created in K8s in the CLI execution, there is no scenario where we might lose the information.
If we wanted to store the information to show it on the UI, there is one scenario that we have to take a look (deploying with a previous CLI version)
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.
Would there be an scenario in which a deploy within another deploy would use the same configmap, overriding the phase
field for the main one?
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.
Do you mean if they have the same name? It'll create two events with the same information besides the duration. What it will happen is:
- Main deploy starts the timer:
- The deploy from inside starts the timer
- The deploy from inside updates the configmap
- The deploy from inside sends the event with its duration
- The main deploy updates the configmap
- The main deploy sends the event with its duration
I think it's the way it must behave but open to discuss it
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.
In the moment in which the main deploy add a phase before the "deploy inside" adds its own, the inside one would overwrite the phase
field of the main one. But not sure if the scenario is possible or not
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.
Anyways, this would be a corner case and not sure if it is even possible
Signed-off-by: Javier Lopez <javier@okteto.com>
Signed-off-by: Javier Lopez <javier@okteto.com>
func (r repositoryURL) String() string { | ||
repo := r.URL | ||
repo.User = nil | ||
|
||
switch repo.Scheme { |
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 don't think we should change this function or at least we should change the name of the function. We are assuming that in all the places where we want the string representation of a repository URL we want to use https
protocol. In some cases we might just want the URL as specified by the user.
Among other things, this is also being used by the function GetAnonymizedRepo
, that is being used in different places. Have we double checked that in all the places where that is being used doesn't matter to change the URL scheme?
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 have double checked. We use GetAnonymizedRepo
in:
- build command for sending analytics, so with this change we'll be sending always the same scheme for the repo and have better metrics
- pipeline command in order to show a list of the repositories, which I think we should be showing all with the same schema also.
- In our info/debug logs to hide user information
- The new insights package
The only one that I have doubts is with the logs. It's only used in the inferer, but given that the comparison between two repositories URL takes that into account I think we are good to go
* feat: add events for build using manifest Signed-off-by: Javier Lopez <javier@okteto.com> * feat: add deploy insights Signed-off-by: Javier Lopez <javier@okteto.com> * fix: field alingment Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: field alingment Signed-off-by: Javier Lopez <javier@okteto.com> * Revert "fix: field alingment" This reverts commit c6be3c1. Signed-off-by: Javier Lopez <javier@okteto.com> * remove analytics from deploy Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * refactor: extract event tracker outside of the constructor Signed-off-by: Javier Lopez <javier@okteto.com> * address feedback Signed-off-by: Javier Lopez <javier@okteto.com> * refactor: address comments Signed-off-by: Javier Lopez <javier@okteto.com> * refactor: address comments Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: rename Signed-off-by: Javier Lopez <javier@okteto.com> * fix: field alingment Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add tests Signed-off-by: Javier Lopez <javier@okteto.com> * lint: fix linter warnign Signed-off-by: Javier Lopez <javier@okteto.com> * fix: bug found with redeploy Signed-off-by: Javier Lopez <javier@okteto.com> * fix: compose bug Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: golangci Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add unint tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: error while reading manifest Signed-off-by: Javier Lopez <javier@okteto.com> * feat: add label for identify events Signed-off-by: Javier Lopez <javier@okteto.com> * address feedback Signed-off-by: Javier Lopez <javier@okteto.com> * address feedback Signed-off-by: Javier Lopez <javier@okteto.com> --------- Signed-off-by: Javier Lopez <javier@okteto.com> (cherry picked from commit 12b2188)
* feat: add events for build using manifest Signed-off-by: Javier Lopez <javier@okteto.com> * feat: add deploy insights Signed-off-by: Javier Lopez <javier@okteto.com> * fix: field alingment Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: field alingment Signed-off-by: Javier Lopez <javier@okteto.com> * Revert "fix: field alingment" This reverts commit c6be3c1. Signed-off-by: Javier Lopez <javier@okteto.com> * remove analytics from deploy Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * refactor: extract event tracker outside of the constructor Signed-off-by: Javier Lopez <javier@okteto.com> * address feedback Signed-off-by: Javier Lopez <javier@okteto.com> * refactor: address comments Signed-off-by: Javier Lopez <javier@okteto.com> * refactor: address comments Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: rename Signed-off-by: Javier Lopez <javier@okteto.com> * fix: field alingment Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add tests Signed-off-by: Javier Lopez <javier@okteto.com> * lint: fix linter warnign Signed-off-by: Javier Lopez <javier@okteto.com> * fix: bug found with redeploy Signed-off-by: Javier Lopez <javier@okteto.com> * fix: compose bug Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: unit tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: golangci Signed-off-by: Javier Lopez <javier@okteto.com> * tests: add unint tests Signed-off-by: Javier Lopez <javier@okteto.com> * fix: error while reading manifest Signed-off-by: Javier Lopez <javier@okteto.com> * feat: add label for identify events Signed-off-by: Javier Lopez <javier@okteto.com> * address feedback Signed-off-by: Javier Lopez <javier@okteto.com> * address feedback Signed-off-by: Javier Lopez <javier@okteto.com> --------- Signed-off-by: Javier Lopez <javier@okteto.com> (cherry picked from commit 12b2188) Co-authored-by: Javier L贸pez Barba <javier@okteto.com>
Proposed changes
DEV-201
This PR adds a k8s event whenever a build is triggered using a manifest v2 either if it's called from an okteto build command or a okteto deploy command.
The event follows the following schema:
How to validate
okteto deploy (--remote) (--wait)
on okteto/movieskubectl get events.events.k8s.io -w
CLI Quality Reminders 馃敡
For both authors and reviewers: