expander-defaults.go 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. Copyright 2018 The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package flexvolume
  14. import (
  15. "k8s.io/apimachinery/pkg/api/resource"
  16. "k8s.io/klog"
  17. "k8s.io/kubernetes/pkg/volume"
  18. "k8s.io/kubernetes/pkg/volume/util"
  19. )
  20. type expanderDefaults struct {
  21. plugin *flexVolumePlugin
  22. }
  23. func newExpanderDefaults(plugin *flexVolumePlugin) *expanderDefaults {
  24. return &expanderDefaults{plugin}
  25. }
  26. func (e *expanderDefaults) ExpandVolumeDevice(spec *volume.Spec, newSize resource.Quantity, oldSize resource.Quantity) (resource.Quantity, error) {
  27. klog.Warning(logPrefix(e.plugin), "using default expand for volume ", spec.Name(), ", to size ", newSize, " from ", oldSize)
  28. return newSize, nil
  29. }
  30. // the defaults for NodeExpand return a generic resize indicator that will trigger the operation executor to go ahead with
  31. // generic filesystem resize
  32. func (e *expanderDefaults) NodeExpand(rsOpt volume.NodeResizeOptions) (bool, error) {
  33. klog.Warning(logPrefix(e.plugin), "using default filesystem resize for volume ", rsOpt.VolumeSpec.Name(), ", at ", rsOpt.DevicePath)
  34. _, err := util.GenericResizeFS(e.plugin.host, e.plugin.GetPluginName(), rsOpt.DevicePath, rsOpt.DeviceMountPath)
  35. if err != nil {
  36. return false, err
  37. }
  38. return true, nil
  39. }