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 autocreate field to manifest #1289

Merged
merged 8 commits into from Feb 23, 2021
Merged

Conversation

jLopezbarb
Copy link
Contributor

Signed-off-by: jLopezbarb javier@okteto.com

Fixes #1285

Proposed changes

  • Creates a autocrate field in manifest to deploy even when there is no application deployed on Okteto Cloud.
  • Returns an error if someone tries to create a deployment without adding this field on manifest or adding the --deploy arg

Signed-off-by: jLopezbarb <javier@okteto.com>
cmd/up/up.go Outdated
if !autoDeploy && !up.Dev.Autocreate {
err = errors.UserError{
E: fmt.Errorf("Can't autocreate deployment"),
Hint: "Deploy your app first on okteto cloud or enable it using --deploy arg or setting autocreate variable to true in your manifest"}
Copy link
Contributor

Choose a reason for hiding this comment

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

@rlamana ^^ that's the error if running okteto up and the deployment doesn't exist

Copy link
Contributor

Choose a reason for hiding this comment

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

Here a few suggestions on how we should present this output:

  1. Can we be more concise with the error? I wouldn't based it on the "autocreate" or at least I would make it clear that the deployment wasn't found first, and then maybe mention the possibility to add the autocreate in the hint. Maybe something like: Deployment ${name} not found in namespace '$namespace'

  2. Don't mention Okteto Cloud since this could be any cluster, right?

  3. In the hint show a clear list of options:

   - Make sure your application is deployed and ready.
   - Make sure your context is pointing to the right namespace.
   - Set the `autocreate` property in your okteto.yml manifest if you want to automatically create a new development container.
  1. Maybe we could show a link to the docs (are we doing this in other parts of the cli?).

wdyt?

cmd/up/up.go Outdated
if err := utils.AskIfDeploy(up.Dev.Name, up.Dev.Namespace); err != nil {
return nil, false, err
}
if !autoDeploy && !up.Dev.Autocreate {
Copy link
Contributor

Choose a reason for hiding this comment

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

Set dev.Autocreate to true here:
https://github.com/okteto/okteto/blob/master/cmd/up/up.go#L180
and from there, we only care about dev.Autocreate.

Copy link
Member

Choose a reason for hiding this comment

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

How will this interact with the CLI param? Will the CLI take precedence?

Copy link
Member

@rberrelleza rberrelleza left a comment

Choose a reason for hiding this comment

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

See comments inline on the name of the key in the manifest.

pkg/model/dev.go Outdated
@@ -144,6 +144,7 @@ type Dev struct {
Resources ResourceRequirements `json:"resources,omitempty" yaml:"resources,omitempty"`
Services []*Dev `json:"services,omitempty" yaml:"services,omitempty"`
PersistentVolumeInfo *PersistentVolumeInfo `json:"persistentVolume,omitempty" yaml:"persistentVolume,omitempty"`
Autocreate bool `json:"autocreate,omitempty" yaml:"autocreate,omitempty"`
Copy link
Member

Choose a reason for hiding this comment

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

Is this the same as if the user passes the deploy arg in the CLI? If so, can we use the same name in the manifest to keep it consistent?

Copy link
Contributor

Choose a reason for hiding this comment

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

deploy sounds confusing? what about autodeploy?
Also, we are keeping the deploy arg, but it should be deprecated

Copy link
Member

Choose a reason for hiding this comment

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

I think calling the same thing two different ways is more confusing. People use the --deploy param today, so renaming to autodeploy it'll be confusing to them.

Both terms are equally confusing to me TBH (from the perspective of a new user), the fact that we call it 'deploy' or 'autocreate' is leaking that fact that we need a deployment before doing the up phase of the process. I'd rather stay with the current 'confusing' term rather than introduce yet another until we have a term we really like.

Copy link
Contributor

Choose a reason for hiding this comment

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

@rberrelleza do you have numbers on how many are using --deploy? The idea is to deprecate the deploy arg

Copy link
Member

Choose a reason for hiding this comment

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

not sure if we are collecting that information, but people that ask questions in the slack channel tend to use it a lot.

maybe we can call it mode: standalone? (with the idea that then having mode:swap in the future so that users can be more explicit about how they want to use up?)

Copy link
Member

Choose a reason for hiding this comment

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

if we are deprecating the deploy flag, maybe let's add a message to the help now?

Copy link
Contributor

@rlamana rlamana Feb 19, 2021

Choose a reason for hiding this comment

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

I thought that the idea of using a mode was interesting for a long time. We even discussed this several times in the past, but the truth is that if we want to keep it simple that just adds a lot more complexity for a use case that is at its minimum:

According to the data:

  • 95.59% of swap use.
  • 4.41% of the "standalone" use. Of which we already know many happened by mistake.

Having a simple flag called autocreate: true right now (or even standalone: true) allows us to keep this feature for that small percentage who use it and avoids the current mistake of creating an unwanted deployment for some. I don't think we should be blocked by the naming convention for this, as long as is not as confusing as deploy or autodeploy, which is a term we use for something completely different.

I vote for autocreate: true or standalone: true

Copy link
Contributor

Choose a reason for hiding this comment

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

@jLopezbarb let's go with autocreate then

cmd/up/up.go Outdated
if err := utils.AskIfDeploy(up.Dev.Name, up.Dev.Namespace); err != nil {
return nil, false, err
}
if !autoDeploy && !up.Dev.Autocreate {
Copy link
Member

Choose a reason for hiding this comment

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

How will this interact with the CLI param? Will the CLI take precedence?

Signed-off-by: jLopezbarb <javier@okteto.com>
Signed-off-by: jLopezbarb <javier@okteto.com>
@codecov
Copy link

codecov bot commented Feb 18, 2021

Codecov Report

Merging #1289 (72bbe3e) into master (5ab5d6f) will decrease coverage by 0.07%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1289      +/-   ##
==========================================
- Coverage   34.01%   33.94%   -0.08%     
==========================================
  Files          68       68              
  Lines        5780     5792      +12     
==========================================
  Hits         1966     1966              
- Misses       3607     3619      +12     
  Partials      207      207              
Impacted Files Coverage Δ
cmd/init/init.go 11.95% <0.00%> (-0.07%) ⬇️
cmd/up/up.go 3.16% <0.00%> (-0.06%) ⬇️
pkg/model/dev.go 53.53% <ø> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5ab5d6f...72bbe3e. Read the comment docs.

@@ -109,7 +109,7 @@ func Up() *cobra.Command {
return err
}

if err := loadDevOverrides(dev, namespace, k8sContext, forcePull, remote); err != nil {
if err := loadDevOverrides(dev, namespace, k8sContext, forcePull, remote, autoDeploy); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

There is an option (MarkHidden) in cobra to not show an arg in the help command. Let add the hidden option to the autodeploy flag and also remove autodeploy from the docs, but keeping the flag hidden for now

cmd/up/up.go Outdated
err = errors.UserError{
E: fmt.Errorf("Deployment %s not found in namespace '%s'", up.Dev.Name, up.Dev.Namespace),
Hint: `Please:
- Make sure your application is deployed and ready.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Make sure your application is deployed and ready.
- Make sure your application is deployed.

cmd/up/up.go Outdated
E: fmt.Errorf("Deployment %s not found in namespace '%s'", up.Dev.Name, up.Dev.Namespace),
Hint: `Please:
- Make sure your application is deployed and ready.
- Make sure your context is pointing to the right namespace.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Make sure your context is pointing to the right namespace.
- Make sure your context is pointing to the right namespace.

cmd/up/up.go Outdated
Hint: `Please:
- Make sure your application is deployed and ready.
- Make sure your context is pointing to the right namespace.
- Set the 'autocreate' property in your okteto.yml manifest if you want to automatically create a new development container.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
- Set the 'autocreate' property in your okteto.yml manifest if you want to automatically create a new development container.
- Set the 'autocreate' field in your okteto manifest if you want to automatically create a new deployment in your current namespace.

Copy link
Contributor

Choose a reason for hiding this comment

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

What about a shorten version:

Suggested change
- Set the 'autocreate' property in your okteto.yml manifest if you want to automatically create a new development container.
- To automatically create a new deployment, set the 'autocreate' field in your okteto manifest.

- Make sure your application is deployed and ready.
- Make sure your context is pointing to the right namespace.
- Set the 'autocreate' property in your okteto.yml manifest if you want to automatically create a new development container.
More information is available here: https://okteto.com/docs/reference/cli#up`,
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this link should point to the autocreate field docs, and add it to the third bullet point.

Copy link
Contributor

Choose a reason for hiding this comment

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

@pchico83 I talked to @jLopezbarb about this. I'd like to start adding links to the full documentation of the commands in case of error. I suggested this so users can read about the general workings of the UP command (including a link to the autocreate but from the docs themselves), instead of having many links on the same output.

We should then also add a paragraph explaining the 'autocreate' in general in the UP description and add a link to how to configure it in the manifest from there.

@rlamana
Copy link
Contributor

rlamana commented Feb 19, 2021

@jLopezbarb can you share a screenshot of how the output looks in the terminal?

@jLopezbarb
Copy link
Contributor Author

jLopezbarb commented Feb 19, 2021

@rlamana this is how the output looks like with the url in the last bullet point.

Captura de pantalla 2021-02-19 a las 11 03 11

I think something like adding another line to show the url could be more readable for the user.

Captura de pantalla 2021-02-19 a las 11 12 44

@rlamana
Copy link
Contributor

rlamana commented Feb 19, 2021

@rlamana this is how the output looks like with the url in the last bullet point.

I thought it was going to look worse :-P We should definitely shorten the last bullet point and take the URL to the next line.

@rlamana
Copy link
Contributor

rlamana commented Feb 19, 2021

@rlamana this is how the output looks like with the url in the last bullet point.

We should also only point to the UP docs. It will make all that shorter too.

Signed-off-by: jLopezbarb <javier@okteto.com>
Signed-off-by: jLopezbarb <javier@okteto.com>
@jLopezbarb
Copy link
Contributor Author

The warning message looks like this:
Captura de pantalla 2021-02-19 a las 12 51 53

@pchico83
Copy link
Contributor

The warning message looks like this:
Captura de pantalla 2021-02-19 a las 12 51 53

I would remove the "warning" word, it is already implied by the yellow color. @rlamana thoughts?

cmd/up/up.go Outdated
@@ -104,12 +104,18 @@ func Up() *cobra.Command {

checkLocalWatchesConfiguration()

if autoDeploy {
log.Yellow(`Warning: The use of 'deploy' flag will be deprecated in a future release.
Please set 'autocreate' in your okteto manifest to get the same behaviour.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Please set 'autocreate' in your okteto manifest to get the same behaviour.
Please set 'autocreate' in your okteto manifest to get the same behavior.

@rlamana
Copy link
Contributor

rlamana commented Feb 22, 2021

I would remove the "warning" word, it is already implied by the yellow color. @rlamana thoughts?
@pchico83 @jLopezbarb I would remove it too. But, don't we have a symbol for this type of message, just like we have the [x] for errors, or the [i] for info messages? I think we should use that format too (maybe we can have an [!] exclamation symbol.

@pchico83
Copy link
Contributor

I would remove the "warning" word, it is already implied by the yellow color. @rlamana thoughts?
@pchico83 @jLopezbarb I would remove it too. But, don't we have a symbol for this type of message, just like we have the [x] for errors, or the [i] for info messages? I think we should use that format too (maybe we can have an [!] exclamation symbol.

@rlamana we don't but makes sense. Let's create an issue for it to keep the scope of this issue unaffected.

@derek derek bot added the no-dco label Feb 23, 2021
@derek
Copy link

derek bot commented Feb 23, 2021

Thank you for your contribution. I've just checked and your commit doesn't appear to be signed-off. That's something we need before your Pull Request can be merged. Please see our contributing guide.
Tip: if you only have one commit so far then run: git commit --amend --signoff and then git push --force.

@pchico83 pchico83 merged commit 563eafa into master Feb 23, 2021
@pchico83 pchico83 deleted the jlopezbarb/autocreate-manifest-field branch February 23, 2021 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Force "okteto up" to only work on "swap" mode
4 participants