Skip to content

Commit

Permalink
back port openshift#657 to 4.3: set CreationTimestamp at create time,…
Browse files Browse the repository at this point in the history
… not only at update time
  • Loading branch information
juzhao committed Nov 4, 2022
1 parent abd0a78 commit 67c9c4b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ func (c *Client) NamespacesToMonitor() ([]string, error) {
}

func (c *Client) CreateOrUpdatePrometheus(p *monv1.Prometheus) error {
if p.Spec.Storage != nil {
p.Spec.Storage.VolumeClaimTemplate.CreationTimestamp = metav1.Unix(0, 0)
}

pclient := c.mclient.MonitoringV1().Prometheuses(p.GetNamespace())
oldProm, err := pclient.Get(p.GetName(), metav1.GetOptions{})
if apierrors.IsNotFound(err) {
Expand All @@ -277,9 +281,6 @@ func (c *Client) CreateOrUpdatePrometheus(p *monv1.Prometheus) error {
}

p.ResourceVersion = oldProm.ResourceVersion
if p.Spec.Storage != nil {
p.Spec.Storage.VolumeClaimTemplate.CreationTimestamp = metav1.Unix(0, 0)
}
_, err = pclient.Update(p)
return errors.Wrap(err, "updating Prometheus object failed")
}
Expand Down

0 comments on commit 67c9c4b

Please sign in to comment.