github.com/juju/juju@v0.0.0-20240430160146-1752b71fcf00/controller/configschema.go (about)

     1  // Copyright 2023 Canonical Ltd.
     2  // Licensed under the AGPLv3, see LICENCE file for details.
     3  
     4  package controller
     5  
     6  import (
     7  	"fmt"
     8  
     9  	"github.com/juju/romulus"
    10  	"github.com/juju/schema"
    11  	"gopkg.in/juju/environschema.v1"
    12  )
    13  
    14  var configChecker = schema.FieldMap(schema.Fields{
    15  	AgentRateLimitMax:                schema.ForceInt(),
    16  	AgentRateLimitRate:               schema.TimeDuration(),
    17  	AuditingEnabled:                  schema.Bool(),
    18  	AuditLogCaptureArgs:              schema.Bool(),
    19  	AuditLogMaxSize:                  schema.String(),
    20  	AuditLogMaxBackups:               schema.ForceInt(),
    21  	AuditLogExcludeMethods:           schema.List(schema.String()),
    22  	APIPort:                          schema.ForceInt(),
    23  	APIPortOpenDelay:                 schema.TimeDuration(),
    24  	ControllerAPIPort:                schema.ForceInt(),
    25  	ControllerName:                   schema.String(),
    26  	StatePort:                        schema.ForceInt(),
    27  	LoginTokenRefreshURL:             schema.String(),
    28  	IdentityURL:                      schema.String(),
    29  	IdentityPublicKey:                schema.String(),
    30  	SetNUMAControlPolicyKey:          schema.Bool(),
    31  	AutocertURLKey:                   schema.String(),
    32  	AutocertDNSNameKey:               schema.String(),
    33  	AllowModelAccessKey:              schema.Bool(),
    34  	MongoMemoryProfile:               schema.String(),
    35  	JujuDBSnapChannel:                schema.String(),
    36  	MaxDebugLogDuration:              schema.TimeDuration(),
    37  	MaxTxnLogSize:                    schema.String(),
    38  	MaxPruneTxnBatchSize:             schema.ForceInt(),
    39  	MaxPruneTxnPasses:                schema.ForceInt(),
    40  	AgentLogfileMaxBackups:           schema.ForceInt(),
    41  	AgentLogfileMaxSize:              schema.String(),
    42  	ModelLogfileMaxBackups:           schema.ForceInt(),
    43  	ModelLogfileMaxSize:              schema.String(),
    44  	ModelLogsSize:                    schema.String(),
    45  	PruneTxnQueryCount:               schema.ForceInt(),
    46  	PruneTxnSleepTime:                schema.TimeDuration(),
    47  	PublicDNSAddress:                 schema.String(),
    48  	JujuHASpace:                      schema.String(),
    49  	JujuManagementSpace:              schema.String(),
    50  	CAASOperatorImagePath:            schema.String(),
    51  	CAASImageRepo:                    schema.String(),
    52  	Features:                         schema.List(schema.String()),
    53  	MeteringURL:                      schema.String(),
    54  	MaxCharmStateSize:                schema.ForceInt(),
    55  	MaxAgentStateSize:                schema.ForceInt(),
    56  	MigrationMinionWaitMax:           schema.TimeDuration(),
    57  	ApplicationResourceDownloadLimit: schema.ForceInt(),
    58  	ControllerResourceDownloadLimit:  schema.ForceInt(),
    59  	QueryTracingEnabled:              schema.Bool(),
    60  	QueryTracingThreshold:            schema.TimeDuration(),
    61  	JujudControllerSnapSource:        schema.String(),
    62  }, schema.Defaults{
    63  	AgentRateLimitMax:                schema.Omit,
    64  	AgentRateLimitRate:               schema.Omit,
    65  	APIPort:                          DefaultAPIPort,
    66  	APIPortOpenDelay:                 DefaultAPIPortOpenDelay,
    67  	ControllerAPIPort:                schema.Omit,
    68  	ControllerName:                   schema.Omit,
    69  	AuditingEnabled:                  DefaultAuditingEnabled,
    70  	AuditLogCaptureArgs:              DefaultAuditLogCaptureArgs,
    71  	AuditLogMaxSize:                  fmt.Sprintf("%vM", DefaultAuditLogMaxSizeMB),
    72  	AuditLogMaxBackups:               DefaultAuditLogMaxBackups,
    73  	AuditLogExcludeMethods:           DefaultAuditLogExcludeMethods,
    74  	StatePort:                        DefaultStatePort,
    75  	LoginTokenRefreshURL:             schema.Omit,
    76  	IdentityURL:                      schema.Omit,
    77  	IdentityPublicKey:                schema.Omit,
    78  	SetNUMAControlPolicyKey:          DefaultNUMAControlPolicy,
    79  	AutocertURLKey:                   schema.Omit,
    80  	AutocertDNSNameKey:               schema.Omit,
    81  	AllowModelAccessKey:              schema.Omit,
    82  	MongoMemoryProfile:               DefaultMongoMemoryProfile,
    83  	JujuDBSnapChannel:                DefaultJujuDBSnapChannel,
    84  	MaxDebugLogDuration:              DefaultMaxDebugLogDuration,
    85  	MaxTxnLogSize:                    fmt.Sprintf("%vM", DefaultMaxTxnLogCollectionMB),
    86  	MaxPruneTxnBatchSize:             DefaultMaxPruneTxnBatchSize,
    87  	MaxPruneTxnPasses:                DefaultMaxPruneTxnPasses,
    88  	AgentLogfileMaxBackups:           DefaultAgentLogfileMaxBackups,
    89  	AgentLogfileMaxSize:              fmt.Sprintf("%vM", DefaultAgentLogfileMaxSize),
    90  	ModelLogfileMaxBackups:           DefaultModelLogfileMaxBackups,
    91  	ModelLogfileMaxSize:              fmt.Sprintf("%vM", DefaultModelLogfileMaxSize),
    92  	ModelLogsSize:                    fmt.Sprintf("%vM", DefaultModelLogsSizeMB),
    93  	PruneTxnQueryCount:               DefaultPruneTxnQueryCount,
    94  	PruneTxnSleepTime:                DefaultPruneTxnSleepTime,
    95  	PublicDNSAddress:                 schema.Omit,
    96  	JujuHASpace:                      schema.Omit,
    97  	JujuManagementSpace:              schema.Omit,
    98  	CAASOperatorImagePath:            schema.Omit,
    99  	CAASImageRepo:                    schema.Omit,
   100  	Features:                         schema.Omit,
   101  	MeteringURL:                      romulus.DefaultAPIRoot,
   102  	MaxCharmStateSize:                DefaultMaxCharmStateSize,
   103  	MaxAgentStateSize:                DefaultMaxAgentStateSize,
   104  	MigrationMinionWaitMax:           DefaultMigrationMinionWaitMax,
   105  	ApplicationResourceDownloadLimit: schema.Omit,
   106  	ControllerResourceDownloadLimit:  schema.Omit,
   107  	QueryTracingEnabled:              DefaultQueryTracingEnabled,
   108  	QueryTracingThreshold:            DefaultQueryTracingThreshold,
   109  	JujudControllerSnapSource:        DefaultJujudControllerSnapSource,
   110  })
   111  
   112  // ConfigSchema holds information on all the fields defined by
   113  // the config package.
   114  var ConfigSchema = environschema.Fields{
   115  	ApplicationResourceDownloadLimit: {
   116  		Description: "The maximum number of concurrent resources downloads per application",
   117  		Type:        environschema.Tint,
   118  	},
   119  	ControllerResourceDownloadLimit: {
   120  		Description: "The maximum number of concurrent resources downloads across all the applications on the controller",
   121  		Type:        environschema.Tint,
   122  	},
   123  	AgentRateLimitMax: {
   124  		Description: "The maximum size of the token bucket used to ratelimit agent connections",
   125  		Type:        environschema.Tint,
   126  	},
   127  	AgentRateLimitRate: {
   128  		Description: "The time taken to add a new token to the ratelimit bucket",
   129  		Type:        environschema.Tstring,
   130  	},
   131  	AuditingEnabled: {
   132  		Description: "Determines if the controller records auditing information",
   133  		Type:        environschema.Tbool,
   134  	},
   135  	AuditLogCaptureArgs: {
   136  		Description: `Determines if the audit log contains the arguments passed to API methods`,
   137  		Type:        environschema.Tbool,
   138  	},
   139  	AuditLogMaxSize: {
   140  		Description: "The maximum size for the current controller audit log file",
   141  		Type:        environschema.Tstring,
   142  	},
   143  	AuditLogMaxBackups: {
   144  		Type:        environschema.Tint,
   145  		Description: "The number of old audit log files to keep (compressed)",
   146  	},
   147  	AuditLogExcludeMethods: {
   148  		Type:        environschema.Tlist,
   149  		Description: "The list of Facade.Method names that aren't interesting for audit logging purposes.",
   150  	},
   151  	APIPort: {
   152  		Type:        environschema.Tint,
   153  		Description: "The port used for api connections",
   154  	},
   155  	APIPortOpenDelay: {
   156  		Type: environschema.Tstring,
   157  		Description: `The duration that the controller will wait 
   158  between when the controller has been deemed to be ready to open 
   159  the api-port and when the api-port is actually opened 
   160  (only used when a controller-api-port value is set).`,
   161  	},
   162  	ControllerAPIPort: {
   163  		Type: environschema.Tint,
   164  		Description: `An optional port that may be set for controllers
   165  that have a very heavy load. If this port is set, this port is used by
   166  the controllers to talk to each other - used for the local API connection
   167  as well as the pubsub forwarders, and the raft workers. If this value is
   168  set, the api-port isn't opened until the controllers have started properly.`,
   169  	},
   170  	StatePort: {
   171  		Type:        environschema.Tint,
   172  		Description: `The port used for mongo connections`,
   173  	},
   174  	LoginTokenRefreshURL: {
   175  		Type:        environschema.Tstring,
   176  		Description: `The url of the jwt well known endpoint`,
   177  	},
   178  	IdentityURL: {
   179  		Type:        environschema.Tstring,
   180  		Description: `The url of the identity manager`,
   181  	},
   182  	IdentityPublicKey: {
   183  		Type:        environschema.Tstring,
   184  		Description: `The public key of the identity manager`,
   185  	},
   186  	SetNUMAControlPolicyKey: {
   187  		Type:        environschema.Tbool,
   188  		Description: `Determines if the NUMA control policy is set`,
   189  	},
   190  	AutocertURLKey: {
   191  		Type:        environschema.Tstring,
   192  		Description: `The URL used to obtain official TLS certificates when a client connects to the API`,
   193  	},
   194  	AutocertDNSNameKey: {
   195  		Type:        environschema.Tstring,
   196  		Description: `The DNS name of the controller`,
   197  	},
   198  	AllowModelAccessKey: {
   199  		Type: environschema.Tbool,
   200  		Description: `Determines if the controller allows users to 
   201  connect to models they have been authorized for even when 
   202  they don't have any access rights to the controller itself`,
   203  	},
   204  	MongoMemoryProfile: {
   205  		Type:        environschema.Tstring,
   206  		Description: `Sets mongo memory profile`,
   207  	},
   208  	JujuDBSnapChannel: {
   209  		Type:        environschema.Tstring,
   210  		Description: `Sets channel for installing mongo snaps when bootstrapping on focal or later`,
   211  	},
   212  	MaxDebugLogDuration: {
   213  		Type:        environschema.Tstring,
   214  		Description: `The maximum duration that a debug-log session is allowed to run`,
   215  	},
   216  	MaxTxnLogSize: {
   217  		Type:        environschema.Tstring,
   218  		Description: `The maximum size the of capped txn log collection`,
   219  	},
   220  	MaxPruneTxnBatchSize: {
   221  		Type:        environschema.Tint,
   222  		Description: `(deprecated) The maximum number of transactions evaluated in one go when pruning`,
   223  	},
   224  	MaxPruneTxnPasses: {
   225  		Type:        environschema.Tint,
   226  		Description: `(deprecated) The maximum number of batches processed when pruning`,
   227  	},
   228  	AgentLogfileMaxBackups: {
   229  		Type:        environschema.Tint,
   230  		Description: "The number of old agent log files to keep (compressed)",
   231  	},
   232  	AgentLogfileMaxSize: {
   233  		Type:        environschema.Tstring,
   234  		Description: `The maximum size of the agent log file`,
   235  	},
   236  	ModelLogfileMaxBackups: {
   237  		Type:        environschema.Tint,
   238  		Description: "The number of old model log files to keep (compressed)",
   239  	},
   240  	ModelLogfileMaxSize: {
   241  		Type:        environschema.Tstring,
   242  		Description: `The maximum size of the log file written out by the controller on behalf of workers running for a model`,
   243  	},
   244  	ModelLogsSize: {
   245  		Type:        environschema.Tstring,
   246  		Description: `The size of the capped collections used to hold the logs for the models`,
   247  	},
   248  	PruneTxnQueryCount: {
   249  		Type:        environschema.Tint,
   250  		Description: `The number of transactions to read in a single query`,
   251  	},
   252  	PruneTxnSleepTime: {
   253  		Type:        environschema.Tstring,
   254  		Description: `The amount of time to sleep between processing each batch query`,
   255  	},
   256  	PublicDNSAddress: {
   257  		Type:        environschema.Tstring,
   258  		Description: `Public DNS address (with port) of the controller.`,
   259  	},
   260  	JujuHASpace: {
   261  		Type:        environschema.Tstring,
   262  		Description: `The network space within which the MongoDB replica-set should communicate`,
   263  	},
   264  	JujuManagementSpace: {
   265  		Type:        environschema.Tstring,
   266  		Description: `The network space that agents should use to communicate with controllers`,
   267  	},
   268  	CAASOperatorImagePath: {
   269  		Type: environschema.Tstring,
   270  		Description: `(deprecated) The url of the docker image used for the application operator.
   271  Use "caas-image-repo" instead.`,
   272  	},
   273  	CAASImageRepo: {
   274  		Type:        environschema.Tstring,
   275  		Description: `The docker repo to use for the jujud operator and mongo images`,
   276  	},
   277  	Features: {
   278  		Type:        environschema.Tlist,
   279  		Description: `A list of runtime changeable features to be updated`,
   280  	},
   281  	MeteringURL: {
   282  		Type:        environschema.Tstring,
   283  		Description: `The url for metrics`,
   284  	},
   285  	MaxCharmStateSize: {
   286  		Type:        environschema.Tint,
   287  		Description: `The maximum size (in bytes) of charm-specific state that units can store to the controller`,
   288  	},
   289  	MaxAgentStateSize: {
   290  		Type:        environschema.Tint,
   291  		Description: `The maximum size (in bytes) of internal state data that agents can store to the controller`,
   292  	},
   293  	MigrationMinionWaitMax: {
   294  		Type:        environschema.Tstring,
   295  		Description: `The maximum during model migrations that the migration worker will wait for agents to report on phases of the migration`,
   296  	},
   297  	QueryTracingEnabled: {
   298  		Type:        environschema.Tbool,
   299  		Description: `Enable query tracing for the dqlite driver`,
   300  	},
   301  	QueryTracingThreshold: {
   302  		Type: environschema.Tstring,
   303  		Description: `The minimum duration of a query for it to be traced. The lower the 
   304  threshold, the more queries will be output. A value of 0 means all queries 
   305  will be output if tracing is enabled.`,
   306  	},
   307  	JujudControllerSnapSource: {
   308  		Type:        environschema.Tstring,
   309  		Description: `The source for the jujud-controller snap.`,
   310  	},
   311  }