Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(migrate): don't fail if lease not found #154

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions cmd/provider-services/cmd/migrate/v2beta2/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ func doMigrateCRDs(ctx context.Context, cmd *cobra.Command) (err error) {
if len(oldMani) > 0 {
spinner.Message("migrating manifests to v2beta2")
spinner.StopMessage("migrated manifests to v2beta2")
spinner.StopFailMessage("failed to migrate manifests to v2beta2")
spinner.StopFailMessage("some v2beta manifests may have failed")

_ = spinner.Start()

Expand All @@ -490,7 +490,6 @@ func doMigrateCRDs(ctx context.Context, cmd *cobra.Command) (err error) {

gspec, exists := activeLeases[nlid]
if !exists {
errs = append(errs, fmt.Errorf("no groupspec for lease %s", nlid)) // nolint goerr113
continue
}

Expand Down Expand Up @@ -550,8 +549,20 @@ func doMigrateCRDs(ctx context.Context, cmd *cobra.Command) (err error) {
_ = spinner.Start()

var errs []error

for _, host := range oldHosts {
nlid := mtypes.LeaseID{
Owner: host.Spec.Owner,
DSeq: host.Spec.Dseq,
GSeq: host.Spec.Oseq,
OSeq: host.Spec.Gseq,
Provider: host.Spec.Provider,
}

_, exists := activeLeases[nlid]
if !exists {
continue
}

nhost := &v2beta2.ProviderHost{
TypeMeta: metav1.TypeMeta{
Kind: "ProviderHost",
Expand Down Expand Up @@ -607,6 +618,14 @@ func doMigrateCRDs(ctx context.Context, cmd *cobra.Command) (err error) {
var errs []error

for _, host := range oldIPs {
olid, _ := host.Spec.LeaseID.ToAkash()
nlid := mmigrate.LeaseIDFromV1beta2(olid)

_, exists := activeLeases[nlid]
if !exists {
continue
}

nIPs := &v2beta2.ProviderLeasedIP{
TypeMeta: metav1.TypeMeta{
Kind: "ProviderLeasedIP",
Expand Down