Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion host/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.25.0
1.25.1-dev
30 changes: 18 additions & 12 deletions host/cmd/hostmgr/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ var (
hostmgr.AllowHostDiscoveryValue,
hostmgr.AllowHostDiscoveryDescription,
)
disabledProvisioning = flag.Bool(
hostmgr.DisabledProvisioning,
hostmgr.DisabledProvisioningValue,
hostmgr.DisabledProvisioningDescription,
)
enableAuth = flag.Bool(rbac.EnableAuth, true, rbac.EnableAuthDescription)
rbacRules = flag.String(rbac.RbacRules, "/rego/authz.rego", rbac.RbacRulesDescription)
invCacheUUIDEnable = flag.Bool(client.InvCacheUUIDEnable, false, client.InvCacheUUIDEnableDescription)
Expand Down Expand Up @@ -104,18 +109,19 @@ func main() {
flag.Parse()

conf := config.HostMgrConfig{
EnableTracing: *enableTracing,
EnableMetrics: *enableMetrics,
TraceURL: *traceURL,
InventoryAddr: *invsvcaddr,
CACertPath: *caCertPath,
TLSKeyPath: *tlsKeyPath,
TLSCertPath: *tlsCertPath,
InsecureGRPC: *insecureGrpc,
EnableHostDiscovery: *allowHostDiscovery,
EnableUUIDCache: *invCacheUUIDEnable,
UUIDCacheTTL: *invCacheStaleTimeout,
UUIDCacheTTLOffset: int(*invCacheStaleTimeoutOffset),
EnableTracing: *enableTracing,
EnableMetrics: *enableMetrics,
TraceURL: *traceURL,
InventoryAddr: *invsvcaddr,
CACertPath: *caCertPath,
TLSKeyPath: *tlsKeyPath,
TLSCertPath: *tlsCertPath,
InsecureGRPC: *insecureGrpc,
EnableHostDiscovery: *allowHostDiscovery,
DisabledProvisioning: *disabledProvisioning,
EnableUUIDCache: *invCacheUUIDEnable,
UUIDCacheTTL: *invCacheStaleTimeout,
UUIDCacheTTLOffset: int(*invCacheStaleTimeoutOffset),
}
if err := conf.Validate(); err != nil {
zlog.InfraSec().Fatal().Err(err).Msgf("Failed to start due to invalid configuration: %v", conf)
Expand Down
25 changes: 13 additions & 12 deletions host/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@ import (

// HostMgrConfig contains configuration for the host manager..
type HostMgrConfig struct {
EnableTracing bool
EnableMetrics bool
TraceURL string
InventoryAddr string
CACertPath string
TLSKeyPath string
TLSCertPath string
InsecureGRPC bool
EnableHostDiscovery bool
EnableUUIDCache bool
UUIDCacheTTL time.Duration
UUIDCacheTTLOffset int
EnableTracing bool
EnableMetrics bool
TraceURL string
InventoryAddr string
CACertPath string
TLSKeyPath string
TLSCertPath string
InsecureGRPC bool
EnableHostDiscovery bool
DisabledProvisioning bool
EnableUUIDCache bool
UUIDCacheTTL time.Duration
UUIDCacheTTLOffset int
}

// Validate checks if the configuration is valid.
Expand Down
12 changes: 7 additions & 5 deletions host/pkg/hostmgr/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (s *server) UpdateHostSystemInfoByGUID(ctx context.Context,
"Host tID=%s, UUID=%s is not trusted, the message will not be handled", tenantID, guid)
}

if hmgr_util.IsHostNotProvisioned(hostres) {
if !DisabledProvisioningValue && hmgr_util.IsHostNotProvisioned(hostres) {
zlog.InfraSec().
InfraError("Host tID=%s, UUID=%s is not yet provisioned, skipping update", tenantID, hostres.GetUuid()).
Msg("UpdateHostSystemInfoByGUID")
Expand Down Expand Up @@ -190,9 +190,11 @@ func (s *server) UpdateInstanceStateStatusByHostGUID(
return nil, err
}

err = updateInstanceStateStatusByHostGUID(ctx, tenantID, host.GetInstance(), in)
if err != nil {
return nil, inv_errors.ErrorToSanitizedGrpcError(err)
if !DisabledProvisioningValue {
err = updateInstanceStateStatusByHostGUID(ctx, tenantID, host.GetInstance(), in)
if err != nil {
return nil, inv_errors.ErrorToSanitizedGrpcError(err)
}
}

return &pb.UpdateInstanceStateStatusByHostGUIDResponse{}, nil
Expand All @@ -213,7 +215,7 @@ func (s *server) updateHostStatusIfNeeded(
return nil
}

if hmgr_util.IsHostNotProvisioned(host) {
if !DisabledProvisioningValue && hmgr_util.IsHostNotProvisioned(host) {
zlog.InfraSec().
InfraError("Skip updating instance state for host tID=%s, UUID=%s (not provisioned)", tenantID, host.GetUuid()).
Msg("UpdateInstanceStateStatusByHostGUID")
Expand Down
14 changes: 11 additions & 3 deletions host/pkg/hostmgr/hostmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,20 @@ var zlog = logging.GetLogger("HostManager")

// TODO(max): remove global instances.
var (
invClientInstance inv_client.TenantAwareInventoryClient
AllowHostDiscoveryValue = true // Default value in flag
invClientInstance inv_client.TenantAwareInventoryClient
AllowHostDiscoveryValue = true // Default value in flag
DisabledProvisioningValue = true // Default value in flag // NOTE: set to true only for testing, should be false in production
)

const (
// AllowHostDiscovery enables automatic host discovery.
AllowHostDiscovery = "allowHostDiscovery"
// AllowHostDiscoveryDescription provides description of the AllowHostDiscovery flag.
AllowHostDiscoveryDescription = "Flag to allow Host discovery automatically when it does not exist in the Inventory"
// DisabledProvisioning toggles provisioning-related checks in the host manager.
DisabledProvisioning = "disabledProvisioning"
// DisabledProvisioningDescription provides description of the DisabledProvisioning flag.
DisabledProvisioningDescription = "Flag to disable provisioning checks for host updates"
// Backoff config for retrying the SetHostConnectionLost.
backoffInterval = 5 * time.Second
backoffRetries = uint64(5)
Expand Down Expand Up @@ -113,7 +118,9 @@ func StartInvGrpcCli(
ctx := context.Background()
resourceKinds := []inv_v1.ResourceKind{
inv_v1.ResourceKind_RESOURCE_KIND_HOST,
inv_v1.ResourceKind_RESOURCE_KIND_INSTANCE,
}
if !conf.DisabledProvisioning {
resourceKinds = append(resourceKinds, inv_v1.ResourceKind_RESOURCE_KIND_INSTANCE)
}
zlog.InfraSec().Info().Msg("initial Inv Grpc Client start.")

Expand Down Expand Up @@ -151,6 +158,7 @@ func StartInvGrpcCli(
SetInvGrpcCli(gcli)
zlog.InfraSec().Info().Msg("initial Grpc Client preparation is done.")
AllowHostDiscoveryValue = conf.EnableHostDiscovery
DisabledProvisioningValue = conf.DisabledProvisioning

return gcli, events, nil
}
Expand Down
Loading