diff --git a/api/v1beta1/vmcluster_types.go b/api/v1beta1/vmcluster_types.go index 3275d70d..633d7372 100644 --- a/api/v1beta1/vmcluster_types.go +++ b/api/v1beta1/vmcluster_types.go @@ -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) } diff --git a/api/victoriametrics/v1beta1/vmcluster_types.go b/api/victoriametrics/v1beta1/vmcluster_types.go index 3275d70d..633d7372 100644 --- a/api/victoriametrics/v1beta1/vmcluster_types.go +++ b/api/victoriametrics/v1beta1/vmcluster_types.go @@ -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) }