[INFRA-144] fix: airgap upgrade (#3318)

* fix: skip APP_RELEASE_VERSION during environment variable updates in install script

- Updated the install.sh script to skip processing the APP_RELEASE_VERSION key when reading from the backup environment file, ensuring that this key is not inadvertently modified during upgrades.

* fix: update current_version assignment in register_instance_ee command

- Changed the assignment of current_version to use app_version as the default value when user_version is not provided, ensuring consistency in version handling.

---------

Co-authored-by: Manish Gupta <manish@plane.so>
This commit is contained in:
Nikhil
2025-06-10 12:00:26 +05:30
committed by GitHub
parent 72ca7c77b3
commit ad2c1a87c9
3 changed files with 62 additions and 3 deletions

View File

@@ -86,9 +86,7 @@ class Command(BaseCommand):
instance.latest_version = data.get(
"latest_version", instance.latest_version
)
instance.current_version = data.get(
"user_version", instance.current_version
)
instance.current_version = data.get("user_version", app_version)
instance.edition = InstanceEdition.PLANE_COMMERCIAL.value
instance.last_checked_at = timezone.now()
instance.is_test = os.environ.get("IS_TEST", "0") == "1"

View File

@@ -186,6 +186,10 @@ if [[ "$INSTALLATION_TYPE" == "Upgrade" ]] && [[ -f "$SETUP_DIR/plane.env.backup
value=""
fi
if [[ "$key" == "APP_RELEASE_VERSION" ]]; then
continue
fi
# echo "$key=$value"
update_env "$SETUP_DIR/plane.env" "$key" "$value"
done < "$SETUP_DIR/plane.env.backup"

View File

@@ -87,6 +87,63 @@ func RefreshLicense(ctx context.Context, api prime_api.IPrimeMonitorApi, license
MembersList: workspaceMembers,
})
if err != nil && api.IsAirgapped() {
// If the license is airgapped, we need to create a new free license
newLicense := &db.License{
ID: license.ID,
LicenseKey: license.LicenseKey,
InstanceID: license.InstanceID,
WorkspaceID: license.WorkspaceID,
Product: "Plane Free",
ProductType: "FREE",
WorkspaceSlug: license.WorkspaceSlug,
Seats: 0,
FreeSeats: 12,
Interval: "MONTHLY",
IsOfflinePayment: false,
IsCancelled: false,
Subscription: "",
CurrentPeriodEndDate: nil,
TrialEndDate: nil,
HasAddedPaymentMethod: false,
HasActivatedFreeTrial: false,
LastVerifiedAt: license.LastVerifiedAt,
LastPaymentFailedDate: nil,
LastPaymentFailedCount: 0,
}
// Update the license in the database
// Update the existing license with the new data present
if err := tx.Delete(&license).Error; err != nil {
return nil, nil, err
}
if err := tx.Create(newLicense).Error; err != nil {
return nil, nil, err
}
// Delete the existing members
if err := tx.Where("license_id = ?", license.ID).Delete(&db.UserLicense{}).Error; err != nil {
return nil, nil, err
}
// Delete the existing flags
if err := tx.Where("license_id = ?", license.ID).Delete(&db.Flags{}).Error; err != nil {
return nil, nil, err
}
return newLicense, &prime_api.WorkspaceActivationResponse{
Product: "Plane Free",
ProductType: "FREE",
WorkspaceSlug: license.WorkspaceSlug,
Seats: 0,
FreeSeats: 12,
Interval: "MONTHLY",
IsOfflinePayment: false,
IsCancelled: false,
MemberList: []prime_api.WorkspaceMember{},
}, nil
}
verificationThreshhold := LICENSE_VERIFICATION_FAILED_THRESHOLD
shouldDeactivate := false