-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
KEP-29: Introducing operator dependency cycle detection to the instan…
…ce controller (#1559) (#1567) Summary: Operator dependencies cycle detection is now part of the instance controller reconciliation. We execute the check for the top-level instances only since the lower-level instances are already take care of. Signed-off-by: Aleksey Dukhovniy <alex.dukhovniy@googlemail.com> Fixes #1513
- Loading branch information
Aleksey Dukhovniy
committed
Jun 22, 2020
1 parent
9db03a9
commit 9246c05
Showing
19 changed files
with
159 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package v1beta1 | ||
|
||
import ( | ||
"context" | ||
|
||
"k8s.io/apimachinery/pkg/types" | ||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
) | ||
|
||
func GetOperator(name, ns string, c client.Client) (*Operator, error) { | ||
o := &Operator{} | ||
err := c.Get(context.TODO(), types.NamespacedName{Name: name, Namespace: ns}, o) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return o, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package instance | ||
|
||
import ( | ||
"fmt" | ||
|
||
"sigs.k8s.io/controller-runtime/pkg/client" | ||
|
||
"github.com/kudobuilder/kudo/pkg/apis/kudo/v1beta1" | ||
"github.com/kudobuilder/kudo/pkg/kudoctl/packages" | ||
) | ||
|
||
// InClusterResolver resolves packages that are already installed in the cluster. Note, that unlike other resolvers, the | ||
// resulting 'packages.Package' struct does not contain package 'packages.Files' (we don't have the original files) and | ||
// doesn't have an Instance resource because multiple Instances of the same Operator/OperatorVersion can exist | ||
type InClusterResolver struct { | ||
c client.Client | ||
ns string | ||
} | ||
|
||
func (r InClusterResolver) Resolve(name string, appVersion string, operatorVersion string) (*packages.Package, error) { | ||
ovn := v1beta1.OperatorVersionName(name, operatorVersion) | ||
|
||
ov, err := v1beta1.GetOperatorVersionByName(ovn, r.ns, r.c) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to resolve operator version %s/%s:%s", r.ns, ovn, appVersion) | ||
} | ||
|
||
// sanity check, as there is an explicit 1:1 relationship between an operator and app version | ||
if ov.Spec.AppVersion != appVersion { | ||
return nil, fmt.Errorf("found operator version %s/%s but found appVersion %s is not equal to the requested %s", r.ns, ovn, ov.Spec.AppVersion, appVersion) | ||
} | ||
|
||
o, err := v1beta1.GetOperator(name, r.ns, r.c) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to resolve operator %s/%s", r.ns, name) | ||
} | ||
|
||
return &packages.Package{ | ||
Resources: &packages.Resources{ | ||
Operator: o, | ||
OperatorVersion: ov, | ||
Instance: nil, | ||
}, | ||
Files: nil, | ||
}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.