Documentation ¶
Index ¶
- Constants
- Variables
- func AmendTaskExtraAttr(origin, new string) string
- func CheckFileLength(filepath string) error
- func CheckMailType(mailtype string) bool
- func CheckNameValid(name string) bool
- func CheckNodeList(nodeStr string) bool
- func CheckTaskArgs(task *protos.TaskToCtld) error
- func CheckTaskExtraAttr(attr string) bool
- func DetectNetworkProxy()
- func ErrMsg(err_code protos.ErrCode) string
- func FormatTable(tableOutputWidth []int, tableHeader []string, tableData [][]string) (formatTableHeader []string, formatTableData [][]string)
- func FoundFirstNumberWithoutBrackets(input string) (int, int, bool)
- func GetParentProcessID(pid int) (int, error)
- func GetPidFromPort(port uint16) (int, error)
- func GetStubToCtldByConfig(config *Config) protos.CraneCtldClient
- func GetTCPSocket(bindAddr string, config *Config) (net.Listener, error)
- func GetUnixSocket(path string, mode fs.FileMode) (net.Listener, error)
- func GrpcErrorPrintf(err error, format string, a ...any)
- func HostNameListToStr(hostList []string) string
- func HostNameListToStr_(hostList []string) ([]string, bool)
- func InitLogger(level string)
- func InvalidDuration() *durationpb.Duration
- func IsForeground() bool
- func NixShell(uid string) (string, error)
- func ParseDuration(time string, duration *durationpb.Duration) bool
- func ParseFloatWithPrecision(val string, decimalPlaces int) (float64, error)
- func ParseGres(gres string) *protos.DeviceMap
- func ParseHostList(hostStr string) ([]string, bool)
- func ParseInRamTaskStatusList(statesStr string) ([]protos.TaskStatus, error)
- func ParseInterval(interval string, intervalpb *protos.TimeInterval) (err error)
- func ParseJobIdList(jobIds string, splitStr string) ([]uint32, error)
- func ParseMemStringAsByte(mem string) (uint64, error)
- func ParseNodeList(nodeStr string) ([]string, bool)
- func ParseStringParamList(parameters string, splitStr string) ([]string, error)
- func ParseTaskStatusList(statesStr string) ([]protos.TaskStatus, error)
- func ParseTaskStatusName(state string) (protos.TaskStatus, error)
- func ParseTime(ts string) (time.Time, error)
- func RemoveBracketsWithoutDashOrComma(input string) string
- func RemoveFileIfExists(path string) bool
- func SecondTimeFormat(second int64) string
- func SetBorderTable(table *tablewriter.Table)
- func SetBorderlessTable(table *tablewriter.Table)
- func SetPropagatedEnviron(task *protos.TaskToCtld)
- func SplitEnvironEntry(env *string) (string, string, bool)
- func TcGetpgrp(fd int) (pgrp int, err error)
- func TcSetpgrp(fd int, pgrp int) (err error)
- func TrimTable(rows *[][]string)
- func TrimTableExcept(rows *[][]string, excepts ...int)
- func Version() string
- func VersionTemplate() string
- type Config
- type CraneCmdError
- type Formatter
- type FormatterJson
- type PluginConfig
Constants ¶
const ( DefaultConfigPath = "/etc/crane/config.yaml" DefaultCraneBaseDir = "/var/crane/" DefaultPlugindSocketPath = "cplugind/cplugind.sock" DefaultCforedSocketPath = "craned/cfored.sock" DefaultCforedServerListenAddress = "0.0.0.0" DefaultCforedServerListenPort = "10012" MaxJobNameLength = 50 MaxJobFileNameLength = 127 MaxJobFilePathLengthForWindows = 260 - MaxJobFileNameLength MaxJobFilePathLengthForUnix = 4096 - MaxJobFileNameLength MaxJobTimeLimit = 315576000000 // 10000 years MaxJobTimeStamp = 253402300799 // 9999-12-31 23:59:59 )
Path = BaseDir + Dir + Name
Variables ¶
var BUILD_TIME = "Unknown"
var FmtJson = FormatterJson{}
var VERSION = "Unknown"
Functions ¶
func AmendTaskExtraAttr ¶
Merge two JSON strings. If there are overlapping keys, values from the second JSON take precedence.
func CheckFileLength ¶
CheckFileLength check if the file length is within the limit.
func CheckMailType ¶
func CheckNameValid ¶
func CheckNodeList ¶
CheckNodeList check if the node list is comma separated node names. The node name should contain only letters and numbers, and start with a letter, end with a number.
func CheckTaskArgs ¶
func CheckTaskArgs(task *protos.TaskToCtld) error
func CheckTaskExtraAttr ¶
func DetectNetworkProxy ¶
func DetectNetworkProxy()
func FormatTable ¶
func GetParentProcessID ¶
func GetPidFromPort ¶
func GetStubToCtldByConfig ¶
func GetStubToCtldByConfig(config *Config) protos.CraneCtldClient
TODO: Refactor this to return ErrCodes instead of exiting.
func GrpcErrorPrintf ¶
func HostNameListToStr ¶
func HostNameListToStr_ ¶
func InitLogger ¶
func InitLogger(level string)
func InvalidDuration ¶
func InvalidDuration() *durationpb.Duration
func IsForeground ¶
func IsForeground() bool
IsForeground returns true if the calling process is a foreground process.
Note that the foreground/background status of a process can change at any moment if the user utilizes the shell job control commands (fg/bg).
Example use for command line tools: suppress extra output if a process is running in background, provide verbose output when running on foreground.
func ParseDuration ¶
func ParseDuration(time string, duration *durationpb.Duration) bool
func ParseFloatWithPrecision ¶
Parses a string containing a float number with a given precision.
func ParseHostList ¶
func ParseInRamTaskStatusList ¶
func ParseInRamTaskStatusList(statesStr string) ([]protos.TaskStatus, error)
func ParseInterval ¶
func ParseInterval(interval string, intervalpb *protos.TimeInterval) (err error)
func ParseMemStringAsByte ¶
func ParseNodeList ¶
func ParseStringParamList ¶
func ParseTaskStatusList ¶
func ParseTaskStatusList(statesStr string) ([]protos.TaskStatus, error)
func ParseTaskStatusName ¶
func ParseTaskStatusName(state string) (protos.TaskStatus, error)
func RemoveFileIfExists ¶
func SecondTimeFormat ¶
func SetBorderTable ¶
func SetBorderTable(table *tablewriter.Table)
func SetBorderlessTable ¶
func SetBorderlessTable(table *tablewriter.Table)
func SetPropagatedEnviron ¶
func SetPropagatedEnviron(task *protos.TaskToCtld)
func TcGetpgrp ¶
TcGetpgrp gets the process group ID of the foreground process group associated with the terminal referred to by fd.
See POSIX.1 documentation for more details: http://pubs.opengroup.org/onlinepubs/009695399/functions/tcgetpgrp.html
func TcSetpgrp ¶
TcSetpgrp sets the foreground process group ID associated with the terminal referred to by fd to pgrp.
See POSIX.1 documentation for more details: https://pubs.opengroup.org/onlinepubs/9699919799/functions/tcsetpgrp.html
func TrimTable ¶
func TrimTable(rows *[][]string)
Trim the cell of the table, if the cell is longer than 30 characters, the rest of the characters will be replaced by `...`.
func TrimTableExcept ¶
Trim the cell of the table, if the cell is longer than 30 characters, the rest of the characters will be replaced by `...`. `excepts` means do not trim the specified columns
func VersionTemplate ¶
func VersionTemplate() string
Types ¶
type Config ¶
type Config struct { ControlMachine string `yaml:"ControlMachine"` CraneCtldListenPort string `yaml:"CraneCtldListenPort"` UseTls bool `yaml:"UseTls"` ServerCertFilePath string `yaml:"ServerCertFilePath"` ServerKeyFilePath string `yaml:"ServerKeyFilePath"` CaCertFilePath string `yaml:"CaCertFilePath"` DomainSuffix string `yaml:"DomainSuffix"` CraneBaseDir string `yaml:"CraneBaseDir"` CranedCforedSockPath string `yaml:"CranedCforedSockPath"` Plugin PluginConfig `yaml:"Plugin"` }
func ParseConfig ¶
TODO: Refactor this to return ErrCodes instead of exiting.
type CraneCmdError ¶
type CraneCmdError = int
const ( ErrorSuccess CraneCmdError = 0 ErrorGeneric CraneCmdError = 1 ErrorCmdArg CraneCmdError = 2 ErrorNetwork CraneCmdError = 3 ErrorBackend CraneCmdError = 4 ErrorInvalidFormat CraneCmdError = 5 )
general
type FormatterJson ¶
type FormatterJson struct { }
JSON
func (FormatterJson) FormatReply ¶
func (f FormatterJson) FormatReply(reply interface{}) string
type PluginConfig ¶
type PluginConfig struct { Enabled bool `yaml:"Enabled"` SockPath string `yaml:"PlugindSockPath"` LogLevel string `yaml:"PlugindDebugLevel"` Plugins []api.PluginMeta `yaml:"Plugins"` }