github.com/intel/goresctrl@v0.5.0/pkg/blockio/kubernetes.go (about) 1 /* 2 Copyright 2021 Intel Corporation 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package blockio 18 19 import ( 20 "github.com/intel/goresctrl/pkg/kubernetes" 21 ) 22 23 const ( 24 // BlockioContainerAnnotation is the CRI level container annotation for setting 25 // the blockio class of a container 26 BlockioContainerAnnotation = "io.kubernetes.cri.blockio-class" 27 28 // BlockioPodAnnotation is a Pod annotation for setting the blockio class of 29 // all containers of the pod 30 BlockioPodAnnotation = "blockio.resources.beta.kubernetes.io/pod" 31 32 // BlockioPodAnnotationContainerPrefix is prefix for per-container Pod annotation 33 // for setting the blockio class of one container of the pod 34 BlockioPodAnnotationContainerPrefix = "blockio.resources.beta.kubernetes.io/container." 35 ) 36 37 // ContainerClassFromAnnotations determines the effective blockio 38 // class of a container from the Pod annotations and CRI level 39 // container annotations of a container. If the class is not specified 40 // by any annotation, returns empty class name. Returned error is 41 // reserved (nil). 42 func ContainerClassFromAnnotations(containerName string, containerAnnotations, podAnnotations map[string]string) (string, error) { 43 clsName, _ := kubernetes.ContainerClassFromAnnotations( 44 BlockioContainerAnnotation, BlockioPodAnnotation, BlockioPodAnnotationContainerPrefix, 45 containerName, containerAnnotations, podAnnotations) 46 return clsName, nil 47 }