github.com/coreos/mantle@v0.13.0/kola/tests/kubernetes/kubelet_wrapper.go (about)

     1  // Copyright 2017 CoreOS, Inc.
     2  //
     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  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package kubernetes
    16  
    17  import (
    18  	"github.com/coreos/mantle/kola/cluster"
    19  	"github.com/coreos/mantle/kola/register"
    20  	"github.com/coreos/mantle/platform/conf"
    21  )
    22  
    23  const hyperkubeTag = "v1.9.2_coreos.0"
    24  const versionOutput = "Kubernetes v1.9.2+coreos.0" // --version for /hyperkube
    25  
    26  func init() {
    27  	// regression test for https://github.com/coreos/bugs/issues/1892
    28  	register.Register(&register.Test{
    29  		Name:        "kubernetes.kubelet_wrapper.var-log-mount",
    30  		Run:         testKubeletWrapperVarLog,
    31  		ClusterSize: 1,
    32  		UserData: conf.ContainerLinuxConfig(`
    33  systemd:
    34    units:
    35    - name: kubelet.service
    36      enable: true
    37      contents: |-
    38        [Service]
    39        Type=oneshot
    40        Environment=KUBELET_IMAGE_TAG=` + hyperkubeTag + `
    41        # var-log and resolv were at various times either in the kubelet-wrapper
    42        # docs or recommended to people
    43        Environment="RKT_RUN_ARGS=--volume var-log,kind=host,source=/var/log \
    44          --mount volume=var-log,target=/var/log \
    45          --volume resolv,kind=host,source=/etc/resolv.conf \
    46          --mount volume=resolv,target=/etc/resolv.conf"
    47  
    48        # The regression was in rkt's handling of RKT_OPTS; if we get far enough
    49        # that rkt runs the kubelet successfully, we haven't hit this regression,
    50        # so just printing the version is enough.
    51        ExecStart=/usr/lib/coreos/kubelet-wrapper --version
    52        [Install]
    53        WantedBy=multi-user.target
    54  `),
    55  		Flags:   []register.Flag{register.RequiresInternetAccess}, // network access for hyperkube
    56  		Distros: []string{"cl"},
    57  	})
    58  }
    59  
    60  func testKubeletWrapperVarLog(c cluster.TestCluster) {
    61  	m := c.Machines()[0]
    62  
    63  	// Wait up to 10 minutes the version
    64  	c.MustSSH(m, `
    65  	for i in {1..120}; do 
    66  		sleep 5
    67  		if journalctl -t kubelet-wrapper -o cat | grep -F '`+versionOutput+`' &>/dev/null; then
    68  			exit 0
    69  		fi
    70  	done
    71  	journalctl -t kubelet-wrapper -o cat
    72  	exit 1`)
    73  }