Skip to content

Commit

Permalink
Rename reboot order from priority to be startupOrder (#3274)
Browse files Browse the repository at this point in the history
Rename reboot order from `priority` to be `startupOrder`
  • Loading branch information
yophilav authored Jul 31, 2020
1 parent 9953ca8 commit eed9c06
Show file tree
Hide file tree
Showing 27 changed files with 107 additions and 107 deletions.
22 changes: 11 additions & 11 deletions doc/ModuleStartupOrder.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

By default, IoT Edge does not impose an ordering in the sequence in which modules are started, updated or stopped. Edge Agent by default is the first module that gets started and based on the edge deployment specification, it figures out which modules need to be started, updated or stopped and executes those operations in a non-deterministic order.

The processing order of modules can be controlled by specifying the value of a module-specific property called `priority` in the IoT Edge deployment. Modules that have been assigned a higher priority will be processed before modules that have been assigned a lower priority.
The processing order of modules can be controlled by specifying the value of a module-specific property called `startupOrder` in the IoT Edge deployment. Modules that have been assigned a higher priority will be processed before modules that have been assigned a lower priority.

This comment has been minimized.

Copy link
@ManuInNZ

ManuInNZ Aug 27, 2020

The end sentence would benefit rewording to align to the change to startUp. e.g.
Modules that have been assigned a higher startupOrder value will be processed before modules that have been assigned a lower one.


## __Use case__

Expand All @@ -14,15 +14,15 @@ As an example, some customers want the Edge Hub module to be started before any

## __Configuration__

Customers can optionally specify a `priority` value for each module in their IoT Edge deployment to achieve module boot ordering. Modules with a higher priority will be created and started first and only when an attempt has been made to start them, will other lower priority modules be created and started.
Customers can optionally specify a `startupOrder` value for each module in their IoT Edge deployment to achieve module boot ordering. Modules with a higher priority will be created and started first and only when an attempt has been made to start them, will other lower priority modules be created and started.

The value of `priority` will be positive and zero-based with 0 being the highest priority value.
A higher numeric `priority` value would indicate a lower priority assigned to that module. The maximum value of this property will be 4294967295.
The value of `startupOrder` will be positive and zero-based with 0 being the highest priority value.
A higher numeric `startupOrder` value would indicate a lower priority assigned to that module. The maximum value of this property will be 4294967295.
Modules that possess the same priority will be created at the same time and will have no deterministic startup order imposed amongst themselves. Modules with higher priority values will be created and started first and once Edge Agent has made an attempt to create and start them (only the modules with a desired state of `Running` will be started), it will proceed with the creation (and optionally startup) of other lower priority modules in order.

**It must be noted that the Edge Agent module will not support the `priority` property and will by default have the highest priority. As is the behavior currently, Edge Agent will always be the first module to get started.**
**It must be noted that the Edge Agent module will not support the `startupOrder` property and will by default have the highest priority. As is the behavior currently, Edge Agent will always be the first module to get started.**

Modules that do not have a `priority` value specified will be started in a non-deterministic order and will be assigned a priority of 4294967295 which indicates the lowest possible priority. Edge Agent will trigger the creation of these modules after all modules with a higher priority have been created.
Modules that do not have a `startupOrder` value specified will be started in a non-deterministic order and will be assigned a priority of 4294967295 which indicates the lowest possible priority. Edge Agent will trigger the creation of these modules after all modules with a higher priority have been created.

**Please note that Kubernetes mode of IoT Edge does not support module startup order priorities.**

Expand Down Expand Up @@ -72,7 +72,7 @@ The following sample deployment manifest illustrates how priority values of modu
"image": "mcr.microsoft.com/azureiotedge-hub:1.0",
"createOptions": ""
},
"priority": 0
"startupOrder": 0
}
},
"modules": {
Expand All @@ -85,7 +85,7 @@ The following sample deployment manifest illustrates how priority values of modu
"image": "mcr.microsoft.com/azureiotedge-simulated-temperature-sensor:1.0",
"createOptions": "{}"
},
"priority": 1
"startupOrder": 1
},
"filtermodule": {
"version": "1.0",
Expand Down Expand Up @@ -118,9 +118,9 @@ The following sample deployment manifest illustrates how priority values of modu

In the sample deployment manifest shown above:

* The `$edgeHub` module has been assigned a `priority` value of 0.
* The `SimulatedTemperatureSensor` module has been assigned a `priority` value of 1.
* The `filtermodule` module has not been assigned any `priority` value which means that it will by default assume the priority of 4294967295 which is the lowest priority value possible.
* The `$edgeHub` module has been assigned a `startupOrder` value of 0.
* The `SimulatedTemperatureSensor` module has been assigned a `startupOrder` value of 1.
* The `filtermodule` module has not been assigned any `startupOrder` value which means that it will by default assume the priority of 4294967295 which is the lowest priority value possible.

When this deployment manifest is deployed to a device that does not have any modules running, `$edgeHub` is the first module that will come up followed by the `SimulatedTemperatureSensor` module and then the `filtermodule`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ public interface IModule : IEquatable<IModule>
[JsonProperty(PropertyName = "imagePullPolicy")]
ImagePullPolicy ImagePullPolicy { get; }

[JsonProperty(PropertyName = "priority")]
uint Priority { get; }
[JsonProperty(PropertyName = "startupOrder")]
uint StartupOrder { get; }

[JsonIgnore]
ConfigurationInfo ConfigurationInfo { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public virtual string Name

public virtual ImagePullPolicy ImagePullPolicy => ImagePullPolicy.OnCreate;

public virtual uint Priority => Constants.DefaultPriority;
public virtual uint StartupOrder => Constants.DefaultPriority;

public virtual ConfigurationInfo ConfigurationInfo => new ConfigurationInfo();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ public async Task<Plan> PlanAsync(
// We want to process all the modules in the deployment (desired modules) and also include the modules
// that are not specified in the deployment but are currently running on the device. This is so that
// their processing is done in the right priority order.
ILookup<uint, KeyValuePair<string, IModule>> desiredPriorityGroups = desired.Modules.ToLookup(x => x.Value.Priority);
ILookup<uint, KeyValuePair<string, IModule>> currentPriorityGroups = current.Modules.ToLookup(x => x.Value.Priority);
ILookup<uint, KeyValuePair<string, IModule>> desiredPriorityGroups = desired.Modules.ToLookup(x => x.Value.StartupOrder);
ILookup<uint, KeyValuePair<string, IModule>> currentPriorityGroups = current.Modules.ToLookup(x => x.Value.StartupOrder);
ImmutableSortedSet<uint> orderedPriorities = desiredPriorityGroups.Select(x => x.Key).Union(currentPriorityGroups.Select(x => x.Key)).ToImmutableSortedSet();
var processedDesiredMatchingCurrentModules = new HashSet<string>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ async Task<Plan> CreatePlan(ModuleSet desired, ModuleSet current, IRuntimeInfo r
// We want to process all the modules in the deployment (desired modules) and also include the modules
// that are not specified in the deployment but are currently running on the device. This is so that
// their processing is done in the right priority order.
ILookup<uint, KeyValuePair<string, IModule>> desiredPriorityGroups = desired.Modules.ToLookup(x => x.Value.Priority);
ILookup<uint, KeyValuePair<string, IModule>> currentPriorityGroups = current.Modules.ToLookup(x => x.Value.Priority);
ILookup<uint, KeyValuePair<string, IModule>> desiredPriorityGroups = desired.Modules.ToLookup(x => x.Value.StartupOrder);
ILookup<uint, KeyValuePair<string, IModule>> currentPriorityGroups = current.Modules.ToLookup(x => x.Value.StartupOrder);
ImmutableSortedSet<uint> orderedPriorities = desiredPriorityGroups.Select(x => x.Key).Union(currentPriorityGroups.Select(x => x.Key)).ToImmutableSortedSet();
var processedDesiredMatchingCurrentModules = new HashSet<string>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public async Task<ModuleSet> GetModulesAsync(CancellationToken token)
moduleState.LastRestartTimeUtc,
moduleRuntimeStatus,
dockerModule.ImagePullPolicy,
dockerModule.Priority,
dockerModule.StartupOrder,
dockerModule.ConfigurationInfo,
dockerModule.Env);
break;
Expand Down Expand Up @@ -130,7 +130,7 @@ public async Task<ModuleSet> GetModulesAsync(CancellationToken token)
moduleState.LastRestartTimeUtc,
moduleRuntimeStatus,
dockerModule.ImagePullPolicy,
dockerModule.Priority,
dockerModule.StartupOrder,
dockerModule.ConfigurationInfo,
dockerModule.Env);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public DockerModule(
RestartPolicy restartPolicy,
DockerConfig config,
ImagePullPolicy imagePullPolicy,
uint priority,
uint startupOrder,
ConfigurationInfo configurationInfo,
IDictionary<string, EnvVal> env)
{
Expand All @@ -29,7 +29,7 @@ public DockerModule(
this.Config = Preconditions.CheckNotNull(config, nameof(config));
this.RestartPolicy = Preconditions.CheckIsDefined(restartPolicy);
this.ImagePullPolicy = Preconditions.CheckIsDefined(imagePullPolicy);
this.Priority = priority;
this.StartupOrder = startupOrder;
this.ConfigurationInfo = configurationInfo ?? new ConfigurationInfo(string.Empty);
this.Env = env?.ToImmutableDictionary() ?? ImmutableDictionary<string, EnvVal>.Empty;
}
Expand All @@ -50,11 +50,11 @@ public DockerModule(
public virtual ImagePullPolicy ImagePullPolicy { get; }

[JsonProperty(
PropertyName = "priority",
PropertyName = "startupOrder",
Required = Required.DisallowNull,
DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
[DefaultValue(Core.Constants.DefaultPriority)]

This comment has been minimized.

Copy link
@micahl

micahl Aug 5, 2020

Contributor

Should the Core.Constants.DefaultPriority be renamed to Core.Constants.DefaultStartupOrder?

public virtual uint Priority { get; }
public virtual uint StartupOrder { get; }

[JsonProperty(Required = Required.Always, PropertyName = "type")]
public virtual string Type => "docker";
Expand Down Expand Up @@ -91,7 +91,7 @@ public virtual bool Equals(IModule<DockerConfig> other)
this.Config.Equals(other.Config) &&
this.RestartPolicy == other.RestartPolicy &&
this.ImagePullPolicy == other.ImagePullPolicy &&
this.Priority == other.Priority &&
this.StartupOrder == other.StartupOrder &&
EnvDictionaryComparer.Equals(this.Env, other.Env);
}

Expand All @@ -105,7 +105,7 @@ public virtual bool IsOnlyModuleStatusChanged(IModule other)
this.Config.Equals(dockerModule.Config) &&
this.RestartPolicy == other.RestartPolicy &&
this.ImagePullPolicy == other.ImagePullPolicy &&
this.Priority == other.Priority &&
this.StartupOrder == other.StartupOrder &&
EnvDictionaryComparer.Equals(this.Env, other.Env);
}

Expand All @@ -124,7 +124,7 @@ public override int GetHashCode()
hashCode = (hashCode * 397) ^ (this.Config != null ? this.Config.GetHashCode() : 0);
hashCode = (hashCode * 397) ^ this.RestartPolicy.GetHashCode();
hashCode = (hashCode * 397) ^ this.ImagePullPolicy.GetHashCode();
hashCode = (hashCode * 397) ^ this.Priority.GetHashCode();
hashCode = (hashCode * 397) ^ this.StartupOrder.GetHashCode();
hashCode = (hashCode * 397) ^ EnvDictionaryComparer.GetHashCode(this.Env);
return hashCode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public DockerRuntimeModule(
DateTime lastRestartTime,
ModuleStatus runtimeStatus,
ImagePullPolicy imagePullPolicy,
uint priority,
uint startupOrder,
ConfigurationInfo configuration,
IDictionary<string, EnvVal> env)
: base(name, version, desiredStatus, restartPolicy, config, imagePullPolicy, priority, configuration, env)
: base(name, version, desiredStatus, restartPolicy, config, imagePullPolicy, startupOrder, configuration, env)
{
this.ExitCode = exitCode;
this.StatusDescription = statusDescription;
Expand All @@ -53,7 +53,7 @@ public DockerRuntimeModule(
DateTime lastRestartTimeUtc,
ModuleStatus runtimeStatus,
ImagePullPolicy imagePullPolicy,
uint priority,
uint startupOrder,
ConfigurationInfo configurationInfo,
IDictionary<string, EnvVal> env)
: this(
Expand All @@ -70,7 +70,7 @@ public DockerRuntimeModule(
lastRestartTimeUtc,
runtimeStatus,
imagePullPolicy,
priority,
startupOrder,
configurationInfo,
env)
{
Expand Down Expand Up @@ -160,7 +160,7 @@ public override int GetHashCode()
this.LastRestartTimeUtc,
newStatus,
this.ImagePullPolicy,
this.Priority,
this.StartupOrder,
this.ConfigurationInfo,
this.Env);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public EdgeHubDockerModule(
RestartPolicy restartPolicy,
DockerConfig settings,
ImagePullPolicy imagePullPolicy,
uint priority,
uint startupOrder,
ConfigurationInfo configuration,
IDictionary<string, EnvVal> env,
string version = "")
: base(Core.Constants.EdgeHubModuleName, version, status, restartPolicy, settings, imagePullPolicy, priority, configuration, env)
: base(Core.Constants.EdgeHubModuleName, version, status, restartPolicy, settings, imagePullPolicy, startupOrder, configuration, env)
{
Preconditions.CheckArgument(type?.Equals("docker") ?? false);
this.DesiredStatus = Preconditions.CheckIsDefined(status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public EdgeHubDockerRuntimeModule(
DateTime lastRestartTime,
ModuleStatus runtimeStatus,
ImagePullPolicy imagePullPolicy,
uint priority,
uint startupOrder,
ConfigurationInfo configuration,
IDictionary<string, EnvVal> env,
string version = "")
Expand All @@ -40,7 +40,7 @@ public EdgeHubDockerRuntimeModule(
lastRestartTime,
runtimeStatus,
imagePullPolicy,
priority,
startupOrder,
configuration,
env)
{
Expand Down Expand Up @@ -68,7 +68,7 @@ public EdgeHubDockerRuntimeModule(
DateTime lastRestartTimeUtc,
ModuleStatus runtimeStatus,
ImagePullPolicy imagePullPolicy,
uint priority,
uint startupOrder,
ConfigurationInfo configurationInfo,
IDictionary<string, EnvVal> env,
string version = "")
Expand All @@ -84,7 +84,7 @@ public EdgeHubDockerRuntimeModule(
lastRestartTimeUtc,
runtimeStatus,
imagePullPolicy,
priority,
startupOrder,
configurationInfo,
env,
version)
Expand Down Expand Up @@ -114,7 +114,7 @@ public EdgeHubDockerRuntimeModule(
this.LastRestartTimeUtc,
newStatus,
this.ImagePullPolicy,
this.Priority,
this.StartupOrder,
this.ConfigurationInfo,
this.Env);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public async Task<ModuleSet> GetModulesAsync(CancellationToken token)
moduleState.LastRestartTimeUtc,
moduleRuntimeInfo.ModuleStatus,
dockerModule.ImagePullPolicy,
dockerModule.Priority,
dockerModule.StartupOrder,
dockerModule.ConfigurationInfo,
dockerModule.Env);
break;
Expand Down Expand Up @@ -116,7 +116,7 @@ public async Task<ModuleSet> GetModulesAsync(CancellationToken token)
moduleState.LastRestartTimeUtc,
moduleRuntimeInfo.ModuleStatus,
dockerModule.ImagePullPolicy,
dockerModule.Priority,
dockerModule.StartupOrder,
dockerModule.ConfigurationInfo,
dockerModule.Env);
break;
Expand Down
Loading

0 comments on commit eed9c06

Please sign in to comment.