Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable Async call #592

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
be563e9
Draft agent for validation purpose (#576)
iwangjintian Dec 4, 2024
0f35293
rebase
yanjiaxin534 Jan 2, 2025
4cdf749
add log for debug
yanjiaxin534 Dec 31, 2024
2285de6
add solution manager to managers
yanjiaxin534 Dec 31, 2024
ce58a89
log
yanjiaxin534 Dec 31, 2024
2e329ac
another solution-manager
yanjiaxin534 Dec 31, 2024
1c8f439
add pm
yanjiaxin534 Dec 31, 2024
7178552
fix bug
yanjiaxin534 Dec 31, 2024
87f4199
after run save state
yanjiaxin534 Dec 31, 2024
2722e3b
current stats bug fix
yanjiaxin534 Dec 31, 2024
f261c72
fix bug
yanjiaxin534 Dec 31, 2024
3470040
summary add remove
yanjiaxin534 Dec 31, 2024
5073cc7
add clear
yanjiaxin534 Dec 31, 2024
f8bee05
add log in helm
yanjiaxin534 Dec 31, 2024
c15eede
add merge state log
yanjiaxin534 Dec 31, 2024
b8adddf
add log
yanjiaxin534 Dec 31, 2024
99a5fdb
add log
yanjiaxin534 Dec 31, 2024
87f86cc
remove rebase
yanjiaxin534 Dec 31, 2024
8748735
add ext
yanjiaxin534 Dec 31, 2024
2dbaf6d
request bug -no body
yanjiaxin534 Dec 31, 2024
8968e98
fix bug
yanjiaxin534 Dec 31, 2024
ebfdab7
add log for compare
yanjiaxin534 Dec 31, 2024
6225641
fix bug fend agent
yanjiaxin534 Dec 31, 2024
6db75c5
fix bug
yanjiaxin534 Dec 31, 2024
d550347
hard code
yanjiaxin534 Dec 31, 2024
85d4f77
fix operation Id
yanjiaxin534 Dec 31, 2024
d5744a9
return element
yanjiaxin534 Dec 31, 2024
cc1801d
add log
yanjiaxin534 Dec 31, 2024
1bdf607
add more log
yanjiaxin534 Dec 31, 2024
f80bc22
fix remote call bug
yanjiaxin534 Dec 31, 2024
9f825bd
0 step will not be executed
yanjiaxin534 Dec 31, 2024
c6bde47
test judge remote
yanjiaxin534 Dec 31, 2024
63d84a4
fix bug
yanjiaxin534 Dec 31, 2024
22bfb59
add log
yanjiaxin534 Jan 1, 2025
ad1e95c
api client will not check summary formate
yanjiaxin534 Jan 2, 2025
ec4d091
encode body
yanjiaxin534 Jan 2, 2025
0cdf8c1
add remove
yanjiaxin534 Jan 2, 2025
e0c1d79
addlog
yanjiaxin534 Jan 2, 2025
8ea708f
remove log
yanjiaxin534 Jan 2, 2025
57b3824
set remote true
yanjiaxin534 Jan 2, 2025
3b849ab
save summary before publish step
yanjiaxin534 Jan 2, 2025
ce55e20
add heart beat
yanjiaxin534 Jan 2, 2025
b295042
fix FindAgentFromDeploymentState
yanjiaxin534 Jan 2, 2025
d304a6f
add heart beat early
yanjiaxin534 Jan 2, 2025
e068ae9
add lock
yanjiaxin534 Jan 2, 2025
4b7cc13
remove skip
yanjiaxin534 Jan 2, 2025
b086369
unified save summary
yanjiaxin534 Jan 2, 2025
ac41c0c
save more summary
yanjiaxin534 Jan 2, 2025
55df043
summary behind and sleep before retry
yanjiaxin534 Jan 2, 2025
c8999cb
10 second then retry
yanjiaxin534 Jan 2, 2025
a5cbcc7
can not change deploy
yanjiaxin534 Jan 2, 2025
1ef58a7
remove
yanjiaxin534 Jan 2, 2025
eeee0b6
n
yanjiaxin534 Jan 2, 2025
e65f949
add lock
yanjiaxin534 Jan 2, 2025
8eca953
fix
yanjiaxin534 Jan 2, 2025
eeaa8e0
change one file
yanjiaxin534 Jan 2, 2025
e56da78
add one file
yanjiaxin534 Jan 2, 2025
2215d51
all remote
yanjiaxin534 Jan 2, 2025
378ab52
try lock
yanjiaxin534 Jan 2, 2025
2df7c3a
hve lock will no error
yanjiaxin534 Jan 2, 2025
c8dd450
change state code
yanjiaxin534 Jan 2, 2025
1936b38
add summary
yanjiaxin534 Jan 2, 2025
5d1f162
poll interval
yanjiaxin534 Jan 3, 2025
0959271
remove lock
yanjiaxin534 Jan 3, 2025
623b66d
add plannned count
yanjiaxin534 Jan 3, 2025
6179173
debug
yanjiaxin534 Jan 3, 2025
2f37291
remove no use type
yanjiaxin534 Jan 4, 2025
4b6e797
add lock
yanjiaxin534 Jan 4, 2025
2b2a8bc
test findAgent from Deployment State
yanjiaxin534 Jan 4, 2025
1ed15e3
abstract step result publish
yanjiaxin534 Jan 4, 2025
e5491f3
set timeout to 10s
yanjiaxin534 Jan 4, 2025
37d719c
refine function and add timeout
yanjiaxin534 Jan 5, 2025
71fcd3f
add const
yanjiaxin534 Jan 5, 2025
f0437c1
remove expired time
yanjiaxin534 Jan 5, 2025
2aa5866
remove timeout
yanjiaxin534 Jan 5, 2025
9690234
remove no use code
yanjiaxin534 Jan 5, 2025
3110d9a
add more comments and log
yanjiaxin534 Jan 5, 2025
2bef1b3
remove reconcile ut-> func change to async
yanjiaxin534 Jan 5, 2025
88f714f
no install extension
yanjiaxin534 Jan 5, 2025
6ba2f9b
remove no use log
yanjiaxin534 Jan 5, 2025
aa1a391
error -> string
yanjiaxin534 Jan 6, 2025
fb3c0d0
refine error string
yanjiaxin534 Jan 6, 2025
d9ab27d
extend 01 06 execute time
yanjiaxin534 Jan 7, 2025
d03d671
fix one UT bug
yanjiaxin534 Jan 7, 2025
7aaef8c
fix federation test
yanjiaxin534 Jan 8, 2025
ae9845a
fix federation test
yanjiaxin534 Jan 8, 2025
3d1f615
remove spec time in container
yanjiaxin534 Jan 8, 2025
66fa35b
remove spec time in container- remove var
yanjiaxin534 Jan 8, 2025
2784881
fix target result type bug
yanjiaxin534 Jan 8, 2025
26f6382
fix
yanjiaxin534 Jan 8, 2025
130353b
fix bug
yanjiaxin534 Jan 8, 2025
2b0d61a
add apiOperationMetrics add EvaluationContext and fix some log
yanjiaxin534 Jan 8, 2025
7b39585
add lock log
yanjiaxin534 Jan 8, 2025
682bcaf
try lock before unlock
yanjiaxin534 Jan 8, 2025
1b6ff9d
lock and unlock in solution-vendor
yanjiaxin534 Jan 8, 2025
f6f6a08
change remote=agent judge strategy
yanjiaxin534 Jan 8, 2025
044783f
get id bug
yanjiaxin534 Jan 8, 2025
3cec05f
install true
yanjiaxin534 Jan 8, 2025
74908b2
add lock
yanjiaxin534 Jan 8, 2025
fb26211
fix lock issue
yanjiaxin534 Jan 8, 2025
a0b171a
install false
yanjiaxin534 Jan 8, 2025
59ace64
add more log for save summary
yanjiaxin534 Jan 9, 2025
fb4384d
container hard code instance
yanjiaxin534 Jan 9, 2025
ca64da7
error init map
yanjiaxin534 Jan 9, 2025
074def9
add deployment for get request
yanjiaxin534 Jan 9, 2025
856eef5
step container -> instance component type null-> container
yanjiaxin534 Jan 9, 2025
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
51 changes: 39 additions & 12 deletions api/pkg/apis/v1alpha1/managers/solution/solution-manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ func (s *SolutionManager) Init(context *contexts.VendorContext, config managers.
s.TargetProviders[k] = p
}
}

keylockprovider, err := managers.GetKeyLockProvider(config, providers)
if err == nil {
s.KeyLockProvider = keylockprovider
Expand Down Expand Up @@ -150,7 +149,26 @@ func (s *SolutionManager) Init(context *contexts.VendorContext, config managers.
return nil
}

func (s *SolutionManager) getPreviousState(ctx context.Context, instance string, namespace string) *SolutionManagerDeploymentState {
// The deployment spec may have changed, so the previous target is not in the new deployment anymore
func (s *SolutionManager) GetTargetProviderForStep(target string, role string, deployment model.DeploymentSpec, previousDesiredState *SolutionManagerDeploymentState) (providers.IProvider, error) {
var override tgt.ITargetProvider
log.Info("get step role %s", role)
if role == "container" {
role = "instance"
}
log.Info("get target providers %+v", s.TargetProviders)
if v, ok := s.TargetProviders[role]; ok {
return v, nil
}
targetSpec := s.GetTargetStateForStep(target, deployment, previousDesiredState)
provider, err := sp.CreateProviderForTargetRole(s.Context, role, targetSpec, override)
if err != nil {
return nil, err
}
return provider, nil
}

func (s *SolutionManager) GetPreviousState(ctx context.Context, instance string, namespace string) *SolutionManagerDeploymentState {
state, err := s.StateProvider.Get(ctx, states.GetRequest{
ID: instance,
Metadata: map[string]interface{}{
Expand Down Expand Up @@ -336,11 +354,12 @@ func (s *SolutionManager) Reconcile(ctx context.Context, deployment model.Deploy
if deployment.IsDryRun {
summary.SuccessCount = 0
}
s.concludeSummary(ctx, deployment.Instance.ObjectMeta.Name, deployment.Generation, deployment.Hash, summary, namespace)
s.ConcludeSummary(ctx, deployment.Instance.ObjectMeta.Name, deployment.Generation, deployment.Hash, summary, namespace)
} else {
log.ErrorfCtx(ctx, " M (Solution): panic happens: %v", debug.Stack())
panic(r)
}
s.ConcludeSummary(ctx, deployment.Instance.ObjectMeta.Name, deployment.Generation, deployment.Hash, summary, namespace)
}()

defer func() {
Expand Down Expand Up @@ -379,7 +398,7 @@ func (s *SolutionManager) Reconcile(ctx context.Context, deployment model.Deploy
}
}

previousDesiredState := s.getPreviousState(ctx, deployment.Instance.ObjectMeta.Name, namespace)
previousDesiredState := s.GetPreviousState(ctx, deployment.Instance.ObjectMeta.Name, namespace)

var currentDesiredState, currentState model.DeploymentState
currentDesiredState, err = NewDeploymentState(deployment)
Expand Down Expand Up @@ -480,7 +499,7 @@ func (s *SolutionManager) Reconcile(ctx context.Context, deployment model.Deploy

if previousDesiredState != nil {
testState := MergeDeploymentStates(&previousDesiredState.State, currentState)
if s.canSkipStep(ctx, step, step.Target, provider.(tgt.ITargetProvider), previousDesiredState.State.Components, testState) {
if s.CanSkipStep(ctx, step, step.Target, provider.(tgt.ITargetProvider), previousDesiredState.State.Components, testState) {
log.InfofCtx(ctx, " M (Solution): skipping step with role %s on target %s", step.Role, step.Target)
targetResult[step.Target] = 1
planSuccessCount++
Expand Down Expand Up @@ -635,8 +654,17 @@ func (s *SolutionManager) getTargetStateForStep(step model.DeploymentStep, deplo
}
return targetSpec
}

func (s *SolutionManager) saveSummary(ctx context.Context, objectName string, generation string, hash string, summary model.SummarySpec, state model.SummaryState, namespace string) error {
func (s *SolutionManager) GetTargetStateForStep(target string, deployment model.DeploymentSpec, previousDeploymentState *SolutionManagerDeploymentState) model.TargetState {
//first find the target spec in the deployment
targetSpec, ok := deployment.Targets[target]
if !ok {
if previousDeploymentState != nil {
targetSpec = previousDeploymentState.Spec.Targets[target]
}
}
return targetSpec
}
func (s *SolutionManager) SaveSummary(ctx context.Context, objectName string, generation string, hash string, summary model.SummarySpec, state model.SummaryState, namespace string) error {
// TODO: delete this state when time expires. This should probably be invoked by the vendor (via GetSummary method, for instance)
log.DebugfCtx(ctx, " M (Solution): saving summary, objectName: %s, state: %s, namespace: %s, jobid: %s, hash %s, targetCount %d, successCount %d",
objectName, state, namespace, summary.JobID, hash, summary.TargetCount, summary.SuccessCount)
Expand Down Expand Up @@ -684,15 +712,14 @@ func (s *SolutionManager) saveSummary(ctx context.Context, objectName string, ge
}

func (s *SolutionManager) saveSummaryProgress(ctx context.Context, objectName string, generation string, hash string, summary model.SummarySpec, namespace string) error {
return s.saveSummary(ctx, objectName, generation, hash, summary, model.SummaryStateRunning, namespace)
return s.SaveSummary(ctx, objectName, generation, hash, summary, model.SummaryStateRunning, namespace)
}

func (s *SolutionManager) concludeSummary(ctx context.Context, objectName string, generation string, hash string, summary model.SummarySpec, namespace string) error {
return s.saveSummary(ctx, objectName, generation, hash, summary, model.SummaryStateDone, namespace)
func (s *SolutionManager) ConcludeSummary(ctx context.Context, objectName string, generation string, hash string, summary model.SummarySpec, namespace string) error {
return s.SaveSummary(ctx, objectName, generation, hash, summary, model.SummaryStateDone, namespace)
}

func (s *SolutionManager) canSkipStep(ctx context.Context, step model.DeploymentStep, target string, provider tgt.ITargetProvider, previousComponents []model.ComponentSpec, currentState model.DeploymentState) bool {

func (s *SolutionManager) CanSkipStep(ctx context.Context, step model.DeploymentStep, target string, provider tgt.ITargetProvider, previousComponents []model.ComponentSpec, currentState model.DeploymentState) bool {
for _, newCom := range step.Components {
key := fmt.Sprintf("%s::%s", newCom.Component.Name, target)
if newCom.Action == model.ComponentDelete {
Expand Down
1 change: 1 addition & 0 deletions api/pkg/apis/v1alpha1/model/summary.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const (
SummaryStatePending SummaryState = iota // Currently unused
SummaryStateRunning // Should indicate that a reconcile operation is in progress
SummaryStateDone // Should indicate that a reconcile operation has completed either successfully or unsuccessfully
SummaryStateTimeout
)

type SummaryState int
Expand Down
1 change: 0 additions & 1 deletion api/pkg/apis/v1alpha1/providers/target/helm/helm.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ func (i *HelmTargetProvider) Get(ctx context.Context, deployment model.Deploymen
}
}
}

return ret, nil
}

Expand Down
1 change: 0 additions & 1 deletion api/pkg/apis/v1alpha1/utils/apiclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,6 @@ func (a *apiClient) QueueJob(ctx context.Context, id string, namespace string, i
func (a *apiClient) Reconcile(ctx context.Context, deployment model.DeploymentSpec, isDelete bool, namespace string, user string, password string) (model.SummarySpec, error) {
summary := model.SummarySpec{}
payload, _ := json.Marshal(deployment)

path := "solution/reconcile" + "?namespace=" + namespace
if isDelete {
path = path + "&delete=true"
Expand Down
Loading
Loading