Compare commits
6 Commits
cli/fix/ig
...
module-app
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f6b85d1b2 | ||
|
|
de51ef4ac0 | ||
|
|
ea4f0e72d6 | ||
|
|
40123968c2 | ||
|
|
6ec54dbab3 | ||
|
|
05fe233d43 |
@@ -170,7 +170,7 @@ spec:
|
||||
priorityClassName: "system-cluster-critical"
|
||||
containers:
|
||||
- name: app-service
|
||||
image: beclab/app-service:0.4.65
|
||||
image: beclab/app-service:0.4.67
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
runAsUser: 0
|
||||
|
||||
@@ -377,6 +377,8 @@ func (r *ApplicationReconciler) createApplication(ctx context.Context, req ctrl.
|
||||
func (r *ApplicationReconciler) updateApplication(ctx context.Context, req ctrl.Request,
|
||||
deployment client.Object, app *appv1alpha1.Application, name string) error {
|
||||
appCopy := app.DeepCopy()
|
||||
appNames := getAppName(deployment)
|
||||
isMultiApp := len(appNames) > 1
|
||||
|
||||
tailScale, err := r.getAppTailScale(deployment)
|
||||
if err != nil {
|
||||
@@ -390,11 +392,31 @@ func (r *ApplicationReconciler) updateApplication(ctx context.Context, req ctrl.
|
||||
|
||||
icon = icons[name]
|
||||
|
||||
entrancesMap, err := r.getEntranceServiceAddress(ctx, deployment, isMultiApp)
|
||||
if err != nil {
|
||||
ctrl.Log.Error(err, "get entrance error")
|
||||
}
|
||||
servicePortsMap, err := r.getAppPorts(ctx, deployment, isMultiApp)
|
||||
if err != nil {
|
||||
klog.Warningf("get app ports err=%v", err)
|
||||
}
|
||||
var appid string
|
||||
if userspace.IsSysApp(name) {
|
||||
appid = name
|
||||
} else {
|
||||
appid = appv1alpha1.AppName(name).GetAppID()
|
||||
}
|
||||
_, sharedEntrances := r.getAppSettings(ctx, name, appid, owner, deployment, isMultiApp, entrancesMap[name])
|
||||
|
||||
appCopy.Spec.Name = name
|
||||
appCopy.Spec.Namespace = deployment.GetNamespace()
|
||||
appCopy.Spec.Owner = owner
|
||||
appCopy.Spec.DeploymentName = deployment.GetName()
|
||||
appCopy.Spec.Icon = icon
|
||||
appCopy.Spec.SharedEntrances = sharedEntrances
|
||||
appCopy.Spec.Ports = servicePortsMap[name]
|
||||
appCopy.Spec.Entrances = entrancesMap[name]
|
||||
|
||||
if tailScale != nil {
|
||||
appCopy.Spec.TailScale = *tailScale
|
||||
}
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
package appstate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
appsv1 "bytetrade.io/web3os/app-service/api/app.bytetrade.io/v1alpha1"
|
||||
apputils "bytetrade.io/web3os/app-service/pkg/utils/app"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
// FIXME: impossible state
|
||||
|
||||
var _ StatefulApp = &PendingCancelFailedApp{}
|
||||
var _ OperationApp = &PendingCancelFailedApp{}
|
||||
|
||||
type PendingCancelFailedApp struct {
|
||||
*DoNothingApp
|
||||
*baseOperationApp
|
||||
}
|
||||
|
||||
func NewPendingCancelFailedApp(c client.Client,
|
||||
@@ -20,7 +27,8 @@ func NewPendingCancelFailedApp(c client.Client,
|
||||
return appFactory.New(c, manager, 0,
|
||||
func(c client.Client, manager *appsv1.ApplicationManager, ttl time.Duration) StatefulApp {
|
||||
return &PendingCancelFailedApp{
|
||||
DoNothingApp: &DoNothingApp{
|
||||
baseOperationApp: &baseOperationApp{
|
||||
ttl: ttl,
|
||||
baseStatefulApp: &baseStatefulApp{
|
||||
manager: manager,
|
||||
client: c,
|
||||
@@ -30,11 +38,25 @@ func NewPendingCancelFailedApp(c client.Client,
|
||||
})
|
||||
}
|
||||
|
||||
//func (p *PendingCancelFailedApp) Exec(ctx context.Context) (StatefulInProgressApp, error) {
|
||||
// // FIXME: should set a max retry count for cancel operation
|
||||
// err := p.updateStatus(ctx, p.manager, appsv1.PendingCanceling, nil, appsv1.PendingCanceling.String())
|
||||
// if err != nil {
|
||||
// klog.Errorf("update app manager %s to %s state failed %v", p.manager.Name, appsv1.PendingCanceling, err)
|
||||
// }
|
||||
// return nil, err
|
||||
//}
|
||||
func (p *PendingCancelFailedApp) Exec(ctx context.Context) (StatefulInProgressApp, error) {
|
||||
if !apputils.IsProtectedNamespace(p.manager.Spec.AppNamespace) {
|
||||
var ns corev1.Namespace
|
||||
err := p.client.Get(ctx, types.NamespacedName{Name: p.manager.Spec.AppNamespace}, &ns)
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
return nil, err
|
||||
}
|
||||
if err == nil {
|
||||
e := p.client.Delete(ctx, &ns)
|
||||
if e != nil {
|
||||
klog.Errorf("failed to delete ns %s, err=%v", p.manager.Spec.AppNamespace, e)
|
||||
return nil, e
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (p *PendingCancelFailedApp) Cancel(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,9 +2,15 @@ package appstate
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
appsv1 "bytetrade.io/web3os/app-service/api/app.bytetrade.io/v1alpha1"
|
||||
apputils "bytetrade.io/web3os/app-service/pkg/utils/app"
|
||||
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/klog/v2"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
@@ -41,6 +47,21 @@ func (p *PendingCancelingApp) Exec(ctx context.Context) (StatefulInProgressApp,
|
||||
klog.Errorf("app %s operation is not ", p.manager.Name)
|
||||
}
|
||||
|
||||
if !apputils.IsProtectedNamespace(p.manager.Spec.AppNamespace) {
|
||||
var ns corev1.Namespace
|
||||
err := p.client.Get(ctx, types.NamespacedName{Name: p.manager.Spec.AppNamespace}, &ns)
|
||||
if err != nil && !apierrors.IsNotFound(err) {
|
||||
klog.Errorf("failed to get namespace %s, %v", p.manager.Spec.AppNamespace, err)
|
||||
return nil, err
|
||||
}
|
||||
if err == nil {
|
||||
if delErr := p.client.Delete(ctx, &ns); delErr != nil && !apierrors.IsNotFound(delErr) {
|
||||
klog.Errorf("failed to delete namespace %s, %v", p.manager.Spec.AppNamespace, delErr)
|
||||
return nil, delErr
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
err := p.updateStatus(ctx, p.manager, appsv1.PendingCanceled, nil, appsv1.PendingCanceled.String(), "")
|
||||
if err != nil {
|
||||
klog.Errorf("update app manager %s to %s state failed %v", p.manager.Name, appsv1.PendingCanceled, err)
|
||||
@@ -59,3 +80,58 @@ func (p *PendingCancelingApp) Cancel(ctx context.Context) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
var _ PollableStatefulInProgressApp = &pendingCancelInProgressApp{}
|
||||
|
||||
type pendingCancelInProgressApp struct {
|
||||
*PendingCancelingApp
|
||||
*basePollableStatefulInProgressApp
|
||||
}
|
||||
|
||||
func (p *pendingCancelInProgressApp) Exec(ctx context.Context) (StatefulInProgressApp, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (p *pendingCancelInProgressApp) poll(ctx context.Context) error {
|
||||
if apputils.IsProtectedNamespace(p.manager.Spec.AppNamespace) {
|
||||
return nil
|
||||
}
|
||||
|
||||
timer := time.NewTicker(time.Second)
|
||||
defer timer.Stop()
|
||||
for {
|
||||
select {
|
||||
case <-timer.C:
|
||||
var ns corev1.Namespace
|
||||
err := p.client.Get(ctx, types.NamespacedName{Name: p.manager.Spec.AppNamespace}, &ns)
|
||||
klog.Infof("pending cancel poll namespace %s err %v", p.manager.Spec.AppNamespace, err)
|
||||
if apierrors.IsNotFound(err) {
|
||||
return nil
|
||||
}
|
||||
|
||||
case <-ctx.Done():
|
||||
return fmt.Errorf("app %s execute cancel operation failed %w", p.manager.Spec.AppName, ctx.Err())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (p *pendingCancelInProgressApp) WaitAsync(ctx context.Context) {
|
||||
appFactory.waitForPolling(ctx, p, func(err error) {
|
||||
if err != nil {
|
||||
updateErr := p.updateStatus(context.TODO(), p.manager, appsv1.PendingCancelFailed, nil, appsv1.PendingCancelFailed.String(), "")
|
||||
if updateErr != nil {
|
||||
klog.Errorf("update app manager %s to %s state failed %v", p.manager.Name, appsv1.PendingCancelFailed.String(), updateErr)
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
updateErr := p.updateStatus(context.TODO(), p.manager, appsv1.PendingCanceled, nil, appsv1.PendingCanceled.String(), "")
|
||||
if updateErr != nil {
|
||||
klog.Errorf("update app manager %s to %s state failed %v", p.manager.Name, appsv1.PendingCanceled.String(), updateErr)
|
||||
return
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ spec:
|
||||
command:
|
||||
- /samba_share
|
||||
- name: files
|
||||
image: beclab/files-server:v0.2.139
|
||||
image: beclab/files-server:v0.2.140
|
||||
imagePullPolicy: IfNotPresent
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: true
|
||||
|
||||
@@ -7,4 +7,4 @@ output:
|
||||
-
|
||||
name: beclab/apecloud-kubeblocks:1.0.1
|
||||
-
|
||||
name: beclab/kubeblock-addon-charts:v1.0.1
|
||||
name: beclab/kubeblock-addon-charts:v1.0.1-ext
|
||||
|
||||
@@ -11,7 +11,7 @@ spec:
|
||||
or cluster of machines.
|
||||
helm:
|
||||
chartLocationURL: file:///minio-1.0.1.tgz
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1-ext
|
||||
chartsPathInImage: /charts
|
||||
installValues: {}
|
||||
valuesMapping:
|
||||
@@ -44,7 +44,7 @@ spec:
|
||||
and scaling.
|
||||
helm:
|
||||
chartLocationURL: file:///mongodb-1.0.1.tgz
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1-ext
|
||||
installable:
|
||||
autoInstall: true
|
||||
type: Helm
|
||||
@@ -68,7 +68,7 @@ spec:
|
||||
speed and relevance on production-scale workloads.
|
||||
helm:
|
||||
chartLocationURL: file:///elasticsearch-1.0.1.tgz
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1-ext
|
||||
installable:
|
||||
autoInstall: true
|
||||
type: Helm
|
||||
@@ -90,7 +90,7 @@ spec:
|
||||
description: RabbitMQ is a reliable and mature messaging and streaming broker.
|
||||
helm:
|
||||
chartLocationURL: file:///rabbitmq-1.0.1.tgz
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1-ext
|
||||
installable:
|
||||
autoInstall: true
|
||||
type: Helm
|
||||
@@ -113,7 +113,7 @@ spec:
|
||||
system that is widely used for web and application servers
|
||||
helm:
|
||||
chartLocationURL: file:///mariadb-1.0.1.tgz
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1-ext
|
||||
installable:
|
||||
autoInstall: true
|
||||
type: Helm
|
||||
@@ -136,7 +136,7 @@ spec:
|
||||
system (RDBMS)
|
||||
helm:
|
||||
chartLocationURL: file:///mysql-1.0.1.tgz
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1
|
||||
chartsImage: beclab/kubeblock-addon-charts:v1.0.1-ext
|
||||
installable:
|
||||
autoInstall: true
|
||||
type: Helm
|
||||
Reference in New Issue
Block a user