Skip to content

Commit

Permalink
Modify update staging policy to support day granularity instead of week
Browse files Browse the repository at this point in the history
Change the DeviceUpdateStagingPercentOfFleetPerWeek to
DeviceUpdateStagingSchedule. Change the proto field for this policy to
a string since a JSON needs to be used now that primitives aren't being
used.

BUG=chromium:858621

Change-Id: Ia6ae8d107c9a9f2fd58042c3f9b2f6956abb8306
Reviewed-on: https://chromium-review.googlesource.com/1135830
Commit-Queue: Adolfo Higueros <adokar@google.com>
Reviewed-by: Maksim Ivanov <emaxx@chromium.org>
Reviewed-by: Lutz Justen <ljusten@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579512}
  • Loading branch information
Adolfo Victoria authored and Commit Bot committed Jul 31, 2018
1 parent f0a8a70 commit f81466d
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 35 deletions.
31 changes: 10 additions & 21 deletions chrome/browser/chromeos/policy/device_policy_decoder_chromeos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -685,27 +685,16 @@ void DecodeAutoUpdatePolicies(const em::ChromeDeviceSettingsProto& policy,
}
}

if (container.staging_percent_of_fleet_per_week_size()) {
auto staging_percent_of_fleet_per_week_policy =
std::make_unique<base::ListValue>();

bool error_decoding = false;
for (const auto& entry : container.staging_percent_of_fleet_per_week()) {
std::unique_ptr<base::Value> value = DecodeIntegerValue(entry);
if (value) {
staging_percent_of_fleet_per_week_policy->Append(std::move(value));
} else {
error_decoding = true;
LOG(ERROR)
<< "Could not decode integer value for staging percentage.";
break;
}
}
if (!error_decoding) {
policies->Set(
key::kDeviceUpdateStagingPercentOfFleetPerWeek,
POLICY_LEVEL_MANDATORY, POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
std::move(staging_percent_of_fleet_per_week_policy), nullptr);
if (container.has_staging_schedule()) {
std::unique_ptr<base::Value> staging_percent_of_fleet_per_week_policy =
DecodeJsonStringAndDropUnknownBySchema(
container.staging_schedule(), key::kDeviceUpdateStagingSchedule);

if (staging_percent_of_fleet_per_week_policy) {
policies->Set(key::kDeviceUpdateStagingSchedule, POLICY_LEVEL_MANDATORY,
POLICY_SCOPE_MACHINE, POLICY_SOURCE_CLOUD,
std::move(staging_percent_of_fleet_per_week_policy),
nullptr);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/test/data/policy/policy_test_cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -3823,7 +3823,7 @@
"test_policy": {"UpdateTimeRestrictions": [{"start" : {"day_of_week" : "Wednesday", "minutes": 30, "hours": 3}, "end": {"day_of_week" : "Thursday", "minutes": 20, "hours": 13}}, {"start": {"day_of_week": "Monday", "minutes": 45, "hours": 1}, "end": {"day_of_week": "Monday", "minutes": 50, "hours": 15}}]}
},

"DeviceUpdateStagingPercentOfFleetPerWeek": {
"DeviceUpdateStagingSchedule": {
"os": ["chromeos"],
"note": "Chrome OS device policy used by update_engine only, not used in Chrome."
},
Expand Down
13 changes: 7 additions & 6 deletions components/policy/proto/chrome_device_policy.proto
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ message OBSOLETE_ScreenSaverProto {

// Enterprise controls for auto-update behavior of Chrome OS.
message AutoUpdateSettingsProto {
reserved 13;

// True if we don't want the device to auto-update (target_version_prefix is
// ignored in this case).
optional bool update_disabled = 1;
Expand Down Expand Up @@ -268,12 +270,11 @@ message AutoUpdateSettingsProto {
// "DeviceAutoUpdateTimeRestrictions" in policy_templates.json.
optional string disallowed_time_intervals = 12;

// Specifies the percent of the fleet to update per week. Each week is
// represented by an int in the list. For example, a list with values
// [5,20,100] means: by the end of week 1, 5% of devices should be updated. By
// the end of week 2, 20% of devices should be updated. By the end of week 3,
// 100% of devices should be updated.
repeated int32 staging_percent_of_fleet_per_week = 13;
// Specifies how much of the fleet to update per day as a json
// string that contains a list of pairs <day, percentage>. For more
// details and examples, see "DeviceUpdateStagingSchedule" in
// policy_templates.json.
optional string staging_schedule = 14;
}

message OBSOLETE_StartUpUrlsProto {
Expand Down
30 changes: 24 additions & 6 deletions components/policy/resources/policy_templates.json
Original file line number Diff line number Diff line change
Expand Up @@ -12482,24 +12482,42 @@
'''
},
{
'name': 'DeviceUpdateStagingPercentOfFleetPerWeek',
'type': 'list',
'name': 'DeviceUpdateStagingSchedule',
'type': 'dict',
'schema': {
'type': 'array',
'items': { 'type': 'integer' },
'items': {
'type': 'object',
'description': 'Contains the number of days and the percentage of the fleet that should be updated after those days have passed.',
'id': 'DayPercentagePair',
'properties': {
'days': {
'description': 'Days from update discovery.',
'type': 'integer',
'minimum': 1,
'maximum': 28,
},
'percentage': {
'description': 'Percentage of the fleet that should be updated after the given days.',
'type': 'integer',
'minimum': 0,
'maximum': 100,
}
}
},
},
'supported_on': ['chrome_os:69-'],
'device_only': True,
'features': {
'dynamic_refresh': True,
},
'example_value': [ 0, 20, 100 ],
'example_value': [{'days': 7, 'percentage': 50}, {'days': 10, 'percentage': 100}],
'id': 458,
'caption': '''The staging schedule for applying a new update''',
'tags': ['system-security'],
'desc': '''This policy defines a list of percentages that will define the fraction of <ph name="PRODUCT_OS_NAME">$2<ex>Google Chrome OS</ex></ph> devices in the OU to update per week starting from the day the update is first discovered. The discovery time is later than the update published time, since it could be a while after the update publishing until the device checks for updates.
'desc': '''This policy defines a list of percentages that will define the fraction of <ph name="PRODUCT_OS_NAME">$2<ex>Google Chrome OS</ex></ph> devices in the OU to update per day starting from the day the update is first discovered. The discovery time is later than the update published time, since it could be a while after the update publishing until the device checks for updates.

The n-th value in the list will be used as the percentage of devices that should complete updating to the next version in the n-th week after the update has been discovered. For example, if an update is discovered today, then the first value in the list defines the percentage of devices in the OU that should update to that version by a week from today. The second value defines the percentage of devices in the OU that should update to that version by 2 weeks from today, and so on.
Each (day, percentage) pair contains which percentage of the fleet has to be updated by the given number of days since the update has been discovered. For example, if we have the pairs [(4, 40), (10, 70), (15, 100)], then 40% of the fleet should have been updated 4 days after seeing the update. 70% should be updated after 10 days, and so on.

If there is a value defined for this policy, updates will ignore the <ph name="DEVICE_UPDATE_SCATTER_FACTOR_POLICY_NAME">DeviceUpdateScatterFactor</ph> policy and follow this policy instead.

Expand Down
2 changes: 1 addition & 1 deletion tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13901,7 +13901,7 @@ Called by update_net_error_codes.py.-->
<int value="455" label="SafeSitesFilterBehavior"/>
<int value="456" label="AllowedInputMethods"/>
<int value="457" label="OverrideSecurityRestrictionsOnInsecureOrigin"/>
<int value="458" label="DeviceUpdateStagingPercentOfFleetPerWeek"/>
<int value="458" label="DeviceUpdateStagingSchedule"/>
<int value="459" label="AutofillAddressEnabled"/>
<int value="460" label="TabLifecyclesEnabled"/>
<int value="461" label="UrlKeyedAnonymizedDataCollectionEnabled"/>
Expand Down

0 comments on commit f81466d

Please sign in to comment.