Skip to content

Commit

Permalink
Merge pull request #2938 from bobbypage/cri-proto
Browse files Browse the repository at this point in the history
Add kubernetes/cri-api to cAdvisor
  • Loading branch information
bobbypage authored Sep 21, 2021
2 parents 90bc378 + 46dedf3 commit a64bbfb
Show file tree
Hide file tree
Showing 18 changed files with 73,348 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ docker-build:
presubmit: vet
@echo ">> checking go formatting"
@./build/check_gofmt.sh
@echo ">> checking CRI definitions"
@./build/check_cri_defs.sh
@echo ">> checking go mod tidy"
@./build/check_gotidy.sh
@echo ">> checking file boilerplate"
Expand Down
2 changes: 1 addition & 1 deletion build/boilerplate/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def file_passes(filename, refs, regexs):
def file_extension(filename):
return os.path.splitext(filename)[1].split(".")[-1].lower()

skipped_dirs = ['Godeps', 'vendor', 'third_party', '_gopath', '_output', '.git']
skipped_dirs = ['Godeps', 'vendor', 'third_party', '_gopath', '_output', '.git', 'cri-api']
def normalize_files(files):
newfiles = []
for pathname in files:
Expand Down
41 changes: 41 additions & 0 deletions build/check_cri_defs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

# Copyright 2021 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Presubmit script that ensures that https://github.com/kubernetes/cri-api
# definitions that are copied into cAdvisor codebase exactly match the ones upstream.

set -e

function check_git_dirty() {
if ! [ -z "$(git status --porcelain)" ]; then
echo ">>> working tree is not clean"
echo ">>> git status:"
echo "$(git status)"
exit 1
fi
}

GIT_ROOT=$(dirname "${BASH_SOURCE}")/..

check_git_dirty

echo ">>> updating k8s CRI definitions..."
"${GIT_ROOT}/build/update_cri_defs.sh"

# If k8s CRI definitions were manually modified or don't match the ones
# upstream, git tree will be unclean.
echo ">>> checking git tree clean after updating k8s CRI definitions..."
check_git_dirty
30 changes: 30 additions & 0 deletions build/update_cri_defs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash

# Copyright 2021 Google Inc. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

CRI_VERSION="release-1.22"
GIT_ROOT=$(dirname "${BASH_SOURCE}")/..

TMP_DIR="$(mktemp -d)"
git clone --depth=1 https://github.com/kubernetes/cri-api.git --branch="${CRI_VERSION}" "${TMP_DIR}"

# rewrite import paths
find "${TMP_DIR}" -type f -name "*.go" -exec sed -i 's:k8s.io/cri-api:github.com/google/cadvisor/cri-api:g' {} +

mkdir -p "${GIT_ROOT}/cri-api"
cp -r "${TMP_DIR}/pkg" "${GIT_ROOT}/cri-api"
rm -rf "${TMP_DIR}"
15 changes: 15 additions & 0 deletions cri-api/pkg/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# See the OWNERS docs at https://go.k8s.io/owners

# Disable inheritance as this is owned by sig-node (should mirror same contents as pkg/kubelet/OWNERS)
options:
no_parent_owners: true

approvers:
- sig-node-approvers # see https://github.com/kubernetes/kubernetes/blob/master/OWNERS_ALIASES#LC220:~:text=sig%2Dnode%2Dapprovers

reviewers:
- sig-node-reviewers # see https://github.com/kubernetes/kubernetes/blob/master/OWNERS_ALIASES#LC220:~:text=sig%2Dnode%2Dreviewers

labels:
- area/kubelet
- sig/node
Loading

0 comments on commit a64bbfb

Please sign in to comment.