Skip to content

Commit

Permalink
api: suppress json parse error for lastApplied spec parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
f41gh7 committed Sep 21, 2023
1 parent ba402b1 commit 9d65e09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions api/v1beta1/vmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,9 @@ func (cr *VMCluster) LastAppliedSpecAsPatch() (client.Patch, error) {
func (cr *VMCluster) HasSpecChanges() (bool, error) {
var prevClusterSpec VMClusterSpec
lastAppliedClusterJSON := cr.Annotations["operator.victoriametrics/last-applied-spec"]
if len(lastAppliedClusterJSON) == 0 {
return true, nil
}
if err := json.Unmarshal([]byte(lastAppliedClusterJSON), &prevClusterSpec); err != nil {
return true, fmt.Errorf("cannot parse last applied cluster spec value: %s : %w", lastAppliedClusterJSON, err)
}
Expand Down
3 changes: 3 additions & 0 deletions api/victoriametrics/v1beta1/vmcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,9 @@ func (cr *VMCluster) LastAppliedSpecAsPatch() (client.Patch, error) {
func (cr *VMCluster) HasSpecChanges() (bool, error) {
var prevClusterSpec VMClusterSpec
lastAppliedClusterJSON := cr.Annotations["operator.victoriametrics/last-applied-spec"]
if len(lastAppliedClusterJSON) == 0 {
return true, nil
}
if err := json.Unmarshal([]byte(lastAppliedClusterJSON), &prevClusterSpec); err != nil {
return true, fmt.Errorf("cannot parse last applied cluster spec value: %s : %w", lastAppliedClusterJSON, err)
}
Expand Down

0 comments on commit 9d65e09

Please sign in to comment.