Skip to content

Commit

Permalink
Merge pull request #589 from cvaroqui/main
Browse files Browse the repository at this point in the history
mostly tasks
  • Loading branch information
cvaroqui authored Sep 6, 2024
2 parents 7d4efa9 + 3ae85fb commit 178f1b4
Show file tree
Hide file tree
Showing 44 changed files with 1,492 additions and 1,140 deletions.
618 changes: 389 additions & 229 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion core/keywords/keywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func (t Indices) Swap(i, j int) {

func (t Text) String() string {
if b, err := t.fs.ReadFile(t.path); err != nil {
panic("missing documentation text file: " + t.path)
return "TODO"
} else {
return string(b)
}
Expand Down
14 changes: 2 additions & 12 deletions core/manifest/dbkeywords.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,6 @@ var (
Text: keywords.NewText(fs, "text/kw/optional"),
}

KWOptionalTrue = keywords.Keyword{
Attr: "Optional",
Converter: converters.Bool,
Default: "true",
Inherit: keywords.InheritHead2Leaf,
Option: "optional",
Scopable: true,
Text: keywords.NewText(fs, "text/kw/optional"),
}

KWPostProvision = keywords.Keyword{
Attr: "PostProvision",
Option: "post_provision",
Expand Down Expand Up @@ -358,12 +348,12 @@ var (
}

syncerKeywords = []Attr{
KWOptionalTrue,
KWOptional,
KWSyncRequires,
}

runnerKeywords = []Attr{
KWOptionalTrue,
KWOptional,
KWBlockingPostRun,
KWBlockingPreRun,
KWPostRun,
Expand Down
13 changes: 6 additions & 7 deletions core/manifest/text/kw/optional
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Action errors on optional resources are logged but do not stop the action
sequence.
Action errors on optional resources are logged but do not interrupt the action sequence.

The optional resources status is not aggregated in the instance availability
status, but aggregated in the overall status.
The status of optional resources is not included in the instance availability status but is considered in the overall status.

Resource tagged `noaction` and sync resources are considered optional by
default.
The status of task and sync resources is always included in the overall status, regardless of whether they are marked as optional.

Dump filesystems are a typical use-case for `optional=true`.
Resources tagged as `noaction` are considered optional by default.

Dump filesystems are a typical use case for optional=true.
3 changes: 0 additions & 3 deletions core/object/actor_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ func (t *actor) masterRun(ctx context.Context) error {
return t.action(ctx, func(ctx context.Context, r resource.Driver) error {
t.log.Attr("rid", r.RID()).Debugf("run resource")
err := resource.Run(ctx, r)
if err == nil {
return nil
}
if errors.Is(err, resource.ErrActionReqNotMet) && actioncontext.IsCron(ctx) {
return nil
}
Expand Down
8 changes: 7 additions & 1 deletion core/object/actor_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/opensvc/om3/core/actioncontext"
"github.com/opensvc/om3/core/colorstatus"
"github.com/opensvc/om3/core/driver"
"github.com/opensvc/om3/core/instance"
"github.com/opensvc/om3/core/provisioned"
"github.com/opensvc/om3/core/rawconfig"
Expand Down Expand Up @@ -199,7 +200,12 @@ func (t *actor) resourceStatusEval(ctx context.Context, data *instance.Status, m
data.Resources[r.RID()] = xd
data.Overall.Add(xd.Status)
if !xd.Optional {
data.Avail.Add(xd.Status)
switch r.ID().DriverGroup() {
case driver.GroupSync:
case driver.GroupTask:
default:
data.Avail.Add(xd.Status)
}
}
data.Provisioned.Add(xd.Provisioned.State)
mu.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions core/object/keystore_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ func (t *keystore) decode(keyname string) ([]byte, error) {
err error
)
if keyname == "" {
return []byte{}, fmt.Errorf("key name can not be empty")
return []byte{}, KeystoreErrKeyEmpty
}
if !t.HasKey(keyname) {
return []byte{}, fmt.Errorf("key does not exist: %s", keyname)
return []byte{}, fmt.Errorf("%w: %s", KeystoreErrNotExist, keyname)
}
k := keyFromName(keyname)
if s, err = t.config.GetStrict(k); err != nil {
Expand Down
4 changes: 2 additions & 2 deletions core/objectaction/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,8 @@ func rsHumanRender(rs []actionrouter.Result) string {
fmt.Printf("%s\n", r.Error)
}
rs[i].Error = nil
case (r.Error != nil) && fmt.Sprint(r.Error) != "":
log.Error().Msgf("%s: %s", r.Path, r.Error)
// case (r.Error != nil) && fmt.Sprint(r.Error) != "":
// log.Error().Msgf("%s: %s", r.Path, r.Error)
case r.Panic != nil:
switch err := r.Panic.(type) {
case error:
Expand Down
2 changes: 2 additions & 0 deletions core/oxcmd/keystore_decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ func (t *CmdKeystoreDecode) RunForPath(ctx context.Context, c *client.T, path na
return fmt.Errorf("%s: %s", path, *response.JSON403)
case http.StatusInternalServerError:
return fmt.Errorf("%s: %s", path, *response.JSON500)
case http.StatusNotFound:
return fmt.Errorf("%s: %s", path, *response.JSON404)
default:
return fmt.Errorf("%s: unexpected response: %s", path, response.Status())
}
Expand Down
12 changes: 8 additions & 4 deletions core/resourceset/resourceset.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,16 @@ func (t T) doParallel(ctx context.Context, l ResourceLister, resources resource.
nResources := len(resources)
for i := 0; i < nResources; i++ {
res := <-q
if res.Resource.IsOptional() {
switch {
case res.Error == nil:
continue
}
if res.Error != nil {
case res.Resource.IsOptional():
res.Resource.Log().Errorf("error from optional resource: %s", res.Error)
continue
default:
res.Resource.Log().Errorf("%s", res.Error)
errors.Join(errs, fmt.Errorf("%s: %w", res.Resource.RID(), res.Error))
}
errors.Join(errs, fmt.Errorf("%s: %w", res.Resource.RID(), res.Error))
}
return errs
}
Expand All @@ -253,6 +256,7 @@ func (t T) doSerial(ctx context.Context, l ResourceLister, resources resource.Dr
case err == nil:
continue
case r.IsOptional():
r.Log().Warnf("error from optional resource: %s", err)
continue
default:
r.Log().Errorf("%s", err)
Expand Down
2 changes: 2 additions & 0 deletions daemon/api/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2400,6 +2400,8 @@ paths:
$ref: '#/components/responses/401'
403:
$ref: '#/components/responses/403'
404:
$ref: '#/components/responses/403'
500:
$ref: '#/components/responses/500'

Expand Down
8 changes: 8 additions & 0 deletions daemon/api/codegen_client_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 178f1b4

Please sign in to comment.