fix: adjust service account managed fields#527
Conversation
ae7e776 to
732276f
Compare
If deployed resource previously had a service account reference, and it does not have `serviceAccountName` and `serviceAccount` params anymore, we must make both `serviceAccount` and `serviceAccountName` params managed to plan/converge work as expected. This is due to SSA operation.
To test the PR, deploy the following chart:
```
Signed-off-by: Ilya Drey <ilya.drey@flant.com>
---
apiVersion: apps/v1
kind: Deployment
metadata:
annotations: {}
labels: {}
name: service-account-removal
spec:
replicas: 2
selector:
matchLabels:
app: service-account-removal
template:
metadata:
labels:
app: service-account-removal
spec:
containers:
- args:
- |
echo "Ready"
touch /tmp/ready
sleep 3600
command:
- sh
- -c
image: alpine:latest
name: app
readinessProbe:
exec:
command:
- /bin/sh
- -c
- cat /tmp/ready && exit 0 || exit 1
initialDelaySeconds: 5
serviceAccountName: service-account-removal
---
apiVersion: v1
kind: ServiceAccount
metadata:
annotations: {}
labels: {}
name: service-account-removal
```
Next, remove `serviceAccountName` from the deployment and run plan again. The `serviceAccountName` should be marked as deleted in the plan output:
```
<skipped>
┌ Update Deployment/service-account-removal
│ restartPolicy: Always
│ schedulerName: default-scheduler
│ securityContext: {}
│ - serviceAccount: service-account-removal
│ - serviceAccountName: service-account-removal
│ terminationGracePeriodSeconds: 30
└ Update Deployment/service-account-removal
<skipped>
```
732276f to
98258a0
Compare
|
/review |
Changelist by BitoThis pull request implements the following key changes.
|
Interaction Diagram by BitosequenceDiagram
participant CLI as nelm CLI
participant RIA as ReleaseInstallAction<br/>pkg/action/release_install.go
participant BRI as BuildResourceInfos<br/>internal/plan/resource_info.go<br/>🔄 Updated | ●●○ Medium
participant BIR as buildInstallableResourceInfo<br/>internal/plan/resource_info.go<br/>🔄 Updated | ●●○ Medium
participant FMFC as fixManagedFieldsInCluster<br/>internal/plan/resource_info.go<br/>🔄 Updated | ●●○ Medium
participant FMF as fixManagedFields<br/>internal/plan/resource_info.go<br/>🔄 Updated | ●●○ Medium
participant ISAMFFR as isServiceAccountManagedFieldFixRequired<br/>internal/plan/resource_info.go<br/>🟩 Added | ●●● High
participant FSAMF as fixServiceAccountManagedFields<br/>internal/plan/resource_info.go<br/>🟩 Added | ●●● High
participant KC as KubeClient<br/>kube.ClientFactorier
CLI->>RIA: nelm release install
RIA->>BRI: BuildResourceInfos(ctx, deployType, ...)
BRI->>BIR: buildInstallableResourceInfo(ctx, localRes, ...)
BIR->>FMFC: fixManagedFieldsInCluster(ctx, releaseNamespace, getObj, localRes, ...)
FMFC->>FMF: fixManagedFields(getObj, localRes, noRemoveManualChanges)
FMF->>ISAMFFR: isServiceAccountManagedFieldFixRequired(localRes.Unstruct, &oursEntry)
ISAMFFR-->>FMF: return required (bool)
alt [service account fix required]
FMF->>FSAMF: fixServiceAccountManagedFields(&oursEntry, subPath)
FSAMF-->>FMF: return error
Note over FMF: Set changed = true
end
FMF-->>FMFC: return changed, err
alt [changed]
FMFC->>KC: MergePatch(ctx, localRes.ResourceMeta, patch, ...)
KC-->>FMFC: return patchedObj, err
end
FMFC-->>BIR: return patchedObj, err
BIR-->>BRI: return infos, err
BRI-->>RIA: return instResourceInfos, delResourceInfos, err
RIA-->>CLI: installation complete
Critical path: nelm CLI -> BuildResourceInfos -> fixManagedFieldsInCluster -> fixManagedFields -> KubeClient
If the interaction diagram doesn't appear, refresh the page to render it. You can disable interaction diagrams by customizing agent settings. Refer to documentation. |
There was a problem hiding this comment.
Code Review Agent Run #9ce86b
Actionable Suggestions - 1
-
internal/plan/resource_info.go - 1
- Error Handling Issue · Line 541-549
Review Details
-
Files reviewed - 1 · Commit Range:
98258a0..98258a0- internal/plan/resource_info.go
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Golangci-lint (Linter) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at ilya.lesikov@flant.com.
Documentation & Help
Signed-off-by: Ilya Drey <ilya.drey@flant.com>
There was a problem hiding this comment.
Code Review Agent Run #5a2d95
Actionable Suggestions - 1
-
internal/plan/resource_info.go - 1
- Incorrect FieldsV1 field removal · Line 699-704
Review Details
-
Files reviewed - 1 · Commit Range:
98258a0..63ba307- internal/plan/resource_info.go
-
Files skipped - 0
-
Tools
- Whispers (Secret Scanner) - ✔︎ Successful
- Detect-secrets (Secret Scanner) - ✔︎ Successful
- Golangci-lint (Linter) - ✔︎ Successful
Bito Usage Guide
Commands
Type the following command in the pull request comment and save the comment.
-
/review- Manually triggers a full AI review. -
/pause- Pauses automatic reviews on this pull request. -
/resume- Resumes automatic reviews. -
/resolve- Marks all Bito-posted review comments as resolved. -
/abort- Cancels all in-progress reviews.
Refer to the documentation for additional commands.
Configuration
This repository uses Default Agent You can customize the agent settings here or contact your Bito workspace admin at ilya.lesikov@flant.com.
Documentation & Help
Signed-off-by: Ilya Drey <ilya.drey@flant.com>
Signed-off-by: Ilya Drey <ilya.drey@flant.com>
7db2063 to
1bb6e00
Compare
If deployed resource previously had a service account reference, and it does not have
serviceAccountNameandserviceAccountparams anymore, we must make bothserviceAccountandserviceAccountNameparams managed to plan/converge work as expected. This is due to SSA operation.To test the PR, deploy the following chart with
NELM_FEAT_CLEAN_NULL_FIELDSenvironment variable set totrue:Next, remove
serviceAccountNamefrom the deployment and run plan again. TheserviceAccountNameshould be marked as deleted in the plan output:Summary by Bito