diff --git a/grpc/pb/phased_test.go b/grpc/pb/phased_test.go new file mode 100644 index 0000000..c1924cc --- /dev/null +++ b/grpc/pb/phased_test.go @@ -0,0 +1,23 @@ +package pb + +import ( + "encoding/json" + "strings" + "testing" +) + +// A phased update is flagged on the wire; an ordinary one carries no field at +// all, so an old server or agent sees exactly the shape it always did. +func TestPackageUpdatePhasedOnWire(t *testing.T) { + b, err := json.Marshal(PackageUpdate{Name: "libkrb5-3", NewVersion: "1.20", Phased: true}) + if err != nil { + t.Fatal(err) + } + if !strings.Contains(string(b), `"phased":true`) { + t.Fatalf("phased missing: %s", b) + } + b, _ = json.Marshal(PackageUpdate{Name: "curl", NewVersion: "8"}) + if strings.Contains(string(b), "phased") { + t.Fatalf("an ordinary update must not carry phased: %s", b) + } +} diff --git a/grpc/pb/vantage.pb.go b/grpc/pb/vantage.pb.go index 6d148c5..ee506d8 100644 --- a/grpc/pb/vantage.pb.go +++ b/grpc/pb/vantage.pb.go @@ -85,6 +85,10 @@ type PackageUpdate struct { Name string `json:"name"` CurrentVersion string `json:"current_version,omitempty"` NewVersion string `json:"new_version"` + // Phased marks an Ubuntu phased update this host is not yet selected for: + // apt lists it as upgradable, but an upgrade defers it until the host's + // phase comes up. It is pending, not installable, so counts leave it out. + Phased bool `json:"phased,omitempty"` } type ReportUpdatesRequest struct { diff --git a/proto/vantage/v1/vantage.proto b/proto/vantage/v1/vantage.proto index b21f7b1..a7a8da1 100644 --- a/proto/vantage/v1/vantage.proto +++ b/proto/vantage/v1/vantage.proto @@ -127,6 +127,7 @@ message PackageUpdate { string name = 1; string current_version = 2; string new_version = 3; + bool phased = 4; // Ubuntu phased update this host is not yet selected for; deferred by apt } message ReportUpdatesRequest {