-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: empty string of backup.status.size
The data type of backup.status.size is string. If backup is failed and the size is not set to "0". The metrics collect will fail to parse it. - The default value of backup.status.size should be "0" - Update the existing backups with backup.status.size == "" to "0" Longhorn 10358 Signed-off-by: Derek Su <derek.su@suse.com> (cherry picked from commit fb0a416) Signed-off-by: Derek Su <derek.su@suse.com>
- Loading branch information
1 parent
935c595
commit 56a5a81
Showing
4 changed files
with
90 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package v164to165 | ||
|
||
import ( | ||
"github.com/pkg/errors" | ||
|
||
apierrors "k8s.io/apimachinery/pkg/api/errors" | ||
clientset "k8s.io/client-go/kubernetes" | ||
|
||
lhclientset "github.com/longhorn/longhorn-manager/k8s/pkg/client/clientset/versioned" | ||
upgradeutil "github.com/longhorn/longhorn-manager/upgrade/util" | ||
) | ||
|
||
const ( | ||
upgradeLogPrefix = "upgrade from v1.6.4 to v1.6.5: " | ||
) | ||
|
||
func UpgradeResources(namespace string, lhClient *lhclientset.Clientset, kubeClient *clientset.Clientset, resourceMaps map[string]interface{}) error { | ||
if resourceMaps == nil { | ||
return errors.New("resourceMaps cannot be nil") | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func UpgradeResourcesStatus(namespace string, lhClient *lhclientset.Clientset, kubeClient *clientset.Clientset, resourceMaps map[string]interface{}) error { | ||
if resourceMaps == nil { | ||
return errors.New("resourceMaps cannot be nil") | ||
} | ||
return upgradeBackupStatus(namespace, lhClient, resourceMaps) | ||
} | ||
|
||
func upgradeBackupStatus(namespace string, lhClient *lhclientset.Clientset, resourceMaps map[string]interface{}) (err error) { | ||
defer func() { | ||
err = errors.Wrapf(err, upgradeLogPrefix+"upgrade backups failed") | ||
}() | ||
|
||
backupMap, err := upgradeutil.ListAndUpdateBackupsInProvidedCache(namespace, lhClient, resourceMaps) | ||
if err != nil { | ||
if apierrors.IsNotFound(err) { | ||
return nil | ||
} | ||
return errors.Wrapf(err, "failed to list all existing Longhorn backups during the backup status upgrade") | ||
} | ||
|
||
for _, b := range backupMap { | ||
if b.Status.Size == "" { | ||
b.Status.Size = "0" | ||
} | ||
} | ||
return nil | ||
} |