Skip to content

Commit

Permalink
updater correctly updates storageversion status
Browse files Browse the repository at this point in the history
  • Loading branch information
roycaihw committed Nov 9, 2020
1 parent 8a1d8f7 commit 23ef9b5
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions staging/src/k8s.io/apiserver/pkg/storageversion/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// Client has the methods required to update the storage version.
type Client interface {
Create(context.Context, *v1alpha1.StorageVersion, metav1.CreateOptions) (*v1alpha1.StorageVersion, error)
Update(context.Context, *v1alpha1.StorageVersion, metav1.UpdateOptions) (*v1alpha1.StorageVersion, error)
UpdateStatus(context.Context, *v1alpha1.StorageVersion, metav1.UpdateOptions) (*v1alpha1.StorageVersion, error)
Get(context.Context, string, metav1.GetOptions) (*v1alpha1.StorageVersion, error)
}

Expand Down Expand Up @@ -91,10 +91,16 @@ func singleUpdate(c Client, apiserverID string, gr schema.GroupResource, encodin
}
updatedSV := localUpdateStorageVersion(sv, apiserverID, encodingVersion, decodableVersions)
if shouldCreate {
_, err := c.Create(context.TODO(), updatedSV, metav1.CreateOptions{})
createdSV, err := c.Create(context.TODO(), updatedSV, metav1.CreateOptions{})
if err != nil {
return err
}
// assign the calculated status to the object just created, then update status
createdSV.Status = updatedSV.Status
_, err = c.UpdateStatus(context.TODO(), createdSV, metav1.UpdateOptions{})
return err
}
_, err = c.Update(context.TODO(), updatedSV, metav1.UpdateOptions{})
_, err = c.UpdateStatus(context.TODO(), updatedSV, metav1.UpdateOptions{})
return err
}

Expand Down

0 comments on commit 23ef9b5

Please sign in to comment.