Skip to content

Commit 23ef9b5

Browse files
committed
updater correctly updates storageversion status
1 parent 8a1d8f7 commit 23ef9b5

File tree

1 file changed

+9
-3
lines changed
  • staging/src/k8s.io/apiserver/pkg/storageversion

1 file changed

+9
-3
lines changed

staging/src/k8s.io/apiserver/pkg/storageversion/updater.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import (
3131
// Client has the methods required to update the storage version.
3232
type Client interface {
3333
Create(context.Context, *v1alpha1.StorageVersion, metav1.CreateOptions) (*v1alpha1.StorageVersion, error)
34-
Update(context.Context, *v1alpha1.StorageVersion, metav1.UpdateOptions) (*v1alpha1.StorageVersion, error)
34+
UpdateStatus(context.Context, *v1alpha1.StorageVersion, metav1.UpdateOptions) (*v1alpha1.StorageVersion, error)
3535
Get(context.Context, string, metav1.GetOptions) (*v1alpha1.StorageVersion, error)
3636
}
3737

@@ -91,10 +91,16 @@ func singleUpdate(c Client, apiserverID string, gr schema.GroupResource, encodin
9191
}
9292
updatedSV := localUpdateStorageVersion(sv, apiserverID, encodingVersion, decodableVersions)
9393
if shouldCreate {
94-
_, err := c.Create(context.TODO(), updatedSV, metav1.CreateOptions{})
94+
createdSV, err := c.Create(context.TODO(), updatedSV, metav1.CreateOptions{})
95+
if err != nil {
96+
return err
97+
}
98+
// assign the calculated status to the object just created, then update status
99+
createdSV.Status = updatedSV.Status
100+
_, err = c.UpdateStatus(context.TODO(), createdSV, metav1.UpdateOptions{})
95101
return err
96102
}
97-
_, err = c.Update(context.TODO(), updatedSV, metav1.UpdateOptions{})
103+
_, err = c.UpdateStatus(context.TODO(), updatedSV, metav1.UpdateOptions{})
98104
return err
99105
}
100106

0 commit comments

Comments
 (0)