-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For the v2 hcs code paths it seems the only time a time zone is set is if a new field on the guest connection settings is present (which we don't have) while using the internal guest connection (shim -> hcs -> gcs). Otherwise the guest is just left without a time zone set, so things like tzutil or the get-timezone powershell cmdlet will return an invalid time zone set. We swapped to always using the external guest connection we maintain in the shim so we need to set a time zone explicitly. This change issues a request to the gcs to set a timezone via the same method that hcs uses internally. It sets the guests time zone to whatever is present on the host which is the docker behavior, and then all containers in the vm should inherit this. Additionally expose an option to override this behavior and just set the time zone to GMT. If the container wants to change its timezone to something else, it is free to on supported images. See https://docs.microsoft.com/en-us/virtualization/windowscontainers/manage-containers/virtual-time-zone Signed-off-by: Daniel Canter <dcanter@microsoft.com>
- Loading branch information
Showing
28 changed files
with
1,173 additions
and
575 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* HCS API | ||
* | ||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
* | ||
* API version: 2.1 | ||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
*/ | ||
|
||
package hcsschema | ||
|
||
type SystemTime struct { | ||
Year int32 `json:"Year,omitempty"` | ||
|
||
Month int32 `json:"Month,omitempty"` | ||
|
||
DayOfWeek int32 `json:"DayOfWeek,omitempty"` | ||
|
||
Day int32 `json:"Day,omitempty"` | ||
|
||
Hour int32 `json:"Hour,omitempty"` | ||
|
||
Minute int32 `json:"Minute,omitempty"` | ||
|
||
Second int32 `json:"Second,omitempty"` | ||
|
||
Milliseconds int32 `json:"Milliseconds,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* HCS API | ||
* | ||
* No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) | ||
* | ||
* API version: 2.1 | ||
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git) | ||
*/ | ||
|
||
package hcsschema | ||
|
||
type TimeZoneInformation struct { | ||
Bias int32 `json:"Bias,omitempty"` | ||
|
||
StandardName string `json:"StandardName,omitempty"` | ||
|
||
StandardDate *SystemTime `json:"StandardDate,omitempty"` | ||
|
||
StandardBias int32 `json:"StandardBias,omitempty"` | ||
|
||
DaylightName string `json:"DaylightName,omitempty"` | ||
|
||
DaylightDate *SystemTime `json:"DaylightDate,omitempty"` | ||
|
||
DaylightBias int32 `json:"DaylightBias,omitempty"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package uvm | ||
|
||
import ( | ||
"fmt" | ||
|
||
hcsschema "github.com/Microsoft/hcsshim/internal/hcs/schema2" | ||
"golang.org/x/sys/windows" | ||
) | ||
|
||
// UTC has everything set to 0's. Just need to fill in the pointer fields and string identifiers. | ||
var utcTimezone = &hcsschema.TimeZoneInformation{ | ||
StandardName: "Coordinated Universal Time", | ||
DaylightName: "Coordinated Universal Time", | ||
StandardDate: &hcsschema.SystemTime{}, | ||
DaylightDate: &hcsschema.SystemTime{}, | ||
} | ||
|
||
// getTimezone returns the hosts timezone in an HCS TimeZoneInformation structure and an error if there | ||
// is one. | ||
func getTimezone() (*hcsschema.TimeZoneInformation, error) { | ||
var tz windows.Timezoneinformation | ||
_, err := windows.GetTimeZoneInformation(&tz) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to get time zone information: %w", err) | ||
} | ||
return tziToHCSSchema(&tz), nil | ||
} | ||
|
||
// TZIToHCSSchema converts a windows.TimeZoneInformation (TIME_ZONE_INFORMATION) to the hcs schema equivalent. | ||
func tziToHCSSchema(tzi *windows.Timezoneinformation) *hcsschema.TimeZoneInformation { | ||
return &hcsschema.TimeZoneInformation{ | ||
Bias: tzi.Bias, | ||
StandardName: windows.UTF16ToString(tzi.StandardName[:]), | ||
StandardDate: &hcsschema.SystemTime{ | ||
Year: int32(tzi.StandardDate.Year), | ||
Month: int32(tzi.StandardDate.Month), | ||
DayOfWeek: int32(tzi.StandardDate.DayOfWeek), | ||
Day: int32(tzi.StandardDate.Day), | ||
Hour: int32(tzi.StandardDate.Hour), | ||
Second: int32(tzi.StandardDate.Second), | ||
Minute: int32(tzi.StandardDate.Minute), | ||
Milliseconds: int32(tzi.StandardDate.Milliseconds), | ||
}, | ||
StandardBias: tzi.StandardBias, | ||
DaylightName: windows.UTF16ToString(tzi.DaylightName[:]), | ||
DaylightDate: &hcsschema.SystemTime{ | ||
Year: int32(tzi.DaylightDate.Year), | ||
Month: int32(tzi.DaylightDate.Month), | ||
DayOfWeek: int32(tzi.DaylightDate.DayOfWeek), | ||
Day: int32(tzi.DaylightDate.Day), | ||
Hour: int32(tzi.DaylightDate.Hour), | ||
Second: int32(tzi.DaylightDate.Second), | ||
Minute: int32(tzi.DaylightDate.Minute), | ||
Milliseconds: int32(tzi.DaylightDate.Milliseconds), | ||
}, | ||
DaylightBias: tzi.DaylightBias, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.