Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Set rancher.environment.KERNEL_VERSION from /proc/version
Browse files Browse the repository at this point in the history
Signed-off-by: Sven Dowideit <SvenDowideit@home.org.au>
  • Loading branch information
SvenDowideit committed Nov 29, 2016
1 parent 4cd20d2 commit 0ac5a2d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
9 changes: 9 additions & 0 deletions docker/env.go
Expand Up @@ -2,10 +2,13 @@ package docker

import (
"fmt"
"io/ioutil"
"strings"

composeConfig "github.com/docker/libcompose/config"
"github.com/rancher/os/config"

log "github.com/Sirupsen/logrus"
)

type ConfigEnvironment struct {
Expand Down Expand Up @@ -41,6 +44,12 @@ func environmentFromCloudConfig(cfg *config.CloudConfig) map[string]string {
environment["no_proxy"] = cfg.Rancher.Network.NoProxy
environment["NO_PROXY"] = cfg.Rancher.Network.NoProxy
}
b, err := ioutil.ReadFile("/proc/version")
if err == nil {
elem := strings.Split(string(b), " ")
environment["KERNEL_VERSION"] = elem[2]
log.Debugf("Using /proc/version to set rancher.environment.KERNEL_VERSION = %s", elem[2])
}
return environment
}

Expand Down
2 changes: 1 addition & 1 deletion tests/assets/test_22/cloud-config.yml
@@ -1,6 +1,6 @@
#cloud-config
rancher:
services_include:
kernel-headers-4.8.10-rancher: true
kernel-headers: true
ssh_authorized_keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC85w9stZyiLQp/DkVO6fqwiShYcj1ClKdtCqgHtf+PLpJkFReSFu8y21y+ev09gsSMRRrjF7yt0pUHV6zncQhVeqsZtgc5WbELY2DOYUGmRn/CCvPbXovoBrQjSorqlBmpuPwsStYLr92Xn+VVsMNSUIegHY22DphGbDKG85vrKB8HxUxGIDxFBds/uE8FhSy+xsoyT/jUZDK6pgq2HnGl6D81ViIlKecpOpWlW3B+fea99ADNyZNVvDzbHE5pcI3VRw8u59WmpWOUgT6qacNVACl8GqpBvQk8sw7O/X9DSZHCKafeD9G5k+GYbAUz92fKWrx/lOXfUXPS3+c8dRIF
2 changes: 1 addition & 1 deletion tests/kernel_headers_test.go
Expand Up @@ -7,5 +7,5 @@ func (s *QemuSuite) TestKernelHeaders(c *C) {

s.CheckCall(c, `
sleep 15
docker inspect kernel-headers-$(uname -r)`)
docker inspect kernel-headers`)
}

0 comments on commit 0ac5a2d

Please sign in to comment.