@@ -31,6 +31,7 @@ type Config struct {
31
31
type UpgradeConfig struct {
32
32
RancherVersion string
33
33
KubernetesVersion string
34
+ RancherOSVersion string
34
35
Force bool
35
36
}
36
37
@@ -45,10 +46,13 @@ func New(cfg Config) *Rancherd {
45
46
}
46
47
47
48
func (r * Rancherd ) Info (ctx context.Context ) error {
48
- rancherVersion , k8sVersion := r .getExistingVersions (ctx )
49
+ rancherVersion , k8sVersion , rancherOSVersion := r .getExistingVersions (ctx )
49
50
50
51
fmt .Printf (" Rancher: %s\n " , rancherVersion )
51
52
fmt .Printf (" Kubernetes: %s\n " , k8sVersion )
53
+ if rancherOSVersion != "" {
54
+ fmt .Printf (" RancherOS: %s\n " , rancherOSVersion )
55
+ }
52
56
fmt .Printf (" Rancherd: %s\n \n " , version .FriendlyVersion ())
53
57
return nil
54
58
}
@@ -69,10 +73,20 @@ func (r *Rancherd) Upgrade(ctx context.Context, upgradeConfig UpgradeConfig) err
69
73
return err
70
74
}
71
75
72
- existingRancherVersion , existingK8sVersion := r .getExistingVersions (ctx )
73
- if existingRancherVersion == rancherVersion && existingK8sVersion == k8sVersion {
76
+ rancherOSVersion , err := versions .RancherOSVersion (upgradeConfig .RancherOSVersion )
77
+ if err != nil {
78
+ return err
79
+ }
80
+
81
+ existingRancherVersion , existingK8sVersion , existingRancherOSVersion := r .getExistingVersions (ctx )
82
+ if existingRancherVersion == rancherVersion &&
83
+ existingK8sVersion == k8sVersion &&
84
+ (existingRancherOSVersion == "" || existingRancherOSVersion == rancherOSVersion ) {
74
85
fmt .Printf ("\n Nothing to upgrade:\n \n " )
75
86
fmt .Printf (" Rancher: %s\n " , rancherVersion )
87
+ if existingRancherOSVersion != "" {
88
+ fmt .Printf (" RancherOS: %s\n " , rancherOSVersion )
89
+ }
76
90
fmt .Printf (" Kubernetes: %s\n \n " , k8sVersion )
77
91
return nil
78
92
}
@@ -83,6 +97,9 @@ func (r *Rancherd) Upgrade(ctx context.Context, upgradeConfig UpgradeConfig) err
83
97
if existingK8sVersion == k8sVersion {
84
98
k8sVersion = ""
85
99
}
100
+ if existingRancherOSVersion == "" || existingRancherOSVersion == rancherOSVersion {
101
+ rancherOSVersion = ""
102
+ }
86
103
87
104
if k8sVersion != "" && existingK8sVersion != "" {
88
105
existingRuntime := config .GetRuntime (existingK8sVersion )
@@ -100,6 +117,9 @@ func (r *Rancherd) Upgrade(ctx context.Context, upgradeConfig UpgradeConfig) err
100
117
if k8sVersion != "" {
101
118
fmt .Printf (" Kubernetes: %s => %s\n " , existingK8sVersion , k8sVersion )
102
119
}
120
+ if rancherOSVersion != "" {
121
+ fmt .Printf (" RancherOS: %s => %s\n " , existingRancherOSVersion , rancherOSVersion )
122
+ }
103
123
104
124
if ! r .cfg .Force {
105
125
go func () {
@@ -114,7 +134,7 @@ func (r *Rancherd) Upgrade(ctx context.Context, upgradeConfig UpgradeConfig) err
114
134
}
115
135
}
116
136
117
- nodePlan , err := plan .Upgrade (& cfg , k8sVersion , rancherVersion , DefaultDataDir )
137
+ nodePlan , err := plan .Upgrade (& cfg , k8sVersion , rancherVersion , rancherOSVersion , DefaultDataDir )
118
138
if err != nil {
119
139
return err
120
140
}
0 commit comments