Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(feat): Warning users about create OSTree static deltas before rolling out waves #285

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved
OTA update download. Consider generating a static delta for targets using:
Comment on lines +32 to +33
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use the semantic newlines in help messages.
Please, see the related section in the style guide.

Suggested change
We recommend that you generate static deltas for your production targets to optimize
OTA update download. Consider generating a static delta for targets using:
We recommend that you generate static deltas for your production targets to optimize OTA update download.
Consider generating a static delta for targets using:

The line length is absolutely irrelevant here, as long as the sentence fits within 25 words.

$ 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
vkhoroz marked this conversation as resolved.
Show resolved Hide resolved
OTA update download. Consider generating a static delta for targets using:
$ fioctl targets static-deltas

You can then cancel the wave and create a new one by using a static delta.
Comment on lines +157 to +163
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same about semantic newlines:

Suggested change
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. Consider generating a static delta for targets using:
$ fioctl targets static-deltas
You can then cancel the wave and create a new one by using a static delta.
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.
Consider generating a static delta for targets using:
$ fioctl targets static-deltas
You can then cancel the wave and create a new one for a target which has static deltas defined.

This also incorporates my above suggestion about using static deltas.

`)

}
}

func hasStaticDelta(new_targets tuf.Files) bool {
for _, file := range new_targets {
custom, err := api.TargetCustom(file)
subcommands.DieNotNil(err)
camilamacedo86 marked this conversation as resolved.
Show resolved Hide resolved
if custom.DeltaStats == nil {
return false
}
}
return true
}

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