Skip to content
This repository has been archived by the owner on Apr 8, 2024. It is now read-only.

Commit

Permalink
feat(server): add GeospatialjpCloudBuildDiskSizeGb option
Browse files Browse the repository at this point in the history
  • Loading branch information
rot1024 committed Feb 28, 2024
1 parent 9ac90fe commit c1ec006
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 5 deletions.
1 change: 1 addition & 0 deletions server/cmsintegration/cmsintegrationcommon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type Config struct {
GeospatialjpCloudBuildMachineType string
GeospatialjpCloudBuildProject string
GeospatialjpCloudBuildRegion string
GeospatialjpCloudBuildDiskSizeGb int64

// compat
// geospatial.jp v2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type Config struct {
CloudBuildMachineType string
CloudBuildProject string
CloudBuildRegion string
CloudBuildDiskSizeGb int64
}

var ppp *pp.PrettyPrinter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func Prepare(ctx context.Context, itemID, projectID string, conf Config) error {
CloudBuildMachineType: conf.CloudBuildMachineType,
CloudBuildProject: conf.CloudBuildProject,
CloudBuildRegion: conf.CloudBuildRegion,
CloudBuildDiskSizeGb: conf.CloudBuildDiskSizeGb,
})
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,19 @@ type prepareOnCloudBuildConfig struct {
CloudBuildMachineType string
CloudBuildProject string
CloudBuildRegion string
CloudBuildDiskSizeGb int64
}

const defaultDockerImage = "eukarya/plateauview2-sidecar-worker:latest"
const defaultDiskSizeGb = 1000

func prepareOnCloudBuild(ctx context.Context, conf prepareOnCloudBuildConfig) error {
if conf.CloudBuildImage == "" {
conf.CloudBuildImage = defaultDockerImage
}
if conf.CloudBuildDiskSizeGb == 0 {
conf.CloudBuildDiskSizeGb = defaultDiskSizeGb
}

log.Debugfc(ctx, "geospatialjp webhook: prepare (cloud build): %s", ppp.Sprint(conf))

Expand All @@ -45,6 +50,7 @@ func prepareOnCloudBuild(ctx context.Context, conf prepareOnCloudBuildConfig) er
Project: conf.CloudBuildProject,
Region: conf.CloudBuildRegion,
Tags: []string{"prepare-geospatialjp"},
DiskSizeGb: conf.CloudBuildDiskSizeGb,
})
}

Expand All @@ -56,6 +62,7 @@ type CloudBuildConfig struct {
Region string
Project string
Tags []string
DiskSizeGb int64
}

func runCloudBuild(ctx context.Context, conf CloudBuildConfig) error {
Expand All @@ -81,6 +88,7 @@ func runCloudBuild(ctx context.Context, conf CloudBuildConfig) error {
},
Options: &cloudbuild.BuildOptions{
MachineType: machineType,
DiskSizeGb: conf.DiskSizeGb,
},
Tags: conf.Tags,
}
Expand Down
1 change: 1 addition & 0 deletions server/cmsintegration/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func geospatialjpv3Config(conf Config) geospatialjpv3.Config {
CloudBuildMachineType: conf.GeospatialjpCloudBuildMachineType,
CloudBuildProject: conf.GeospatialjpCloudBuildProject,
CloudBuildRegion: conf.GeospatialjpCloudBuildRegion,
CloudBuildDiskSizeGb: conf.GeospatialjpCloudBuildDiskSizeGb,
}
}

Expand Down
2 changes: 2 additions & 0 deletions server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type Config struct {
Geospatialjp_CloudBuildMachineType string `pp:",omitempty"`
Geospatialjp_CloudBuildProject string `pp:",omitempty"`
Geospatialjp_CloudBuildRegion string `pp:",omitempty"`
Geospatialjp_CloudBuildDiskSizeGb int64 `pp:",omitempty"`
DataConv_Disable bool `pp:",omitempty"`
Indexer_Delegate bool `pp:",omitempty"`
DataCatalog_DisableCache bool `pp:",omitempty"`
Expand Down Expand Up @@ -134,6 +135,7 @@ func (c *Config) CMSIntegration() cmsintegration.Config {
GeospatialjpCloudBuildMachineType: c.Geospatialjp_CloudBuildMachineType,
GeospatialjpCloudBuildProject: cloudBuildProject,
GeospatialjpCloudBuildRegion: cloudBuildRegion,
GeospatialjpCloudBuildDiskSizeGb: c.Geospatialjp_CloudBuildDiskSizeGb,
}
}

Expand Down
18 changes: 13 additions & 5 deletions worker/preparegspatialjp/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func Command(conf *Config) (err error) {
citygmlError, plateauError, maxlodError,
strings.TrimSpace(comment),
); err != nil {
log.Errorfc(ctx, "failed to notify error: %w", err)
log.Errorfc(ctx, "failed to notify error: %v", err)
}
}()

Expand Down Expand Up @@ -425,9 +425,9 @@ func notifyError(ctx context.Context, c *cms.CMS, cityItemID, gdataItemID string
if comment != "" {
msgPrefix := ""
if isErr {
msgPrefix = "マージ処理に失敗しました。"
msgPrefix = "公開準備処理に失敗しました。"
} else {
msgPrefix = "マージ処理が完了しました。"
msgPrefix = "公開準備処理が完了しました。"
}

if err := c.CommentToItem(ctx, cityItemID, msgPrefix+comment); err != nil {
Expand All @@ -439,7 +439,7 @@ func notifyError(ctx context.Context, c *cms.CMS, cityItemID, gdataItemID string
}
}

if !citygmlError && !plateauError {
if !citygmlError && !plateauError && !maxLODError {
return nil
}

Expand Down Expand Up @@ -483,6 +483,10 @@ func notifyError(ctx context.Context, c *cms.CMS, cityItemID, gdataItemID string
return fmt.Errorf("failed to marshal item")
}

if rawItem.Fields == nil {
rawItem.Fields = []*cms.Field{}
}

if _, err := c.UpdateItem(ctx, rawItem.ID, rawItem.Fields, rawItem.MetadataFields); err != nil {
return fmt.Errorf("failed to update item: %w", err)
}
Expand Down Expand Up @@ -526,11 +530,15 @@ func notifyRunning(ctx context.Context, c *cms.CMS, citygmlID, dataID string, ci
var rawItem cms.Item
cms.Marshal(item, &rawItem)

if rawItem.Fields == nil {
rawItem.Fields = []*cms.Field{}
}

if _, err := c.UpdateItem(ctx, rawItem.ID, rawItem.Fields, rawItem.MetadataFields); err != nil {
return fmt.Errorf("failed to update item: %w", err)
}

comment := "マージ処理を開始しました。"
comment := "G空間情報センターの公開準備処理を開始しました。"

if err := c.CommentToItem(ctx, citygmlID, comment); err != nil {
return fmt.Errorf("failed to comment to city item: %w", err)
Expand Down

0 comments on commit c1ec006

Please sign in to comment.