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 healthcheck for firefly and extra log info for image #317

Merged
merged 1 commit into from
Jul 23, 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
6 changes: 5 additions & 1 deletion internal/core/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
package core

import (
"context"
"encoding/json"
"fmt"
"os"
"strings"

"github.com/hyperledger/firefly-cli/internal/constants"
"github.com/hyperledger/firefly-cli/internal/docker"
"github.com/hyperledger/firefly-cli/internal/log"
"github.com/hyperledger/firefly-cli/pkg/types"
"github.com/hyperledger/firefly-common/pkg/fftypes"
)
Expand Down Expand Up @@ -107,7 +109,7 @@ func getSHA(imageName, imageTag string) (string, error) {
}
}

func ReadManifestFile(p string) (*types.VersionManifest, error) {
func ReadManifestFile(ctx context.Context, p string) (*types.VersionManifest, error) {
d, err := os.ReadFile(p)
if err != nil {
return nil, err
Expand All @@ -117,6 +119,8 @@ func ReadManifestFile(p string) (*types.VersionManifest, error) {

// If core is not specified in the manifest, use a locally built image called "firefly"
if manifest.FireFly == nil {
log := log.LoggerFromContext(ctx)
log.Warn("No FireFly image present in manifest provided, using local image hypeledger/firefly")
manifest.FireFly = &types.ManifestEntry{
Image: "hyperledger/firefly",
Local: true,
Expand Down
10 changes: 10 additions & 0 deletions internal/docker/docker_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ func CreateDockerCompose(s *types.Stack) *DockerComposeConfig {
DependsOn: map[string]map[string]string{},
Logging: StandardLogOptions,
Environment: s.EnvironmentVars,
HealthCheck: &HealthCheck{
Test: []string{
"CMD",
"curl",
"--fail",
fmt.Sprintf("http://localhost:%d/api/v1/status", member.ExposedFireflyPort),
},
Interval: "15s", // 6000 requests in a day
Retries: 30,
},
}
compose.Volumes[fmt.Sprintf("%s_data_%s", fireflyCore, member.ID)] = struct{}{}
compose.Services[fireflyCore+"_"+member.ID].DependsOn["dataexchange_"+member.ID] = map[string]string{"condition": "service_started"}
Expand Down
2 changes: 1 addition & 1 deletion internal/stacks/stack_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (s *StackManager) InitStack(options *types.InitOptions) (err error) {

if options.ManifestPath != "" {
// If a path to a manifest file is set, read the existing file
manifest, err = core.ReadManifestFile(options.ManifestPath)
manifest, err = core.ReadManifestFile(s.ctx, options.ManifestPath)
if err != nil {
return err
}
Expand Down
Loading