Skip to content

Commit

Permalink
Disable check for org and location id, bump timeout (#3712)
Browse files Browse the repository at this point in the history
Co-authored-by: Maxim Pertsov <[email protected]>
  • Loading branch information
2 people authored and joncha1 committed Mar 20, 2024
1 parent e6f7db2 commit 6aa0e6a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 26 deletions.
6 changes: 0 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,12 +604,6 @@ func (config *Cloud) Validate(path string, fromCloud bool) error {
if config.LocalFQDN == "" {
return resource.NewConfigValidationFieldRequiredError(path, "local_fqdn")
}
if config.PrimaryOrgID == "" {
return resource.NewConfigValidationFieldRequiredError(path, "primary_org_id")
}
if config.LocationID == "" {
return resource.NewConfigValidationFieldRequiredError(path, "location_id")
}
} else if config.Secret == "" {
return resource.NewConfigValidationFieldRequiredError(path, "secret")
}
Expand Down
16 changes: 0 additions & 16 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,15 +220,6 @@ func TestConfigEnsure(t *testing.T) {
test.That(t, err, test.ShouldNotBeNil)
test.That(t, resource.GetFieldFromFieldRequiredError(err), test.ShouldEqual, "local_fqdn")
invalidCloud.Cloud.LocalFQDN = "yeeself"
err = invalidCloud.Ensure(true, logger)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, resource.GetFieldFromFieldRequiredError(err), test.ShouldEqual, "primary_org_id")
invalidCloud.Cloud.PrimaryOrgID = "the-primary-org"
err = invalidCloud.Ensure(true, logger)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, resource.GetFieldFromFieldRequiredError(err), test.ShouldEqual, "location_id")
invalidCloud.Cloud.LocationID = "the-location"
test.That(t, invalidCloud.Ensure(true, logger), test.ShouldBeNil)

invalidRemotes := config.Config{
DisablePartialStart: true,
Expand Down Expand Up @@ -485,13 +476,6 @@ func TestConfigEnsurePartialStart(t *testing.T) {
test.That(t, err, test.ShouldNotBeNil)
test.That(t, resource.GetFieldFromFieldRequiredError(err), test.ShouldEqual, "local_fqdn")
invalidCloud.Cloud.LocalFQDN = "yeeself"
err = invalidCloud.Ensure(true, logger)
test.That(t, resource.GetFieldFromFieldRequiredError(err), test.ShouldEqual, "primary_org_id")
invalidCloud.Cloud.PrimaryOrgID = "the-primary-org"
err = invalidCloud.Ensure(true, logger)
test.That(t, err, test.ShouldNotBeNil)
test.That(t, resource.GetFieldFromFieldRequiredError(err), test.ShouldEqual, "location_id")
invalidCloud.Cloud.LocationID = "the-location"

test.That(t, invalidCloud.Ensure(true, logger), test.ShouldBeNil)

Expand Down
13 changes: 9 additions & 4 deletions config/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ var (
DateCompiled = ""
)

const (
initialReadTimeout = 1 * time.Second
readTimeout = 5 * time.Second
)

func getAgentInfo() (*apppb.AgentInfo, error) {
hostname, err := os.Hostname()
if err != nil {
Expand Down Expand Up @@ -252,9 +257,9 @@ func readFromCloud(
)
// use shouldReadFromCache determine whether this is part of initial read or not
if shouldReadFromCache {
ctxWithTimeout, cancel = context.WithTimeout(ctx, 500*time.Millisecond)
ctxWithTimeout, cancel = context.WithTimeout(ctx, initialReadTimeout)
} else {
ctxWithTimeout, cancel = context.WithTimeout(ctx, 5*time.Second)
ctxWithTimeout, cancel = context.WithTimeout(ctx, readTimeout)
}
// Use the SignalingInsecure from the Cloud config returned from the app not the initial config.
certData, err := readCertificateDataFromCloudGRPC(ctxWithTimeout, cfg.Cloud.SignalingInsecure, cloudCfg, logger)
Expand Down Expand Up @@ -609,9 +614,9 @@ func getFromCloudOrCache(ctx context.Context, cloudCfg *Cloud, shouldReadFromCac
)
// use shouldReadFromCache determine whether this is part of initial read or not
if shouldReadFromCache {
ctxWithTimeout, cancel = context.WithTimeout(ctx, 500*time.Millisecond)
ctxWithTimeout, cancel = context.WithTimeout(ctx, initialReadTimeout)
} else {
ctxWithTimeout, cancel = context.WithTimeout(ctx, 5*time.Second)
ctxWithTimeout, cancel = context.WithTimeout(ctx, readTimeout)
}
defer cancel()

Expand Down

0 comments on commit 6aa0e6a

Please sign in to comment.