Skip to content

Commit

Permalink
(feat): Warning users about create OSTree static deltas before rollin…
Browse files Browse the repository at this point in the history
…g out waves

Signed-off-by: Camila Macedo <[email protected]>
  • Loading branch information
Camila Macedo committed Oct 3, 2023
1 parent 0ac0f5f commit 5f63f5e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 5 additions & 0 deletions client/foundries.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,10 @@ type ProjectTrigger struct {
Id int `json:"id,omitempty"`
Secrets []ProjectSecret `json:"secrets"`
}
type DeltaStats struct {
Sha256 string `json:"sha256"`
Size int `json:"size"`
}

type TufCustom struct {
HardwareIds []string `json:"hardwareIds,omitempty"`
Expand All @@ -286,6 +290,7 @@ type TufCustom struct {
ComposeApps map[string]ComposeApp `json:"docker_compose_apps,omitempty"`
Name string `json:"name,omitempty"`
ContainersSha string `json:"containers-sha,omitempty"`
DeltaStats *DeltaStats `json:"delta-stats,omitempty"`
LmpManifestSha string `json:"lmp-manifest-sha,omitempty"`
OverridesSha string `json:"meta-subscriber-overrides-sha,omitempty"`
Uri string `json:"uri,omitempty"`
Expand Down
32 changes: 31 additions & 1 deletion subcommands/waves/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ func init() {
This command only initializes a wave, but does not provision its updates to devices.
Use a "fioctl wave rollout <wave> <group>" to trigger updates of this wave to a device group.
Use a "fioctl wave complete <wave>" to update all devices (make it globally available).
Use a "fioctl wave cancel <wave> to cancel a wave (make it no longer available).`,
Use a "fioctl wave cancel <wave> to cancel a wave (make it no longer available).
We recommend that you generate static deltas for your production targets to optimize
OTA update download. Please, consider generating a static delta for targets using:
$ fioctl targets static-deltas.
`,
Run: doInitWave,
Args: cobra.ExactArgs(3),
Example: `
Expand Down Expand Up @@ -145,6 +150,31 @@ func doInitWave(cmd *cobra.Command, args []string) {
} else {
subcommands.DieNotNil(api.FactoryCreateWave(factory, &wave), "Failed to create a wave")
}

if !hasStaticDelta(new_targets) {

fmt.Print(`
WARNING: You created a wave for a target version without static deltas.
We recommend that you generate static deltas for your production targets to optimize
OTA update download. Please, consider generating a static delta for targets using:
$ fioctl targets static-deltas.
You can then cancel this wave and create a new one for a target with a static delta.
`)

}
}

func hasStaticDelta(new_targets tuf.Files) bool {
for _, file := range new_targets {
custom, err := api.TargetCustom(file)
subcommands.DieNotNil(err)
if custom.DeltaStats == nil {
return false
}
}
return true
}

func pruneTargets(currentTargets *client.AtsTargetsMeta, versions []string) client.AtsTargetsMeta {
Expand Down

0 comments on commit 5f63f5e

Please sign in to comment.