mirror of
https://github.com/rancher/os.git
synced 2025-09-13 13:39:53 +00:00
Embed subscriber service
This commit is contained in:
@@ -101,7 +101,8 @@ var schema = `{
|
|||||||
"properties": {
|
"properties": {
|
||||||
"url": {"type": "string"},
|
"url": {"type": "string"},
|
||||||
"image": {"type": "string"},
|
"image": {"type": "string"},
|
||||||
"rollback": {"type": "string"}
|
"rollback": {"type": "string"},
|
||||||
|
"policy": {"type": "string"}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -158,6 +158,7 @@ type UpgradeConfig struct {
|
|||||||
URL string `yaml:"url,omitempty"`
|
URL string `yaml:"url,omitempty"`
|
||||||
Image string `yaml:"image,omitempty"`
|
Image string `yaml:"image,omitempty"`
|
||||||
Rollback string `yaml:"rollback,omitempty"`
|
Rollback string `yaml:"rollback,omitempty"`
|
||||||
|
Policy string `yaml:"policy,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type EngineOpts struct {
|
type EngineOpts struct {
|
||||||
|
58
images/01-base/usr/bin/os-subscriber
Executable file
58
images/01-base/usr/bin/os-subscriber
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e -x
|
||||||
|
|
||||||
|
gateway_address="http://ros.rancher.io/gateway"
|
||||||
|
|
||||||
|
_sigProcess() {
|
||||||
|
echo "SIGINT/SIGTERM signal..."
|
||||||
|
kill -9 $$
|
||||||
|
}
|
||||||
|
|
||||||
|
trap _sigProcess SIGINT SIGKILL SIGTERM
|
||||||
|
|
||||||
|
__read_policy() {
|
||||||
|
policy=`ros c get rancher.upgrade.policy`
|
||||||
|
if [ -z $policy ]; then
|
||||||
|
echo "can not read upgrade.policy"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
return $(($policy))
|
||||||
|
}
|
||||||
|
|
||||||
|
__report_activity() {
|
||||||
|
arch=`uname -m`
|
||||||
|
uuid=`cat /sys/class/dmi/id/product_uuid`
|
||||||
|
release=`ros -v | awk '{print $2}'`
|
||||||
|
response=`wget --server-response ${gateway_address}/report --header 'Accept: application/json' --header 'Content-type: application/json' --header "arch: $arch" --header "uuid: $uuid" --header "release: $release" 2>&1 | awk '/^ HTTP/{print $2}'`
|
||||||
|
if [ $response -ge 200 -a $response -le 300 ]; then
|
||||||
|
echo "report activity success"
|
||||||
|
else
|
||||||
|
echo "report activity failed"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
__upgrade_operate() {
|
||||||
|
recommend_version=`wget ${gateway_address}/version -q -O -`
|
||||||
|
case $policy in
|
||||||
|
download)
|
||||||
|
echo "upgrade.policy is 'download'"
|
||||||
|
__report_activity
|
||||||
|
system-docker pull $recommend_version
|
||||||
|
;;
|
||||||
|
auto)
|
||||||
|
echo "upgrade.policy is 'auto'"
|
||||||
|
__report_activity
|
||||||
|
ros os upgrade -i $recommend_version -f
|
||||||
|
;;
|
||||||
|
none)
|
||||||
|
echo "upgrade.policy is 'none'"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "upgrade.policy is 'illegal'"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
__read_policy
|
||||||
|
|
||||||
|
__upgrade_operate
|
@@ -381,6 +381,25 @@ rancher:
|
|||||||
volumes:
|
volumes:
|
||||||
- /sys:/host/sys
|
- /sys:/host/sys
|
||||||
- /var/lib/system-docker:/var/lib/system-docker:shared
|
- /var/lib/system-docker:/var/lib/system-docker:shared
|
||||||
|
subscriber:
|
||||||
|
image: {{.OS_REPO}}/os-base:{{.VERSION}}{{.SUFFIX}}
|
||||||
|
command: os-subscriber
|
||||||
|
environment:
|
||||||
|
- IN_DOCKER=true
|
||||||
|
labels:
|
||||||
|
io.rancher.os.scope: system
|
||||||
|
io.rancher.os.after: console
|
||||||
|
cron.schedule: "0 0 3 * * ?"
|
||||||
|
privileged: true
|
||||||
|
pid: host
|
||||||
|
ipc: host
|
||||||
|
net: host
|
||||||
|
uts: host
|
||||||
|
volumes_from:
|
||||||
|
- command-volumes
|
||||||
|
- system-volumes
|
||||||
|
volumes:
|
||||||
|
- /sys:/host/sys
|
||||||
system_docker:
|
system_docker:
|
||||||
exec: true
|
exec: true
|
||||||
storage_driver: overlay2
|
storage_driver: overlay2
|
||||||
@@ -399,6 +418,7 @@ rancher:
|
|||||||
upgrade:
|
upgrade:
|
||||||
url: {{.OS_RELEASES_YML}}/releases{{.SUFFIX}}.yml
|
url: {{.OS_RELEASES_YML}}/releases{{.SUFFIX}}.yml
|
||||||
image: {{.OS_REPO}}/os
|
image: {{.OS_REPO}}/os
|
||||||
|
policy: download
|
||||||
docker:
|
docker:
|
||||||
{{if eq "amd64" .ARCH -}}
|
{{if eq "amd64" .ARCH -}}
|
||||||
engine: {{.USER_DOCKER_ENGINE_VERSION}}
|
engine: {{.USER_DOCKER_ENGINE_VERSION}}
|
||||||
|
Reference in New Issue
Block a user