@@ -142,36 +142,38 @@ func (ign *DynamicIgnition) GenerateIgnitionConfig() error {
142
142
143
143
// Add or set the time zone for the machine
144
144
if len (ign .TimeZone ) > 0 {
145
- var (
146
- err error
147
- tz string
148
- )
145
+ var err error
146
+ tz := ign .TimeZone
149
147
// local means the same as the host
150
148
// look up where it is pointing to on the host
151
149
if ign .TimeZone == "local" {
152
150
tz , err = getLocalTimeZone ()
153
151
if err != nil {
154
152
return fmt .Errorf ("error getting local timezone: %q" , err )
155
153
}
156
- } else {
157
- tz = ign .TimeZone
158
154
}
159
- tzLink := Link {
160
- Node : Node {
161
- Group : GetNodeGrp ("root" ),
162
- Path : "/etc/localtime" ,
163
- Overwrite : BoolToPtr (false ),
164
- User : GetNodeUsr ("root" ),
165
- },
166
- LinkEmbedded1 : LinkEmbedded1 {
167
- Hard : BoolToPtr (false ),
168
- // We always want this value in unix form (/path/to/something) because this is being
169
- // set in the machine OS (always Linux). However, filepath.join on windows will use a "\\"
170
- // separator; therefore we use ToSlash to convert the path to unix style
171
- Target : filepath .ToSlash (filepath .Join ("/usr/share/zoneinfo" , tz )),
172
- },
155
+ // getLocalTimeZone() can return empty string, do not add broken symlink in that case
156
+ // coreos will default to UTC
157
+ if tz == "" {
158
+ logrus .Info ("Unable to determine local timezone, machine will default to UTC" )
159
+ } else {
160
+ tzLink := Link {
161
+ Node : Node {
162
+ Group : GetNodeGrp ("root" ),
163
+ Path : "/etc/localtime" ,
164
+ Overwrite : BoolToPtr (false ),
165
+ User : GetNodeUsr ("root" ),
166
+ },
167
+ LinkEmbedded1 : LinkEmbedded1 {
168
+ Hard : BoolToPtr (false ),
169
+ // We always want this value in unix form (/path/to/something) because this is being
170
+ // set in the machine OS (always Linux). However, filepath.join on windows will use a "\\"
171
+ // separator; therefore we use ToSlash to convert the path to unix style
172
+ Target : filepath .ToSlash (filepath .Join ("/usr/share/zoneinfo" , tz )),
173
+ },
174
+ }
175
+ ignStorage .Links = append (ignStorage .Links , tzLink )
173
176
}
174
- ignStorage .Links = append (ignStorage .Links , tzLink )
175
177
}
176
178
177
179
// This service gets environment variables that are provided
0 commit comments