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

Bugfix: disable rollback of latest task #477

Merged
merged 2 commits into from
May 7, 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
12 changes: 10 additions & 2 deletions internal/delivery/http/app-serve-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -574,8 +574,16 @@ func (h *AppServeAppHandler) GetAppServeAppTaskDetail(w http.ResponseWriter, r *
return
}

// TODO: this should be false for latest task
if strings.Contains(task.Status, "SUCCESS") && task.Status != "ABORT_SUCCESS" &&
// Workaround: Compare task ID with latest task ID
// Mark latest task with additional flag later
latestTask, err := h.usecase.GetAppServeAppLatestTask(r.Context(), appId)
if err != nil {
ErrorJSON(w, r, httpErrors.NewInternalServerError(err, "", ""))
return
}
if taskId == latestTask.ID {
task.AvailableRollback = false
} else if strings.Contains(task.Status, "SUCCESS") && task.Status != "ABORT_SUCCESS" &&
task.Status != "ROLLBACK_SUCCESS" {
task.AvailableRollback = true
}
Expand Down
62 changes: 31 additions & 31 deletions internal/model/app-serve-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,43 @@ import (
)

type AppServeApp struct {
ID string `gorm:"primarykey" json:"id,omitempty"`
Name string `gorm:"index" json:"name,omitempty"` // application name
Namespace string `json:"namespace,omitempty"` // application namespace
OrganizationId string `json:"organizationId,omitempty"` // contractId is a contract ID which this app belongs to
ProjectId string `json:"projectId,omitempty"` // project ID which this app belongs to
Type string `json:"type,omitempty"` // type (build/deploy/all)
AppType string `json:"appType,omitempty"` // appType (spring/springboot)
EndpointUrl string `json:"endpointUrl,omitempty"` // endpoint URL of deployed app
PreviewEndpointUrl string `json:"previewEndpointUrl,omitempty"` // preview svc endpoint URL in B/G deployment
TargetClusterId string `json:"targetClusterId,omitempty"` // target cluster to which the app is deployed
TargetClusterName string `gorm:"-:all" json:"targetClusterName,omitempty"` // target cluster name
Status string `gorm:"index" json:"status,omitempty"` // status is status of deployed app
GrafanaUrl string `json:"grafanaUrl,omitempty"` // grafana dashboard URL for deployed app
Description string `json:"description,omitempty"` // description for application
ID string `gorm:"primarykey" json:"id"`
Name string `gorm:"index" json:"name"` // application name
Namespace string `json:"namespace"` // application namespace
OrganizationId string `json:"organizationId"` // contractId is a contract ID which this app belongs to
ProjectId string `json:"projectId"` // project ID which this app belongs to
Type string `json:"type"` // type (build/deploy/all)
AppType string `json:"appType"` // appType (spring/springboot)
EndpointUrl string `json:"endpointUrl"` // endpoint URL of deployed app
PreviewEndpointUrl string `json:"previewEndpointUrl"` // preview svc endpoint URL in B/G deployment
TargetClusterId string `json:"targetClusterId"` // target cluster to which the app is deployed
TargetClusterName string `gorm:"-:all" json:"targetClusterName"` // target cluster name
Status string `gorm:"index" json:"status"` // status is status of deployed app
GrafanaUrl string `json:"grafanaUrl"` // grafana dashboard URL for deployed app
Description string `json:"description"` // description for application
CreatedAt time.Time `gorm:"autoCreateTime:false" json:"createdAt" `
UpdatedAt *time.Time `gorm:"autoUpdateTime:false" json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
}

type AppServeAppTask struct {
ID string `gorm:"primarykey" json:"id,omitempty"`
AppServeAppId string `gorm:"not null" json:"appServeAppId,omitempty"` // ID for appServeApp that this task belongs to
Version string `json:"version,omitempty"` // application version
Status string `json:"status,omitempty"` // status is app status
Output string `json:"output,omitempty"` // output for task result
ArtifactUrl string `json:"artifactUrl,omitempty"` // URL of java app artifact (Eg, Jar)
ImageUrl string `json:"imageUrl,omitempty"` // URL of built image for app
ExecutablePath string `json:"executablePath,omitempty"` // Executable path of app image
Profile string `json:"profile,omitempty"` // java app profile
AppConfig string `json:"appConfig,omitempty"` // java app config
AppSecret string `json:"appSecret,omitempty"` // java app secret
ExtraEnv string `json:"extraEnv,omitempty"` // env variable list for java app
Port string `json:"port,omitempty"` // java app port
ResourceSpec string `json:"resourceSpec,omitempty"` // resource spec of app pod
HelmRevision int32 `gorm:"default:0" json:"helmRevision,omitempty"` // revision of deployed helm release
Strategy string `json:"strategy,omitempty"` // deployment strategy (eg, rolling-update)
RollbackVersion string `json:"rollbackVersion,omitempty"` // rollback target version
ID string `gorm:"primarykey" json:"id"`
AppServeAppId string `gorm:"not null" json:"appServeAppId"` // ID for appServeApp that this task belongs to
Version string `json:"version"` // application version
Status string `json:"status"` // status is app status
Output string `json:"output"` // output for task result
ArtifactUrl string `json:"artifactUrl"` // URL of java app artifact (Eg, Jar)
ImageUrl string `json:"imageUrl"` // URL of built image for app
ExecutablePath string `json:"executablePath"` // Executable path of app image
Profile string `json:"profile"` // java app profile
AppConfig string `json:"appConfig"` // java app config
AppSecret string `json:"appSecret"` // java app secret
ExtraEnv string `json:"extraEnv"` // env variable list for java app
Port string `json:"port"` // java app port
ResourceSpec string `json:"resourceSpec"` // resource spec of app pod
HelmRevision int32 `gorm:"default:0" json:"helmRevision"` // revision of deployed helm release
Strategy string `json:"strategy"` // deployment strategy (eg, rolling-update)
RollbackVersion string `json:"rollbackVersion"` // rollback target version
PvEnabled bool `json:"pvEnabled"`
PvStorageClass string `json:"pvStorageClass"`
PvAccessMode string `json:"pvAccessMode"`
Expand Down
62 changes: 31 additions & 31 deletions pkg/domain/app-serve-app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,43 @@ package domain
import "time"

type AppServeAppResponse struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"` // application name
Namespace string `json:"namespace,omitempty"` // application namespace
OrganizationId string `json:"organizationId,omitempty"` // contractId is a contract ID which this app belongs to
ProjectId string `json:"projectId,omitempty"` // project ID which this app belongs to
Type string `json:"type,omitempty"` // type (build/deploy/all)
AppType string `json:"appType,omitempty"` // appType (spring/springboot)
EndpointUrl string `json:"endpointUrl,omitempty"` // endpoint URL of deployed app
PreviewEndpointUrl string `json:"previewEndpointUrl,omitempty"` // preview svc endpoint URL in B/G deployment
TargetClusterId string `json:"targetClusterId,omitempty"` // target cluster to which the app is deployed
TargetClusterName string `json:"targetClusterName,omitempty"` // target cluster name
Status string `json:"status,omitempty"` // status is status of deployed app
GrafanaUrl string `json:"grafanaUrl,omitempty"` // grafana dashboard URL for deployed app
Description string `json:"description,omitempty"` // description for application
ID string `json:"id"`
Name string `json:"name"` // application name
Namespace string `json:"namespace"` // application namespace
OrganizationId string `json:"organizationId"` // contractId is a contract ID which this app belongs to
ProjectId string `json:"projectId"` // project ID which this app belongs to
Type string `json:"type"` // type (build/deploy/all)
AppType string `json:"appType"` // appType (spring/springboot)
EndpointUrl string `json:"endpointUrl"` // endpoint URL of deployed app
PreviewEndpointUrl string `json:"previewEndpointUrl"` // preview svc endpoint URL in B/G deployment
TargetClusterId string `json:"targetClusterId"` // target cluster to which the app is deployed
TargetClusterName string `json:"targetClusterName"` // target cluster name
Status string `json:"status"` // status is status of deployed app
GrafanaUrl string `json:"grafanaUrl"` // grafana dashboard URL for deployed app
Description string `json:"description"` // description for application
CreatedAt time.Time `json:"createdAt" `
UpdatedAt *time.Time `json:"updatedAt"`
DeletedAt *time.Time `json:"deletedAt"`
}

type AppServeAppTaskResponse struct {
ID string `json:"id,omitempty"`
AppServeAppId string `json:"appServeAppId,omitempty"` // ID for appServeApp that this task belongs to
Version string `json:"version,omitempty"` // application version
Status string `json:"status,omitempty"` // status is app status
Output string `json:"output,omitempty"` // output for task result
ArtifactUrl string `json:"artifactUrl,omitempty"` // URL of java app artifact (Eg, Jar)
ImageUrl string `json:"imageUrl,omitempty"` // URL of built image for app
ExecutablePath string `json:"executablePath,omitempty"` // Executable path of app image
Profile string `json:"profile,omitempty"` // java app profile
AppConfig string `json:"appConfig,omitempty"` // java app config
AppSecret string `json:"appSecret,omitempty"` // java app secret
ExtraEnv string `json:"extraEnv,omitempty"` // env variable list for java app
Port string `json:"port,omitempty"` // java app port
ResourceSpec string `json:"resourceSpec,omitempty"` // resource spec of app pod
HelmRevision int32 `json:"helmRevision,omitempty"` // revision of deployed helm release
Strategy string `json:"strategy,omitempty"` // deployment strategy (eg, rolling-update)
RollbackVersion string `json:"rollbackVersion,omitempty"` // rollback target version
ID string `json:"id"`
AppServeAppId string `json:"appServeAppId"` // ID for appServeApp that this task belongs to
Version string `json:"version"` // application version
Status string `json:"status"` // status is app status
Output string `json:"output"` // output for task result
ArtifactUrl string `json:"artifactUrl"` // URL of java app artifact (Eg, Jar)
ImageUrl string `json:"imageUrl"` // URL of built image for app
ExecutablePath string `json:"executablePath"` // Executable path of app image
Profile string `json:"profile"` // java app profile
AppConfig string `json:"appConfig"` // java app config
AppSecret string `json:"appSecret"` // java app secret
ExtraEnv string `json:"extraEnv"` // env variable list for java app
Port string `json:"port"` // java app port
ResourceSpec string `json:"resourceSpec"` // resource spec of app pod
HelmRevision int32 `json:"helmRevision"` // revision of deployed helm release
Strategy string `json:"strategy"` // deployment strategy (eg, rolling-update)
RollbackVersion string `json:"rollbackVersion"` // rollback target version
PvEnabled bool `json:"pvEnabled"`
PvStorageClass string `json:"pvStorageClass"`
PvAccessMode string `json:"pvAccessMode"`
Expand Down
Loading