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

Fix forbidden error when updating volumes stack #1538

Merged
merged 5 commits into from
May 18, 2021

Conversation

jLopezbarb
Copy link
Contributor

Signed-off-by: Javier López Barba javier@okteto.com

Fixes: When there is a volume deployed and you want to update resources (Okteto stack deploy without running Okteto stack destroy), it gives you a forbidden error, because the volume name and storage class name are not set initially. These fields are given by Okteto cluster.

Proposed changes

  • This PR checks if the requested resources are the same from the previous instance.
  • If the resources are the same, it doesn't update the volume, but if they are not equal updates the volume with the volume name and storage class name set instead of the new one

Signed-off-by: Javier López Barba <javier@okteto.com>
@@ -229,8 +229,11 @@ func deployVolume(ctx context.Context, volumeName string, s *model.Stack, c *kub
if old.Labels[okLabels.StackNameLabel] != s.Name {
return fmt.Errorf("name collision: the volume '%s' belongs to the stack '%s'", pvc.Name, old.Labels[okLabels.StackNameLabel])
}
if err := volumes.Update(ctx, &pvc, c); err != nil {
return fmt.Errorf("error updating volume of service '%s': %s", pvc.Name, err.Error())
if !volumes.IsEqual(&pvc, old) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we do this in every case? if they are equal, it should do nothing.
Also, can you try that it is possible to change the volume size and the change takes effect in the volume?

@codecov
Copy link

codecov bot commented May 17, 2021

Codecov Report

Merging #1538 (b13d43c) into master (14edbee) will decrease coverage by 0.01%.
The diff coverage is 68.57%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1538      +/-   ##
==========================================
- Coverage   35.99%   35.97%   -0.02%     
==========================================
  Files          88       88              
  Lines        8405     8414       +9     
==========================================
+ Hits         3025     3027       +2     
- Misses       5013     5019       +6     
- Partials      367      368       +1     
Impacted Files Coverage Δ
pkg/cmd/stack/deploy.go 0.00% <0.00%> (ø)
pkg/model/stack_serializer.go 53.80% <85.71%> (-0.03%) ⬇️

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 14edbee...b13d43c. Read the comment docs.

Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>
Signed-off-by: Javier López Barba <javier@okteto.com>

old.Spec.Resources.Requests["storage"] = pvc.Spec.Resources.Requests["storage"]
for key, value := range pvc.Labels {
old.Labels[key] = value
Copy link
Contributor

Choose a reason for hiding this comment

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

should we remove the old labels?

@jLopezbarb jLopezbarb merged commit 1026e05 into master May 18, 2021
@jLopezbarb jLopezbarb deleted the jlopezbarb/fix-update-volume-resources branch May 18, 2021 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants