mirror of
https://github.com/kubesphere/kubekey.git
synced 2025-12-26 01:22:51 +00:00
fix: tag can be inherited
Signed-off-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
parent
4540d3a4cd
commit
22a63e7da8
|
|
@ -58,9 +58,12 @@ func (t Taggable) IsEnabled(onlyTags []string, skipTags []string) bool {
|
|||
|
||||
// JoinTag the child block should inherit tag for parent block
|
||||
func JoinTag(child, parent Taggable) Taggable {
|
||||
for _, tg := range parent.Tags {
|
||||
if !slices.Contains(child.Tags, tg) {
|
||||
child.Tags = append(child.Tags, tg)
|
||||
for _, tag := range parent.Tags {
|
||||
if tag == "always" { // skip inherit "always" tag
|
||||
continue
|
||||
}
|
||||
if !slices.Contains(child.Tags, tag) {
|
||||
child.Tags = append(child.Tags, tag)
|
||||
}
|
||||
}
|
||||
return child
|
||||
|
|
|
|||
|
|
@ -237,6 +237,7 @@ func (e executor) execBlock(ctx context.Context, options execBlockOptions) error
|
|||
if at.RunOnce { // only run in first host
|
||||
hosts = []string{options.hosts[0]}
|
||||
}
|
||||
tags := kkcorev1.JoinTag(at.Taggable, options.tags)
|
||||
|
||||
// use the most closely configuration
|
||||
ignoreErrors := at.IgnoreErrors
|
||||
|
|
@ -258,7 +259,7 @@ func (e executor) execBlock(ctx context.Context, options execBlockOptions) error
|
|||
role: options.role,
|
||||
blocks: at.Block,
|
||||
when: append(options.when, at.When.Data...),
|
||||
tags: kkcorev1.JoinTag(at.Taggable, options.tags),
|
||||
tags: tags,
|
||||
}); err != nil {
|
||||
klog.V(4).ErrorS(err, "execute tasks from block error", "pipeline", ctrlclient.ObjectKeyFromObject(e.pipeline), "block", at.Name)
|
||||
return err
|
||||
|
|
@ -272,7 +273,7 @@ func (e executor) execBlock(ctx context.Context, options execBlockOptions) error
|
|||
blocks: at.Rescue,
|
||||
role: options.role,
|
||||
when: append(options.when, at.When.Data...),
|
||||
tags: kkcorev1.JoinTag(at.Taggable, options.tags),
|
||||
tags: tags,
|
||||
}); err != nil {
|
||||
klog.V(4).ErrorS(err, "execute tasks from rescue error", "pipeline", ctrlclient.ObjectKeyFromObject(e.pipeline), "block", at.Name)
|
||||
return err
|
||||
|
|
@ -287,7 +288,7 @@ func (e executor) execBlock(ctx context.Context, options execBlockOptions) error
|
|||
blocks: at.Always,
|
||||
role: options.role,
|
||||
when: append(options.when, at.When.Data...),
|
||||
tags: kkcorev1.JoinTag(at.Taggable, options.tags),
|
||||
tags: tags,
|
||||
}); err != nil {
|
||||
klog.V(4).ErrorS(err, "execute tasks from always error", "pipeline", ctrlclient.ObjectKeyFromObject(e.pipeline), "block", at.Name)
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in New Issue