quota.go 1.6 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 quota
  14. import (
  15. "k8s.io/apimachinery/pkg/api/resource"
  16. utilfeature "k8s.io/apiserver/pkg/util/feature"
  17. "k8s.io/kubernetes/pkg/features"
  18. "k8s.io/kubernetes/pkg/util/mount"
  19. )
  20. // Interface -- quota interface
  21. type Interface interface {
  22. // Does the path provided support quotas, and if so, what types
  23. SupportsQuotas(m mount.Interface, path string) (bool, error)
  24. // Assign a quota (picked by the quota mechanism) to a path,
  25. // and return it.
  26. AssignQuota(m mount.Interface, path string, poduid string, bytes *resource.Quantity) error
  27. // Get the quota-based storage consumption for the path
  28. GetConsumption(path string) (*resource.Quantity, error)
  29. // Get the quota-based inode consumption for the path
  30. GetInodes(path string) (*resource.Quantity, error)
  31. // Remove the quota from a path
  32. // Implementations may assume that any data covered by the
  33. // quota has already been removed.
  34. ClearQuota(m mount.Interface, path string, poduid string) error
  35. }
  36. func enabledQuotasForMonitoring() bool {
  37. return utilfeature.DefaultFeatureGate.Enabled(features.LocalStorageCapacityIsolationFSQuotaMonitoring)
  38. }