Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions pkg/engine/operation/graph/resource_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (rn *ResourceNode) Execute(operation *opsmodels.Operation) status.Status {
case opsmodels.ApplyPreview, opsmodels.DestroyPreview:
fillResponseChangeSteps(operation, rn, liveState, predictableState)
case opsmodels.Apply, opsmodels.Destroy:
if s = rn.applyResource(operation, priorState, planedState); status.IsErr(s) {
if s = rn.applyResource(operation, priorState, planedState, liveState); status.IsErr(s) {
return s
}
default:
Expand All @@ -120,9 +120,9 @@ func (rn *ResourceNode) Execute(operation *opsmodels.Operation) status.Status {
return nil
}

func (rn *ResourceNode) applyResource(operation *opsmodels.Operation, priorState, planedState *models.Resource) status.Status {
func (rn *ResourceNode) applyResource(operation *opsmodels.Operation, priorState, planedState, live *models.Resource) status.Status {
log.Infof("operation:%v, prior:%v, plan:%v, live:%v", rn.Action, jsonutil.Marshal2String(priorState),
jsonutil.Marshal2String(planedState))
jsonutil.Marshal2String(planedState), jsonutil.Marshal2String(live))

var res *models.Resource
var s status.Status
Expand All @@ -145,8 +145,13 @@ func (rn *ResourceNode) applyResource(operation *opsmodels.Operation, priorState
log.Debugf("delete state: %v", s.String())
}
case opsmodels.UnChange:
log.Infof("planed resource not update live state")
res = priorState
log.Infof("planed resource and live state are equal")
// auto import resources exist in spec and live cluster but no recorded in kusion_state.json
if priorState == nil {
res = live
} else {
res = priorState
}
}
if status.IsErr(s) {
return s
Expand Down