You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

161 lines
5.6 KiB

File Path Configuration TTL Validation (#4376) * compatibility patch for csi driver * added namespace to all component parameters * added namespace to all component parameters * dereference in range * added namespace to values.yml defaults * added namespace to s3 component * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * push on all tags * push on all tags * push on all tags * push on all tags * push on all tags * changed helm directory structure * update charts location * fixed dereference * updated permissions * updated permissions * match current action schema * added helm chart liniting CI * modified chart list changed * fixed nodejs warning * standardized a few defaults * added chart dirs * lowerd period seconds for volume startup to test chart lint changes * lowerd period seconds for volume startup to test chart lint changes * test * changed back * adjustment * debug ls statment * removed change detection * remvoed change detection * always lint the charts * added missing ) * fixed typo * added spaces in front of all comments * pdated values.yaml * pdated values.yaml * don't validate maintainers for now * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * - adds helm chart lint on changes - adds test helm chart install on k8s * updated helm chart readme.md * added artifact hub * added artifact hub * added ttl validation
2 years ago
3 months ago
4 years ago
File Path Configuration TTL Validation (#4376) * compatibility patch for csi driver * added namespace to all component parameters * added namespace to all component parameters * dereference in range * added namespace to values.yml defaults * added namespace to s3 component * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * push on all tags * push on all tags * push on all tags * push on all tags * push on all tags * changed helm directory structure * update charts location * fixed dereference * updated permissions * updated permissions * match current action schema * added helm chart liniting CI * modified chart list changed * fixed nodejs warning * standardized a few defaults * added chart dirs * lowerd period seconds for volume startup to test chart lint changes * lowerd period seconds for volume startup to test chart lint changes * test * changed back * adjustment * debug ls statment * removed change detection * remvoed change detection * always lint the charts * added missing ) * fixed typo * added spaces in front of all comments * pdated values.yaml * pdated values.yaml * don't validate maintainers for now * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * - adds helm chart lint on changes - adds test helm chart install on k8s * updated helm chart readme.md * added artifact hub * added artifact hub * added ttl validation
2 years ago
3 years ago
4 years ago
4 years ago
4 years ago
File Path Configuration TTL Validation (#4376) * compatibility patch for csi driver * added namespace to all component parameters * added namespace to all component parameters * dereference in range * added namespace to values.yml defaults * added namespace to s3 component * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * push on all tags * push on all tags * push on all tags * push on all tags * push on all tags * changed helm directory structure * update charts location * fixed dereference * updated permissions * updated permissions * match current action schema * added helm chart liniting CI * modified chart list changed * fixed nodejs warning * standardized a few defaults * added chart dirs * lowerd period seconds for volume startup to test chart lint changes * lowerd period seconds for volume startup to test chart lint changes * test * changed back * adjustment * debug ls statment * removed change detection * remvoed change detection * always lint the charts * added missing ) * fixed typo * added spaces in front of all comments * pdated values.yaml * pdated values.yaml * don't validate maintainers for now * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * - adds helm chart lint on changes - adds test helm chart install on k8s * updated helm chart readme.md * added artifact hub * added artifact hub * added ttl validation
2 years ago
adjusted regex to be from 1 to 255 for the value (#4377) * compatibility patch for csi driver * added namespace to all component parameters * added namespace to all component parameters * dereference in range * added namespace to values.yml defaults * added namespace to s3 component * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * push on all tags * push on all tags * push on all tags * push on all tags * push on all tags * changed helm directory structure * update charts location * fixed dereference * updated permissions * updated permissions * match current action schema * added helm chart liniting CI * modified chart list changed * fixed nodejs warning * standardized a few defaults * added chart dirs * lowerd period seconds for volume startup to test chart lint changes * lowerd period seconds for volume startup to test chart lint changes * test * changed back * adjustment * debug ls statment * removed change detection * remvoed change detection * always lint the charts * added missing ) * fixed typo * added spaces in front of all comments * pdated values.yaml * pdated values.yaml * don't validate maintainers for now * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * - adds helm chart lint on changes - adds test helm chart install on k8s * updated helm chart readme.md * added artifact hub * added artifact hub * added ttl validation * adjusted regex to be from 1 to 255 for the value * added better error message * fixed regex
2 years ago
File Path Configuration TTL Validation (#4376) * compatibility patch for csi driver * added namespace to all component parameters * added namespace to all component parameters * dereference in range * added namespace to values.yml defaults * added namespace to s3 component * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * push on all tags * push on all tags * push on all tags * push on all tags * push on all tags * changed helm directory structure * update charts location * fixed dereference * updated permissions * updated permissions * match current action schema * added helm chart liniting CI * modified chart list changed * fixed nodejs warning * standardized a few defaults * added chart dirs * lowerd period seconds for volume startup to test chart lint changes * lowerd period seconds for volume startup to test chart lint changes * test * changed back * adjustment * debug ls statment * removed change detection * remvoed change detection * always lint the charts * added missing ) * fixed typo * added spaces in front of all comments * pdated values.yaml * pdated values.yaml * don't validate maintainers for now * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * - adds helm chart lint on changes - adds test helm chart install on k8s * updated helm chart readme.md * added artifact hub * added artifact hub * added ttl validation
2 years ago
adjusted regex to be from 1 to 255 for the value (#4377) * compatibility patch for csi driver * added namespace to all component parameters * added namespace to all component parameters * dereference in range * added namespace to values.yml defaults * added namespace to s3 component * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * push on all tags * push on all tags * push on all tags * push on all tags * push on all tags * changed helm directory structure * update charts location * fixed dereference * updated permissions * updated permissions * match current action schema * added helm chart liniting CI * modified chart list changed * fixed nodejs warning * standardized a few defaults * added chart dirs * lowerd period seconds for volume startup to test chart lint changes * lowerd period seconds for volume startup to test chart lint changes * test * changed back * adjustment * debug ls statment * removed change detection * remvoed change detection * always lint the charts * added missing ) * fixed typo * added spaces in front of all comments * pdated values.yaml * pdated values.yaml * don't validate maintainers for now * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * - adds helm chart lint on changes - adds test helm chart install on k8s * updated helm chart readme.md * added artifact hub * added artifact hub * added ttl validation * adjusted regex to be from 1 to 255 for the value * added better error message * fixed regex
2 years ago
File Path Configuration TTL Validation (#4376) * compatibility patch for csi driver * added namespace to all component parameters * added namespace to all component parameters * dereference in range * added namespace to values.yml defaults * added namespace to s3 component * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * added helm chart to github pages * push on all tags * push on all tags * push on all tags * push on all tags * push on all tags * changed helm directory structure * update charts location * fixed dereference * updated permissions * updated permissions * match current action schema * added helm chart liniting CI * modified chart list changed * fixed nodejs warning * standardized a few defaults * added chart dirs * lowerd period seconds for volume startup to test chart lint changes * lowerd period seconds for volume startup to test chart lint changes * test * changed back * adjustment * debug ls statment * removed change detection * remvoed change detection * always lint the charts * added missing ) * fixed typo * added spaces in front of all comments * pdated values.yaml * pdated values.yaml * don't validate maintainers for now * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * update helm_ci.yml * - adds helm chart lint on changes - adds test helm chart install on k8s * updated helm chart readme.md * added artifact hub * added artifact hub * added ttl validation
2 years ago
4 years ago
4 years ago
4 years ago
  1. package shell
  2. import (
  3. "bytes"
  4. "flag"
  5. "fmt"
  6. "io"
  7. "regexp"
  8. "strings"
  9. "github.com/seaweedfs/seaweedfs/weed/filer"
  10. "github.com/seaweedfs/seaweedfs/weed/pb/filer_pb"
  11. "github.com/seaweedfs/seaweedfs/weed/storage/super_block"
  12. )
  13. func init() {
  14. Commands = append(Commands, &commandFsConfigure{})
  15. }
  16. type commandFsConfigure struct {
  17. }
  18. func (c *commandFsConfigure) Name() string {
  19. return "fs.configure"
  20. }
  21. func (c *commandFsConfigure) Help() string {
  22. return `configure and apply storage options for each location
  23. # see the current configuration file content
  24. fs.configure
  25. # trying the changes and see the possible configuration file content
  26. fs.configure -locationPrefix=/my/folder -collection=abc
  27. fs.configure -locationPrefix=/my/folder -collection=abc -ttl=7d
  28. # example: configure adding only 1 physical volume for each bucket collection
  29. fs.configure -locationPrefix=/buckets/ -volumeGrowthCount=1
  30. # apply the changes
  31. fs.configure -locationPrefix=/my/folder -collection=abc -apply
  32. # delete the changes
  33. fs.configure -locationPrefix=/my/folder -delete -apply
  34. `
  35. }
  36. func (c *commandFsConfigure) HasTag(CommandTag) bool {
  37. return false
  38. }
  39. func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
  40. fsConfigureCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
  41. locationPrefix := fsConfigureCommand.String("locationPrefix", "", "path prefix, required to update the path-specific configuration")
  42. collection := fsConfigureCommand.String("collection", "", "assign writes to this collection")
  43. replication := fsConfigureCommand.String("replication", "", "assign writes with this replication")
  44. ttl := fsConfigureCommand.String("ttl", "", "assign writes with this ttl (e.g., 1m, 1h, 1d, 1w, 1y)")
  45. diskType := fsConfigureCommand.String("disk", "", "[hdd|ssd|<tag>] hard drive or solid state drive or any tag")
  46. fsync := fsConfigureCommand.Bool("fsync", false, "fsync for the writes")
  47. isReadOnly := fsConfigureCommand.Bool("readOnly", false, "disable writes")
  48. worm := fsConfigureCommand.Bool("worm", false, "write-once-read-many, written files are readonly")
  49. wormGracePeriod := fsConfigureCommand.Uint64("wormGracePeriod", 0, "grace period before worm is enforced, in seconds")
  50. wormRetentionTime := fsConfigureCommand.Uint64("wormRetentionTime", 0, "retention time for a worm enforced file, in seconds")
  51. maxFileNameLength := fsConfigureCommand.Uint("maxFileNameLength", 0, "file name length limits in bytes for compatibility with Unix-based systems")
  52. dataCenter := fsConfigureCommand.String("dataCenter", "", "assign writes to this dataCenter")
  53. rack := fsConfigureCommand.String("rack", "", "assign writes to this rack")
  54. dataNode := fsConfigureCommand.String("dataNode", "", "assign writes to this dataNode")
  55. volumeGrowthCount := fsConfigureCommand.Int("volumeGrowthCount", 0, "the number of physical volumes to add if no writable volumes")
  56. isDelete := fsConfigureCommand.Bool("delete", false, "delete the configuration by locationPrefix")
  57. apply := fsConfigureCommand.Bool("apply", false, "update and apply filer configuration")
  58. if err = fsConfigureCommand.Parse(args); err != nil {
  59. return nil
  60. }
  61. fc, err := filer.ReadFilerConf(commandEnv.option.FilerAddress, commandEnv.option.GrpcDialOption, commandEnv.MasterClient)
  62. if err != nil {
  63. return err
  64. }
  65. if *locationPrefix != "" {
  66. infoAboutSimulationMode(writer, *apply, "-apply")
  67. locConf := &filer_pb.FilerConf_PathConf{
  68. LocationPrefix: *locationPrefix,
  69. Collection: *collection,
  70. Replication: *replication,
  71. Ttl: *ttl,
  72. Fsync: *fsync,
  73. MaxFileNameLength: uint32(*maxFileNameLength),
  74. DiskType: *diskType,
  75. VolumeGrowthCount: uint32(*volumeGrowthCount),
  76. ReadOnly: *isReadOnly,
  77. DataCenter: *dataCenter,
  78. Rack: *rack,
  79. DataNode: *dataNode,
  80. Worm: *worm,
  81. WormGracePeriodSeconds: *wormGracePeriod,
  82. WormRetentionTimeSeconds: *wormRetentionTime,
  83. }
  84. // check collection
  85. if *collection != "" && strings.HasPrefix(*locationPrefix, "/buckets/") {
  86. return fmt.Errorf("one s3 bucket goes to one collection and not customizable")
  87. }
  88. // check replication
  89. if *replication != "" {
  90. rp, err := super_block.NewReplicaPlacementFromString(*replication)
  91. if err != nil {
  92. return fmt.Errorf("parse replication %s: %v", *replication, err)
  93. }
  94. if *volumeGrowthCount%rp.GetCopyCount() != 0 {
  95. return fmt.Errorf("volumeGrowthCount %d should be divided by replication copy count %d", *volumeGrowthCount, rp.GetCopyCount())
  96. }
  97. }
  98. // check ttl
  99. if *ttl != "" {
  100. regex := "^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)[mhdwMy]$"
  101. match, _ := regexp.MatchString(regex, *ttl)
  102. if !match {
  103. return fmt.Errorf("ttl should be of the following format [1 to 255][unit] (e.g., 5m, 2h, 180d, 1w, 2y)")
  104. }
  105. }
  106. // save it
  107. if *isDelete {
  108. fc.DeleteLocationConf(*locationPrefix)
  109. } else {
  110. fc.AddLocationConf(locConf)
  111. }
  112. }
  113. var buf2 bytes.Buffer
  114. fc.ToText(&buf2)
  115. fmt.Fprintf(writer, string(buf2.Bytes()))
  116. fmt.Fprintln(writer)
  117. if *apply {
  118. if err = commandEnv.WithFilerClient(false, func(client filer_pb.SeaweedFilerClient) error {
  119. return filer.SaveInsideFiler(client, filer.DirectoryEtcSeaweedFS, filer.FilerConfName, buf2.Bytes())
  120. }); err != nil && err != filer_pb.ErrNotFound {
  121. return err
  122. }
  123. }
  124. return nil
  125. }
  126. func infoAboutSimulationMode(writer io.Writer, forceMode bool, forceModeOption string) {
  127. if forceMode {
  128. return
  129. }
  130. fmt.Fprintf(writer, "Running in simulation mode. Use \"%s\" option to apply the changes.\n", forceModeOption)
  131. }