-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix stack name when manifest at .okteto folder #2742
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2742 +/- ##
==========================================
+ Coverage 32.10% 32.18% +0.07%
==========================================
Files 158 158
Lines 18580 18592 +12
==========================================
+ Hits 5966 5984 +18
+ Misses 11909 11896 -13
- Partials 705 712 +7
Continue to review full report at Codecov.
|
cmd/deploy/deploy.go
Outdated
@@ -152,13 +152,18 @@ func Deploy(ctx context.Context) *cobra.Command { | |||
} | |||
} | |||
|
|||
// when name is an option - this overrides the manifest or inferred name | |||
if options.Name != "" { | |||
os.Setenv(model.OktetoNameEnvVar, options.Name) |
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.
This seems like a very indirect way of setting this and is quite brittle. We've effectively set a global variable, in env, in order to make a decision later on. What are all of the ways this env var get set and how can we track them? Is there a more direct approach we can take that eliminates this?
It seems like a better, and less brittle way, would be to set the name as a config option and somehow passing it into the code that will eventually do the deploy directly.
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.
yup, this was actually not needed to be fixed :/ i've updated the scope for the PR due to the comments at the issue #2661
5e07b4d
to
943ee13
Compare
Note to bear in mind. This could be considered as a non-backward compatible change. If I already executed deployed an application with current version of the CLI, I would have a dev environment called I don't know how frequent could be this case, but commented just to take into account |
CLI logs:
|
@teresaromero what would happen if after that I execute |
when using the current one, the Should we add some logic so the components change their labels and dev environment name to be swaped? |
I would add logic to, in case we are in @ifbyol great catch! |
I've been going tthough the code to make this modification, we have to change all components ( deployments, sfs, jobs, volumes, etc...) ? |
I've tried to add some logic to swap the stack names in case the old one was
as the labels are inmutable, should then display a warning message so the user can destroy the |
@teresaromero I would automatically |
@ifbyol @jLopezbarb can you check the latest changes that involve destroy de compontent and redeploy with new labels? thanks |
edit description with instructions on how to reproduce the change |
pkg/cmd/stack/deploy.go
Outdated
if err := deployments.Destroy(ctx, old.Name, old.Namespace, c); err != nil { | ||
return false, fmt.Errorf("error updating deployment of service '%s': %s", svcName, err.Error()) | ||
} | ||
if _, err := deployments.Deploy(ctx, d, c); err != nil { | ||
return false, fmt.Errorf("error updating deployment of service '%s': %s", svcName, err.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.
This is odd, why if it failed because a temporal error redeploying? Any error in a redeploy would imply to destroy a deploy again even if it is not necessary, right?
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.
you are right, in case of statefulsets we make this only when the error is not "Forbidden", do you think we should control other types of errorS?
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.
@ifbyol i've reverted the change here and added an exception prior to deploying for first time to check if is the exception, if yes, then we destroy and redeploy
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.
ok, I think it looks good now.
Maybe we can include a comment before the if to explain why this piece of code is needed? If not, in a few months we won't remember why we do that check
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've added a comment with a link to this PR and some context
Signed-off-by: Teresa Romero <teresa@okteto.com>
Signed-off-by: Teresa Romero <teresa@okteto.com>
Signed-off-by: Teresa Romero <teresa@okteto.com>
4e07bf9
to
ca58381
Compare
return false, fmt.Errorf("skipping deploy of deployment '%s' due to name collision with deployment in stack '%s'", svcName, old.Labels[model.StackNameLabel]) | ||
} | ||
if v, ok := old.Labels[model.DeployedByLabel]; ok { | ||
if old.Labels[model.StackNameLabel] == "okteto" { | ||
d.Labels[model.DeployedByLabel] = s.Name | ||
} |
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.
Don't you need an else here? If you set the deployed-by
label to the new name, the line 498 will overwrite it with the value coming from the old deployment, right?
Or moving the line 498 before doing the okteto
check would be enough
Signed-off-by: Teresa Romero <teresa@okteto.com>
Signed-off-by: Teresa Romero <teresa@okteto.com>
Can we add some unit test with the scenario of having an .okteto folder |
Signed-off-by: Teresa Romero <teresa@okteto.com>
Signed-off-by: Teresa Romero <teresa@okteto.com>
@maroshii i've added both 2 labels: bugfix and breaking change... its definatly a bug fix as the users which use an .okteto folder for their compose and stacks will now have the dev environment name fixed, but at the same time, if someone had a dev environment deployed with prev version of cli, now the old one will be empty and they will se a new one with the correct name, not sure if this is a breking change, or "not that breaking" change.. but is a change :/ EDIT: on i get an error that only 1 so... i will go with bug fix as we have logic in place to dont break |
Signed-off-by: Teresa Romero teresa@okteto.com
Fixes #2661
Proposed changes
docker-compose.yaml
is under an.okteto
folder at the repository, the dev environment name was being used wasokteto
. - fixed the parsing for directoriesokteto
destroy and redeploy the componentsokteto
dev environment will be left empty, used can activly destroy it by ui or cli destroy --nameHow to reproduce
.okteto
folder inside the repo