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

Add terminate ns, skip notifications for abnormal users, set default.NodePort.Limit=10, adapt new user struct. #5056

Merged
merged 4 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 4 additions & 3 deletions controllers/account/api/v1/debt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ var DefaultDebtConfig = map[DebtStatusType]int64{
const DebtNamespaceAnnoStatusKey = "debt.sealos/status"

const (
NormalDebtNamespaceAnnoStatus = "Normal"
SuspendDebtNamespaceAnnoStatus = "Suspend"
ResumeDebtNamespaceAnnoStatus = "Resume"
NormalDebtNamespaceAnnoStatus = "Normal"
SuspendDebtNamespaceAnnoStatus = "Suspend"
ResumeDebtNamespaceAnnoStatus = "Resume"
TerminateSuspendDebtNamespaceAnnoStatus = "TerminateSuspend"
)

// DebtSpec defines the desired state of Debt
Expand Down
10 changes: 9 additions & 1 deletion controllers/account/controllers/debt_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,15 @@ func (r *DebtReconciler) sendSMSNotice(user string, oweAmount int64, noticeType
if r.SmsConfig == nil && r.VmsConfig == nil && r.smtpConfig == nil {
return nil
}
outh, err := r.AccountV2.GetUserOauthProvider(&pkgtypes.UserQueryOpts{Owner: user})
_user, err := r.AccountV2.GetUser(&pkgtypes.UserQueryOpts{Owner: user})
if err != nil {
return fmt.Errorf("failed to get user: %w", err)
}
// skip abnormal user
if _user.Status != pkgtypes.UserStatusNormal {
return nil
}
outh, err := r.AccountV2.GetUserOauthProvider(&pkgtypes.UserQueryOpts{UID: _user.UID, ID: _user.ID})
if err != nil {
return fmt.Errorf("failed to get user oauth provider: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion controllers/account/controllers/namespace_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func (r *NamespaceReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
}
logger.V(1).Info("debt status", "status", debtStatus)
switch debtStatus {
case v1.SuspendDebtNamespaceAnnoStatus:
case v1.SuspendDebtNamespaceAnnoStatus, v1.TerminateSuspendDebtNamespaceAnnoStatus:
if err := r.SuspendUserResource(ctx, req.NamespacedName.Name); err != nil {
logger.Error(err, "suspend namespace resources failed")
return ctrl.Result{}, err
Expand Down
1 change: 1 addition & 0 deletions controllers/account/deploy/Kubefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ ENV cloudDomain="cloud.sealos.io"
ENV cloudPort=""
ENV MONGO_URI "mongodb://mongo:27017/resources"
ENV GLOBAL_COCKROACH_URI ""
ENV ACCOUNT_API_JWT_SECRET="secret"
ENV LOCAL_COCKROACH_URI ""
ENV LOCAL_REGION ""
ENV OSNamespace="objectstorage-system"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ data:
LOCAL_REGION: '{{ .LOCAL_REGION }}'
DOMAIN: '{{ .cloudDomain }}'
PORT: '{{ .cloudPort }}'
ACCOUNT_API_JWT_SECRET: '{{ .ACCOUNT_API_JWT_SECRET }}'
BASE_BALANCE: '{{ .BASE_BALANCE | default "ri79LzQiQrs6CVa1ctE308+AseBXbOua0RIMCXAH5hc3irs=" }}'


2 changes: 1 addition & 1 deletion controllers/devbox/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/labring/sealos/controllers/devbox

go 1.23
go 1.22

require (
github.com/avast/retry-go v2.7.0+incompatible
Expand Down
2 changes: 1 addition & 1 deletion controllers/pkg/resources/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ const (
DefaultQuotaLimitsMemory = "64Gi"
DefaultQuotaLimitsStorage = "100Gi"
DefaultQuotaLimitsGPU = "8"
DefaultQuotaLimitsNodePorts = "3"
DefaultQuotaLimitsNodePorts = "10"
DefaultQuotaObjectStorageSize = "100Gi"
DefaultQuotaObjectStorageBucket = "5"
)
Expand Down
22 changes: 15 additions & 7 deletions controllers/pkg/types/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,23 @@ func (Transfer) TableName() string {
}

type User struct {
UID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
CreatedAt time.Time `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp()"`
UpdatedAt time.Time `gorm:"column:updatedAt;type:timestamp(3) with time zone;default:current_timestamp()"`
AvatarURI string `gorm:"column:avatarUri;type:text"`
Nickname string `gorm:"type:text"`
ID string `gorm:"type:text;not null;unique"`
Name string `gorm:"type:text;not null"`
UID uuid.UUID `gorm:"type:uuid;default:gen_random_uuid();primary_key"`
CreatedAt time.Time `gorm:"column:createdAt;type:timestamp(3) with time zone;default:current_timestamp()"`
UpdatedAt time.Time `gorm:"column:updatedAt;type:timestamp(3) with time zone;default:current_timestamp()"`
AvatarURI string `gorm:"column:avatarUri;type:text"`
Nickname string `gorm:"type:text"`
ID string `gorm:"type:text;not null;unique"`
Name string `gorm:"type:text;not null"`
Status UserStatus `gorm:"column:status;type:UserStatus;default:'NORMAL_USER'::defaultdb.public.'UserStatus';not null"`
}

type UserStatus string

const (
UserStatusNormal UserStatus = "NORMAL_USER"
UserStatusLock UserStatus = "LOCK_USER"
)

func (User) TableName() string {
return "User"
}
Expand Down
Loading